public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	sched-ext@lists.linux.dev, Emil Tsalapatis <emil@etsalapatis.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH sched_ext/for-7.0-fixes] sched_ext: Fix enqueue_task_scx() truncation of upper enqueue flags
Date: Sat, 7 Mar 2026 07:50:12 +0100	[thread overview]
Message-ID: <aavKpFRhyV8U5SBb@gpd4> (raw)
In-Reply-To: <9b72570da1834f89d8f6017ce3b14db0@kernel.org>

On Fri, Mar 06, 2026 at 02:23:13PM -1000, Tejun Heo wrote:
> enqueue_task_scx() takes int enq_flags from the sched_class interface.
> SCX enqueue flags starting at bit 32 (SCX_ENQ_PREEMPT and above) are
> silently truncated when passed through activate_task(). extra_enq_flags
> was added as a workaround - storing high bits in rq->scx.extra_enq_flags
> and OR-ing them back in enqueue_task_scx(). However, the OR target is
> still the int parameter, so the high bits are lost anyway.
> 
> The current impact is limited as the only affected flag is SCX_ENQ_PREEMPT
> which is informational to the BPF scheduler - its loss means the scheduler
> doesn't know about preemption but doesn't cause incorrect behavior.
> 
> Fix by renaming the int parameter to core_enq_flags and introducing a
> u64 enq_flags local that merges both sources. All downstream functions
> already take u64 enq_flags.
> 
> Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
> Cc: stable@vger.kernel.org # v6.12+
> Signed-off-by: Tejun Heo <tj@kernel.org>

Good catch.

Acked-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> ---
>  kernel/sched/ext.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index XXXXXXX..XXXXXXX 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -1728,16 +1728,15 @@ static void clr_task_runnable(struct task_struct *p)
>  		p->scx.flags |= SCX_TASK_RESET_RUNNABLE_AT;
>  }
> 
> -static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int enq_flags)
> +static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int core_enq_flags)
>  {
>  	struct scx_sched *sch = scx_task_sched(p);
>  	int sticky_cpu = p->scx.sticky_cpu;
> +	u64 enq_flags = core_enq_flags | rq->scx.extra_enq_flags;
> 
>  	if (enq_flags & ENQUEUE_WAKEUP)
>  		rq->scx.flags |= SCX_RQ_IN_WAKEUP;
> 
> -	enq_flags |= rq->scx.extra_enq_flags;
> -
>  	/*
>  	 * Restoring a running task will be immediately followed by
>  	 * set_next_task_scx() which expects the task to not be on the BPF
> --
> tejun

  reply	other threads:[~2026-03-07  6:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-07  0:23 [PATCH sched_ext/for-7.0-fixes] sched_ext: Fix enqueue_task_scx() truncation of upper enqueue flags Tejun Heo
2026-03-07  6:50 ` Andrea Righi [this message]
2026-03-07 15:04 ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aavKpFRhyV8U5SBb@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=emil@etsalapatis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox