public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Joel Fernandes <joelagnelf@nvidia.com>
Cc: Tejun Heo <tj@kernel.org>,
	linux-kernel@vger.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>
Subject: Re: [PATCH RFC] sched_ext: Choose prev_cpu if idle and cache affine without WF_SYNC
Date: Tue, 18 Mar 2025 18:46:27 +0100	[thread overview]
Message-ID: <Z9mxc4lzDTHSpLq4@gpd3> (raw)
In-Reply-To: <20250318170047.GA3467630@joelnvbox>

Hi Joel,

On Tue, Mar 18, 2025 at 01:00:47PM -0400, Joel Fernandes wrote:
...
> From: Joel Fernandes <joelagnelf@nvidia.com>
> Subject: [PATCH] sched/ext: Make default idle CPU selection better
> 
> Currently, sched_ext's default CPU selection is roughly something like
> this:
> 
> 1. Look for FULLY IDLE CORES:
>     1.1. Select prev CPU (wakee) if its CORE is fully idle.
>     1.2. Or, pick any CPU from fully idle CORE in the L3, then NUMA.
>     1.3. Or, any idle CPU from fully idle CORE usable by task.
> 2. Or, use PREV CPU if it is idle.
> 3. Or any idle CPU in the LLC, NUMA.
> 4. Or finally any CPU usable by the task.
> 
> This can end up select any idle core in the system even if that means
> jumping across NUMA nodes (basically 1.3 happens before 3.).
> 
> Improve this by moving 1.3 to after 3 (so that skipping over NUMA
> happens only later) and also add selection of fully idle target (waker)
> core before looking for fully-idle cores in the LLC/NUMA. This is similar to
> what FAIR scheduler does.
> 
> The new sequence is as follows:
> 
> 1. Look for FULLY IDLE CORES:
>     1.1. Select prev CPU (wakee) if its CORE is fully idle.
>     1.2. Select target CPU (waker) if its CORE is fully idle and shares cache
>         with prev. <- Added this.
>     1.3. Or, pick any CPU from fully idle CORE in the L3, then NUMA.
> 2. Or, use PREV CPU if it is idle.
> 3. Or any idle CPU in the LLC, NUMA.
> 4. Or, any idle CPU from fully idle CORE usable by task. <- Moved down.
> 5. Or finally any CPU usable by the task.
> 
> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
> ---
>  kernel/sched/ext.c | 26 +++++++++++++++++++-------
>  1 file changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 5a81d9a1e31f..324e442319c7 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -3558,6 +3558,16 @@ static s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu,
>  			goto cpu_found;
>  		}
>  
> +		/*
> +		 * If the waker's CPU shares cache with @prev_cpu and is part
> +		 * of a fully idle core, select it.
> +		 */
> +		if (cpus_share_cache(cpu, prev_cpu) &&
> +		    cpumask_test_cpu(cpu, idle_masks.smt) &&
> +		    test_and_clear_cpu_idle(cpu)) {

I think this is always false, because cpu is still in use by the waker and
its state hasn't been updated to idle yet.

> +			goto cpu_found;
> +		}
> +

-Andrea

  reply	other threads:[~2025-03-18 17:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17  8:28 [PATCH RFC] sched_ext: Choose prev_cpu if idle and cache affine without WF_SYNC Joel Fernandes
2025-03-17 17:08 ` Tejun Heo
2025-03-17 17:30   ` Andrea Righi
2025-03-17 17:44     ` Peter Zijlstra
2025-03-18  5:17       ` Andrea Righi
2025-03-17 22:11     ` Joel Fernandes
2025-03-18  5:09       ` Andrea Righi
2025-03-18 17:00         ` Joel Fernandes
2025-03-18 17:46           ` Andrea Righi [this message]
2025-03-18 22:37             ` Joel Fernandes
2025-03-17 22:07   ` Joel Fernandes
2025-03-17 22:25     ` Tejun Heo
2025-03-17 22:45       ` Joel Fernandes
2025-03-18  0:12   ` Libo Chen
2025-03-18  0:14     ` Tejun Heo
2025-03-17 17:20 ` Andrea Righi
2025-03-17 22:44   ` Joel Fernandes

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=Z9mxc4lzDTHSpLq4@gpd3 \
    --to=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=changwoo@igalia.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=joelagnelf@nvidia.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --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