Re: [PATCH 5/6] sched_ext: Report the ecaps loss when a cpu goes offline

From: Andrea Righi

Date: Sun Oct 18 2026 - 02:51:24 EST


Hi Tejun,

On Sat, Oct 17, 2026 at 03:59:51PM -1000, Tejun Heo wrote:
> When a cpu goes offline, a sub-scheduler's effective caps on its cid are
> cleared, but neither the sub-scheduler nor its parent is notified. The
> sub-scheduler keeps treating the cid as usable, and the parent can't act on
> the loss, e.g. reset the cpuperf target.
>
> Report the loss before the root's ops.cpu_offline() and the regain after its
> ops.cpu_online(). The zeroing at offline was the last change to a sched's
> ecaps outside a delivery, so they now change only with one. Syncs on an
> inactive cpu are processed instead of discarded, and the reseed reschedules
> the cpu itself, as they got no resched when queued. Suspend and hibernation
> now report their cpu downs and ups as well. This is temporary, and a later
> patch leaves them out.
>
> Two things need care. A cpu going down marks a sync for each sub-scheduler,
> and its hotplug thread waits until each marked sync has been processed. The
> cpu's own ext picks process them, and the ext server is started in case a
> fair task holds the cpu. Only the marked syncs count, so a flood of changes
> on the cid can't hold up the hotplug.
>
> The detach report reaches only active cpus. It holds off cpu hotplug, so a
> cpu it skips has reported its loss as it went down, and no unreported loss
> is left to drop.
>
> Drop the cpuperf reset from scx_qmap's ops.sub_detach(), as its
> ops.sub_child_ecaps_updated() now resets the targets on the loss reports.
>
> v2: Reschedule from the irq work and document the regain order.
>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> ---
...
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index 05cf0f0056e9..59dfe7999603 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -846,6 +846,7 @@ struct scx_rq {
> /* sched of the open running session, see scx_cid_sched_update() */
> struct scx_sched *sched;
> struct llist_head ecaps_to_sync; /* pending ecaps syncs */
> + u32 nr_ecaps_offline; /* marked syncs a down waits for */
> struct task_struct *sub_dispatch_prev;
> #endif
> cpumask_var_t cpus_to_sync;

nit: nr_ecaps_offline lands between two 8-byte aligned fields, which adds
a 4-byte hole and shifts everything after it (kick_sync included) by 8
bytes. Can we move it next to kick_sync_pending instead? Something like:

#ifdef CONFIG_EXT_SUB_SCHED
/* sched of the open running session, see scx_cid_sched_update() */
struct scx_sched *sched;
struct llist_head ecaps_to_sync; /* pending ecaps syncs */
struct task_struct *sub_dispatch_prev;
u32 nr_ecaps_offline; /* marked syncs a down waits for */
#endif
bool kick_sync_pending;
cpumask_var_t cpus_to_sync;
unsigned long kick_sync;

This way the u32 and the bool share the existing hole, and kick_sync and
the following fields keep their current offsets.

Thanks,
-Andrea