Sched_ext development
 help / color / mirror / Atom feed
From: Kuba Piecuch <jpiecuch@google.com>
To: Cheng-Yang Chou <yphbchou0911@gmail.com>, Tejun Heo <tj@kernel.org>
Cc: Kuba Piecuch <jpiecuch@google.com>, <sched-ext@lists.linux.dev>,
	 David Vernet <void@manifault.com>,
	Andrea Righi <arighi@nvidia.com>,
	 Changwoo Min <changwoo@igalia.com>,
	Ching-Chun Huang <jserv@ccns.ncku.edu.tw>,
	 Chia-Ping Tsai <chia7712@gmail.com>
Subject: Re: [PATCH] tools/sched_ext: Handle pinned tasks in scx_central
Date: Wed, 15 Apr 2026 09:59:33 +0000	[thread overview]
Message-ID: <DHTN2MJP9V4Z.221YVTILI5XR6@google.com> (raw)
In-Reply-To: <3cpy5o3wdfqrmk7kuvwlvibnkesvzprjru5urhyvf66qytnjeu@jibpzykbt65k>

On Wed Apr 15, 2026 at 6:17 AM UTC, Cheng-Yang Chou wrote:
> From df62cc372cb9fab7aa9b666a6a127d8248923dd8 Mon Sep 17 00:00:00 2001
> From: Cheng-Yang Chou <yphbchou0911@gmail.com>
> Date: Mon, 13 Apr 2026 15:19:59 +0800
> Subject: [PATCH v3 sched_ext/for-7.1] tools/sched_ext: Handle migration-disabled tasks in
>  scx_central
>
> When a task calls migrate_disable(), p->cpus_ptr is not updated until
> migrate_disable_switch() runs during context switch, so dispatch_to_cpu()
> may dequeue such a task and dispatch it to a CPU it cannot run on.
>
> Extend the mismatch check in dispatch_to_cpu() to also test
> is_migration_disabled() alongside the cpumask check, so tasks in this
> window are bounced to the fallback DSQ.
>
> Suggested-by: Andrea Righi <arighi@nvidia.com>
> Suggested-by: Tejun Heo <tj@kernel.org>
> Suggested-by: Kuba Piecuch <jpiecuch@google.com>
> Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
> ---
> v3:
>  - Drop the select_cpu() shortcut, revert enqueue() to the kthread-only
>    forward-progress path, and expand the dispatch_to_cpu() mismatch
>    check to cover is_migration_disabled() (Tejun Heo)
>  - Drop kick_cpu() on mismatch (Andrea Righi)
>  - Reword commit subject and message with the fix
>
> v2:
>  - Add is_migration_disabled() check in enqueue() as p->nr_cpus_allowed
>    is not updated until migrate_disable_switch() runs during context
>    switch, which happens after ops.enqueue(). (Kuba Piecuch)
>
>  tools/sched_ext/scx_central.bpf.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tools/sched_ext/scx_central.bpf.c b/tools/sched_ext/scx_central.bpf.c
> index 4efcce099bd5..64dd60b3e922 100644
> --- a/tools/sched_ext/scx_central.bpf.c
> +++ b/tools/sched_ext/scx_central.bpf.c
> @@ -149,10 +149,14 @@ static bool dispatch_to_cpu(s32 cpu)
>  		}
>  
>  		/*
> -		 * If we can't run the task at the top, do the dumb thing and
> -		 * bounce it to the fallback dsq.
> +		 * If we can't run the task at the top for whatever reason,
> +		 * bounce it to the fallback dsq. Also check
> +		 * is_migration_disabled() explicitly as p->cpus_ptr may not
> +		 * reflect the migration-disabled state yet if
> +		 * migrate_disable_switch() hasn't run.
>  		 */
> -		if (!bpf_cpumask_test_cpu(cpu, p->cpus_ptr)) {
> +		if (!bpf_cpumask_test_cpu(cpu, p->cpus_ptr) ||
> +		    (is_migration_disabled(p) && scx_bpf_task_cpu(p) != cpu)) {
>  			__sync_fetch_and_add(&nr_mismatches, 1);
>  			scx_bpf_dsq_insert(p, FALLBACK_DSQ_ID, SCX_SLICE_INF, 0);
>  			bpf_task_release(p);

Looks good to me!

Minor email-related comment: I would prefer if patch revisions (v2, v3, ...)
were sent in separate emails with their own subject line, otherwise it may look
like I'm reviewing the v1, if you look solely at the subject line.

To be clear, the following tag applies to v3.

Reviewed-by: Kuba Piecuch <jpiecuch@google.com>


  reply	other threads:[~2026-04-15  9:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13 11:04 [PATCH] tools/sched_ext: Handle pinned tasks in scx_central Cheng-Yang Chou
2026-04-13 15:29 ` Kuba Piecuch
2026-04-14  3:45   ` Cheng-Yang Chou
2026-04-14 17:19     ` Tejun Heo
2026-04-15  6:17       ` Cheng-Yang Chou
2026-04-15  9:59         ` Kuba Piecuch [this message]
2026-04-15 10:07           ` Cheng-Yang Chou
2026-04-17 18:38         ` Tejun Heo
2026-04-14 21:01     ` Andrea Righi
2026-04-15  6:02       ` Cheng-Yang Chou

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=DHTN2MJP9V4Z.221YVTILI5XR6@google.com \
    --to=jpiecuch@google.com \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=chia7712@gmail.com \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    --cc=yphbchou0911@gmail.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