Commit 133e9969 authored by Jan Kiszka's avatar Jan Kiszka

cobalt: sched-quota: Fix live-updating if quotas, once more

f116e7eb already tried to enable live updates of a quota group but
got one thing wrong and missed another catch:

First, we must not use group_is_active() to check if the group is
currently consuming time. That has to be the same logic as in
xnsched_quota_pick(), i.e. a check of the currently running thread on
the target sched belongs to the modified group.

The second issue is that, if a group had no budget on refill or consumed
it in this period already, an extension of the budget missed to move
expired threads back to the runqueue.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
parent e0d83ca3
......@@ -584,8 +584,10 @@ void xnsched_quota_set_limit(struct xnsched_quota_group *tg,
int quota_percent, int quota_peak_percent,
int *quota_sum_r)
struct xnsched_quota *qs = &tg->sched->quota;
struct xnsched *sched = tg->sched;
struct xnsched_quota *qs = &sched->quota;
xnticks_t old_quota_ns = tg->quota_ns;
struct xnthread *thread, *tmp, *curr;
xnticks_t now, elapsed, consumed;
......@@ -611,7 +613,9 @@ void xnsched_quota_set_limit(struct xnsched_quota_group *tg,
tg->quota_percent = quota_percent;
tg->quota_peak_percent = quota_peak_percent;
if (group_is_active(tg)) {
curr = sched->curr;
if (curr->quota == tg &&
xnthread_test_state(curr, XNREADY|XNTHREAD_BLOCK_BITS) == 0) {
now = xnclock_read_monotonic(&nkclock);
elapsed = now - tg->run_start_ns;
......@@ -638,11 +642,19 @@ void xnsched_quota_set_limit(struct xnsched_quota_group *tg,
*quota_sum_r = quota_sum_all(qs);
if (tg->run_budget_ns > 0) {
list_for_each_entry_safe_reverse(thread, tmp, &tg->expired,
quota_expired) {
xnsched_addq(&sched->rt.runnable, thread);
* Apply the new budget immediately, in case a member of this
* group is currently running.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment