From: Andrea Righi <arighi@nvidia.com>
To: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
Vladimir Vdovin <deliran@verdict.gg>,
Gregory Price <gourry@gourry.net>,
David Dai <david.dai@linux.dev>, Emil Tsalapatis <etsal@meta.com>,
Christian Loehle <christian.loehle@arm.com>,
Balbir Singh <balbirs@nvidia.com>,
Lee Trager <ltrager@nvidia.com>,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] sched/numa: Leave the placement of a BPF-scheduled task to its scheduler
Date: Tue, 27 Oct 2026 10:30:41 +0100 [thread overview]
Message-ID: <auBvQc7-lfMMoQPm@gpd4> (raw)
In-Reply-To: <d63c6e92-a722-4061-a9a0-5e84a3313c43@amd.com>
On Tue, Oct 27, 2026 at 02:30:31PM +0530, K Prateek Nayak wrote:
> Hello Andrea,
>
> On 10/27/2026 12:13 PM, Andrea Righi wrote:
> >> On 10/27/2026 9:43 AM, Andrea Righi wrote:
> >>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> >>> index 36df9a4dde534..5064c7b707f4d 100644
> >>> --- a/kernel/sched/fair.c
> >>> +++ b/kernel/sched/fair.c
> >>> @@ -3267,8 +3267,13 @@ static bool task_numa_compare(struct task_numa_env *env,
> >>>
> >>> rcu_read_lock();
> >>> cur = rcu_dereference_all(dst_rq->curr);
> >>> + /*
> >>> + * Never pick a task under a BPF scheduler as the swap partner: its
> >>> + * placement is left to that scheduler, see numa_migrate_preferred().
> >>> + * Moving the faulting task alone to the destination is still allowed.
> >>> + */
> >>> if (cur && ((cur->flags & (PF_EXITING | PF_KTHREAD)) ||
> >>> - !cur->mm))
> >>> + !cur->mm || task_on_scx(cur)))
> >>
> >> So if you are here, it must be from:
> >>
> >> task_numa_migrate()
> >> task_numa_find_cpu()
> >> task_numa_compare()
> >>
> >> but task_on_scx(p) would skip this and it means a fair task is looking
> >> for a swap candidate when scx running in partial mode right?
> >
> > Correct.
> >
> >>
> >> At that point, it feels fair class should be well within its rights to
> >> call shots on the swap candidate even if it is an scx task.
> >>
> >> If scx has a ops.set_numa() defined, it would have accumulated hinting
> >> faults and the CPU it is running on is a wrong node anyways so the
> >> migration shouldn't be bad in grand scheme of things. If ops.set_numa()
> >> is not defined, then the scheduler doesn't care about NUMA placement
> >> and it should be okay for a fair task to acquire that CPU.
> >
> > The fair task can still acquire that CPU: with cur = NULL,
> > task_numa_compare() can still pick the destination CPU for the fair task
> > alone, and once it's there it'll preempt the sched_ext task, since fair
> > wins over scx. What the check prevents is only the other half of the
> > swap, which is fair moving the scx task to the source CPU, overriding
> > the placement decided by the BPF scheduler (the idea is that fair should
> > be able to preempt scx, but not override scx's task placement).
>
> I guess that is fair - if there is a better target, it should be
> preferred.
> > And the fact that the scx task is not on its preferred node doesn't
> > necessarily mean that it's on the wrong node: the preferred node only
> > tracks memory locality, but the BPF scheduler may have placed the task
> > there on purpose for other reasons (e.g., close to a device, which is
> > one of the use cases that motivated this work), using the preferred node
> > only as a hint.
>
> But is anyone running ext in partial mode expecting good performance
> without having moved a ton of tasks to ext beforehand?
Yeah, partial mode has always been a bit controversial, users of this
mode are mostly those that rely on fair-specific features (e.g., EAS)
but still want to experiment with sched_ext. And to make it work
effectively, the best approach is to statically partition the system, to
avoid mixing fair and ext tasks on the same CPUs.
In that scenario I think it's even more important to not let fair move
scx tasks around. Hopefully, once the ext class is able to provides all
the features that fair provides, we can stop supporting partial mode.
Thanks,
-Andrea
next prev parent reply other threads:[~2026-10-27 9:30 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 4:13 [PATCHSET v2 sched_ext/for-7.5] sched_ext: Add NUMA balancing support Andrea Righi
2026-10-27 4:13 ` [PATCH 1/6] sched/numa: Let other scheduling classes drive NUMA scanning Andrea Righi
2026-10-27 4:13 ` [PATCH 2/6] sched/numa: Leave the placement of a BPF-scheduled task to its scheduler Andrea Righi
2026-10-27 5:45 ` K Prateek Nayak
2026-10-27 6:43 ` Andrea Righi
2026-10-27 9:00 ` K Prateek Nayak
2026-10-27 9:30 ` Andrea Righi [this message]
2026-10-27 10:43 ` Peter Zijlstra
2026-10-27 11:09 ` Andrea Righi
2026-10-27 11:52 ` Peter Zijlstra
2026-10-27 4:13 ` [PATCH 3/6] sched/numa: Notify the scheduling class of preferred node changes Andrea Righi
2026-10-27 5:30 ` K Prateek Nayak
2026-10-27 6:34 ` Andrea Righi
2026-10-27 8:02 ` K Prateek Nayak
2026-10-27 4:13 ` [PATCH 4/6] sched_ext: Report preferred NUMA nodes through ops.set_numa_node() Andrea Righi
2026-10-27 10:49 ` Peter Zijlstra
2026-10-27 11:14 ` Andrea Righi
2026-10-27 4:13 ` [PATCH 5/6] sched_ext: Add a kfunc to read a task's preferred NUMA node Andrea Righi
2026-10-27 6:12 ` K Prateek Nayak
2026-10-27 6:57 ` Andrea Righi
2026-10-27 10:50 ` Peter Zijlstra
2026-10-27 11:21 ` Andrea Righi
2026-10-27 11:54 ` Peter Zijlstra
2026-10-27 4:13 ` [PATCH 6/6] selftests/sched_ext: Test preferred NUMA node notifications Andrea Righi
2026-10-27 10:52 ` [PATCHSET v2 sched_ext/for-7.5] sched_ext: Add NUMA balancing support Peter Zijlstra
2026-10-27 11:38 ` Andrea Righi
2026-10-27 11:55 ` Peter Zijlstra
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=auBvQc7-lfMMoQPm@gpd4 \
--to=arighi@nvidia.com \
--cc=balbirs@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=christian.loehle@arm.com \
--cc=david.dai@linux.dev \
--cc=deliran@verdict.gg \
--cc=dietmar.eggemann@arm.com \
--cc=etsal@meta.com \
--cc=gourry@gourry.net \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ltrager@nvidia.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=vschneid@redhat.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
all inboxes | Powered by JetHome®