mcs: Don't pass capacity through calls

The capacity does not need to be passed as an argument to
refill_check_budget as all information that it was being used for can be
dertermined from the usage directly.

Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
This commit is contained in:
Curtis Millar 2019-07-24 16:09:05 +10:00 committed by Kent McLeod
parent c06a6c9a93
commit 0fbf2f7da3
6 changed files with 10 additions and 15 deletions

View file

@ -128,10 +128,8 @@ void refill_update(sched_context_t *sc, ticks_t new_period, ticks_t new_budget,
* the head refill, resulting in refill_sufficient failing.
*
* @param usage the amount of time to charge.
* @param capacity the value returned by refill_capacity. At most call sites this
* has already been calculated so pass the value in rather than calculating it again.
*/
void refill_budget_check(ticks_t used, ticks_t capacity);
void refill_budget_check(ticks_t used);
/*
* Charge a the current scheduling context `used` amount from its

View file

@ -217,7 +217,7 @@ static inline void updateRestartPC(tcb_t *tcb)
void endTimeslice(bool_t can_timeout_fault);
/* called when a thread has used up its head refill */
void chargeBudget(ticks_t capacity, ticks_t consumed, bool_t canTimeoutFault, word_t core, bool_t isCurCPU);
void chargeBudget(ticks_t consumed, bool_t canTimeoutFault, word_t core, bool_t isCurCPU);
/* Update the kernels timestamp and stores in ksCurTime.
* The difference between the previous kernel timestamp and the one just read
@ -260,7 +260,7 @@ static inline bool_t checkBudget(void)
return true;
}
chargeBudget(capacity, NODE_STATE(ksConsumed), true, CURRENT_CPU_INDEX(), true);
chargeBudget(NODE_STATE(ksConsumed), true, CURRENT_CPU_INDEX(), true);
return false;
}

View file

@ -589,8 +589,7 @@ static inline void mcsIRQ(irq_t irq)
checkBudget();
} else if (NODE_STATE(ksCurSC)->scRefillMax) {
/* otherwise, if the thread is not schedulable, the SC could be valid - charge it if so */
ticks_t capacity = refill_capacity(NODE_STATE(ksCurSC), NODE_STATE(ksConsumed));
chargeBudget(capacity, NODE_STATE(ksConsumed), false, CURRENT_CPU_INDEX(), true);
chargeBudget(NODE_STATE(ksConsumed), false, CURRENT_CPU_INDEX(), true);
}
}
@ -605,7 +604,7 @@ static void handleYield(void)
#ifdef CONFIG_KERNEL_MCS
/* Yield the current remaining budget */
ticks_t consumed = NODE_STATE(ksCurSC)->scConsumed;
chargeBudget(0, REFILL_HEAD(NODE_STATE(ksCurSC)).rAmount, false, CURRENT_CPU_INDEX(), true);
chargeBudget(REFILL_HEAD(NODE_STATE(ksCurSC)).rAmount, false, CURRENT_CPU_INDEX(), true);
NODE_STATE(ksCurSC)->scConsumed = consumed;
#else
tcbSchedDequeue(NODE_STATE(ksCurThread));

View file

@ -234,10 +234,11 @@ static inline void ensure_sufficient_head(sched_context_t *sc)
}
}
void refill_budget_check(ticks_t usage, ticks_t capacity)
void refill_budget_check(ticks_t usage)
{
sched_context_t *sc = NODE_STATE(ksCurSC);
/* this function should only be called when the sc is out of budget */
ticks_t capacity = refill_capacity(NODE_STATE(ksCurSC), usage);
assert(capacity < MIN_BUDGET || refill_full(sc));
assert(sc->scPeriod > 0);
REFILL_SANITY_START(sc);

View file

@ -579,7 +579,7 @@ void setNextInterrupt(void)
setDeadline(next_interrupt - getTimerPrecision());
}
void chargeBudget(ticks_t capacity, ticks_t consumed, bool_t canTimeoutFault, word_t core, bool_t isCurCPU)
void chargeBudget(ticks_t consumed, bool_t canTimeoutFault, word_t core, bool_t isCurCPU)
{
if (isRoundRobin(NODE_STATE_ON_CORE(ksCurSC, core))) {
@ -587,7 +587,7 @@ void chargeBudget(ticks_t capacity, ticks_t consumed, bool_t canTimeoutFault, wo
REFILL_HEAD(NODE_STATE_ON_CORE(ksCurSC, core)).rAmount += REFILL_TAIL(NODE_STATE_ON_CORE(ksCurSC, core)).rAmount;
REFILL_TAIL(NODE_STATE_ON_CORE(ksCurSC, core)).rAmount = 0;
} else {
refill_budget_check(consumed, capacity);
refill_budget_check(consumed);
}
assert(REFILL_HEAD(NODE_STATE_ON_CORE(ksCurSC, core)).rAmount >= MIN_BUDGET);

View file

@ -35,10 +35,7 @@ static exception_t invokeSchedControl_Configure(sched_context_t *target, word_t
commitTime();
#ifdef ENABLE_SMP_SUPPORT
} else {
/* if its a remote core, manually charge the budget */
ticks_t capacity = refill_capacity(target, NODE_STATE_ON_CORE(ksConsumed, target->scCore));
chargeBudget(capacity, NODE_STATE_ON_CORE(ksConsumed, target->scCore), false, target->scCore, false);
chargeBudget(NODE_STATE_ON_CORE(ksConsumed, target->scCore), false, target->scCore, false);
doReschedule(target->scCore);
}
#endif /* ENABLE_SMP_SUPPORT */