Re: [PATCH v3 1/2] sched/core: Preserve WF_RQ_SELECTED across queued wakeups

From: Tejun Heo

Date: Mon Nov 30 2026 - 11:55:38 EST


On Mon, Nov 30, 2026 at 01:05:57PM +0000, Kuba Piecuch wrote:
> ENQUEUE_RQ_SELECTED tells a sched_class that ->select_task_rq() was
> called for a task wakeup. sched_ext exposes this flag to BPF schedulers
> as SCX_ENQ_CPU_SELECTED.
>
> When a BPF scheduler sets SCX_OPS_ALLOW_QUEUED_WAKEUP, a wakeup can be
> delivered through the ttwu wakelist in two ways:
>
> 1) from the p->on_cpu path, before ->select_task_rq() is called. In this
> case WF_RQ_SELECTED is not set and SCX_ENQ_CPU_SELECTED is correctly
> clear;
>
> 2) from ttwu_queue(), after ->select_task_rq() has been called. In this
> case WF_RQ_SELECTED is set in wake_flags, but sched_ttwu_pending()
> only carries WF_MIGRATED across the wakelist, so the flag is dropped
> and ops.enqueue() is wrongly told that ops.select_cpu() was skipped.
> This also results in undercounting SCX_EV_SELECT_CPU_FALLBACK events.
>
> Fix case 2 by preserving WF_RQ_SELECTED across the wakelist in the same
> way WF_MIGRATED is, so that ttwu_do_activate() passes
> ENQUEUE_RQ_SELECTED to activate_task(). Case 1 is unaffected.
>
> Fixes: 3539c6411a7c ("sched_ext: Implement SCX_OPS_ALLOW_QUEUED_WAKEUP")
> Cc: stable@xxxxxxxxxxxxxxx # v6.15+
> Acked-by: Tejun Heo <tj@xxxxxxxxxx>
> Reviewed-by: Andrea Righi <arighi@xxxxxxxxxx>
> Signed-off-by: Kuba Piecuch <jpiecuch@xxxxxxxxxx>

Peter, would it be okay to route this through sched_ext?

Thanks.

--
tejun