[XEN PATCH] xen/credit2: let the tickled pCPU pick up the unit it was tickled for

Jiaqing Zhao posted 1 patch 3 weeks, 3 days ago
There is a newer version of this series
xen/common/sched/credit2.c | 1 +
1 file changed, 1 insertion(+)
[XEN PATCH] xen/credit2: let the tickled pCPU pick up the unit it was tickled for
Posted by Jiaqing Zhao 3 weeks, 3 days ago
runq_tickle() picks an idle pCPU without taking CSCHED2_MIGRATE_RESIST
into account, but runq_candidate() on that pCPU still applies it. With
the unit's credit within CSCHED2_MIGRATE_RESIST of CSCHED2_CREDIT_MIN,
the tickled pCPU declines the unit because it is not its master, while
the master has already skipped it as deferred to the tickled pCPU. Both
go idle and the unit stays runnable on the runqueue with nobody to run
it.

Seen as a permanent PVH dom0 stall under nested virtualization, where
dom0 overruns its slice far enough to be clamped at CSCHED2_CREDIT_MIN.

Don't resist migration to the pCPU that was tickled for the unit.

Fixes: 069cf39fb171 ("xen: credit2: make tickling more deterministic")
Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
---
 xen/common/sched/credit2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c
index 4949606881..3791a8d4cd 100644
--- a/xen/common/sched/credit2.c
+++ b/xen/common/sched/credit2.c
@@ -3517,6 +3517,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,
          * its credit is at least CSCHED2_MIGRATE_RESIST higher.
          */
         if ( sched_unit_master(svc->unit) != cpu
+             && svc->tickled_cpu != cpu
              && snext->credit + CSCHED2_MIGRATE_RESIST > svc->credit )
         {
             SCHED_STAT_CRANK(migrate_resisted);
-- 
2.53.0
Re: [XEN PATCH] xen/credit2: let the tickled pCPU pick up the unit it was tickled for
Posted by George Dunlap 3 weeks, 2 days ago
On Tue, Sep 29, 2026 at 3:07 PM Jiaqing Zhao <Zhao.Jiaqing@amd.com> wrote:
>
> runq_tickle() picks an idle pCPU without taking CSCHED2_MIGRATE_RESIST
> into account, but runq_candidate() on that pCPU still applies it. With
> the unit's credit within CSCHED2_MIGRATE_RESIST of CSCHED2_CREDIT_MIN,
> the tickled pCPU declines the unit because it is not its master, while
> the master has already skipped it as deferred to the tickled pCPU. Both
> go idle and the unit stays runnable on the runqueue with nobody to run
> it.
>
> Seen as a permanent PVH dom0 stall under nested virtualization, where
> dom0 overruns its slice far enough to be clamped at CSCHED2_CREDIT_MIN.
>
> Don't resist migration to the pCPU that was tickled for the unit.
>
> Fixes: 069cf39fb171 ("xen: credit2: make tickling more deterministic")
> Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
> ---
>  xen/common/sched/credit2.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c
> index 4949606881..3791a8d4cd 100644
> --- a/xen/common/sched/credit2.c
> +++ b/xen/common/sched/credit2.c
> @@ -3517,6 +3517,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,
>           * its credit is at least CSCHED2_MIGRATE_RESIST higher.
>           */
>          if ( sched_unit_master(svc->unit) != cpu
> +             && svc->tickled_cpu != cpu

Thanks for this.  This is the right fix; the only issue is that the
comment above this is stale; it needs to be expanded to include the
extra condition you've added here.

With that addressed:

Reviewed-by: George Dunlap <gwd@xenproject.org>