[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[4.22?] Re: [PATCH] sched/rtds: refill cur_budget when extratime is toggled on a depleted vCPU


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 25 Jun 2026 08:31:14 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID"
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Dario Faggioli <dfaggioli@xxxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>, Meng Xu <mengxu@xxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 25 Jun 2026 06:31:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.05.2026 11:08, Juergen Gross wrote:
> On 20.05.26 15:57, Oleksii Moisieiev wrote:
>> XEN_DOMCTL_SCHEDOP_putvcpuinfo can flip the RTDS_extratime bit on a vCPU
>> that is currently depleted (cur_budget == 0, possibly sitting on the
>> depleted queue). rt_dom_cntl() touches only svc->flags; cur_budget is
>> left unchanged. As a result the next code path that calls runq_insert()
>> on this vCPU - rt_unit_wake() after a domain_unpause(),
>> rt_context_saved() following a delayed runq add, or repl_timer_handler()
>> after a replenishment - places the vCPU on the run queue, because
>> has_extratime(svc) is now true and runq_insert() admits extratime units
>> regardless of cur_budget:
>>
>>      /* add svc to runq if svc still has budget or its extratime is set */
>>      if ( svc->cur_budget > 0 ||
>>           has_extratime(svc) )
>>          deadline_runq_insert(svc, &svc->q_elem, runq);
>>      else
>>          list_add(&svc->q_elem, &prv->depletedq);
>>
>> The very next rt_schedule() iterates the run queue from runq_pick()
>> and trips the ASSERT(iter_svc->cur_budget > 0) at the bottom of the
>> loop, panicking the host. Observed trace:
>>
>>      Assertion 'iter_svc->cur_budget > 0' failed at common/sched/rt.c:1035
>>      ----[ Xen-4.22-unstable  arm64  debug=y ubsan=y  Not tainted ]----
>>      [<...>] rt.c#rt_schedule+0x1558/0x33e0 (PC)
>>      [<...>] core.c#do_schedule+0x2e4/0x15b4
>>      [<...>] core.c#schedule+0xb14/0xe50
>>      [<...>] softirq.c#__do_softirq+0x20c/0x3d4
>>      [<...>] do_softirq+0x14/0x1c
>>      [<...>] domain.c#idle_loop+0x194/0x558
>>
>> Minimal reproducer: pin a single-vCPU domU to a pCPU, program RTDS with
>> extratime off and a low utilisation (e.g. budget = 10ms / period = 100ms)
>> so the vCPU spends most of its time in the depleted queue, pause the
>> domain, issue a putvcpuinfo that sets XEN_DOMCTL_SCHEDRT_extra, then
>> unpause. As soon as the schedule softirq fires on the pCPU, the BUG
>> hits. The same sequence is reachable without an explicit pause: any
>> window in which rt_dom_cntl() runs between burn_budget()'s budget
>> exhaustion and rt_context_saved()'s runq_insert() also closes onto the
>> same broken state, because the per-scheduler lock is dropped between
>> those two points.
>>
>> The semantics for "extratime gets exhausted budget refilled" already
>> live in burn_budget():
>>
>>      if ( has_extratime(svc) )
>>      {
>>          svc->priority_level++;
>>          svc->cur_budget = svc->budget;
>>      }
>>
>> Apply the same priority-demotion-and-refill in rt_dom_cntl() when the
>> flag transitions from off to on while the vCPU is depleted, clear
>> RTDS_depleted to match, and - if the vCPU is currently on the depleted
>> queue - move it to the run queue using the same q_remove() +
>> runq_insert() pattern already used by repl_timer_handler(). The vCPU
>> remains on the replenishment queue throughout, so its normal
>> replenishment cadence is preserved.
>>
>> The complementary transition (on -> off) is already safe: clearing the
>> flag only narrows the runq_insert() admission condition, so subsequent
>> depleted insertions correctly route to the depleted queue.
>>
>> No other call sites need changes: with cur_budget restored before the
>> flag is observable to runq_insert(), runq_pick()'s long-standing
>> invariant (every run-queue entry has cur_budget > 0) is preserved.
>>
> 
> This is missing
> 
> Fixes: 463b95831778 ("xen:rtds: towards work conserving RTDS")
> 
>> Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@xxxxxxxx>
> 
> With the "Fixes:" tag added:
> 
> Reviewed-by: Juergen Gross <jgross@xxxxxxxx>

And then perhaps wanted in 4.22 right away (rather than later as a backport).
Oleksii?

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.