The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Phil Auld <pauld@redhat.com>
To: shubhang@os.amperecomputing.com
Cc: 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>,
	Shubhang Kaushik <sh@gentwo.org>,
	Shijie Huang <Shijie.Huang@amperecomputing.com>,
	Frank Wang <zwang@amperecomputing.com>,
	Christopher Lameter <cl@gentwo.org>,
	Adam Li <adam.li@amperecomputing.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/fair: Prefer cache-hot prev_cpu for wakeup
Date: Mon, 20 Oct 2025 08:36:48 -0400	[thread overview]
Message-ID: <20251020123648.GA851830@pauld.westford.csb> (raw)
In-Reply-To: <20251017-b4-sched-cfs-refactor-propagate-v1-1-1eb0dc5b19b3@os.amperecomputing.com>

Hi,

On Fri, Oct 17, 2025 at 04:00:44PM -0700 Shubhang Kaushik via B4 Relay wrote:
> From: Shubhang Kaushik <shubhang@os.amperecomputing.com>
> 
> Modify the wakeup path in `select_task_rq_fair()` to prioritize cache
> locality for waking tasks. The previous fast path always attempted to
> find an idle sibling, even if the task's prev CPU was not truly busy.
> 
> The original problem was that under some circumstances, this could lead
> to unnecessary task migrations away from a cache-hot core, even when
> the task's prev CPU was a suitable candidate. The scheduler's internal
> mechanism `cpu_overutilized()` provide an evaluation of CPU load.
> 
> To address this, the wakeup heuristic is updated to check the status of
> the task's `prev_cpu` first:
> - If the `prev_cpu` is  not overutilized (as determined by
>   `cpu_overutilized()`, via PELT), the task is woken up on
>   its previous CPU. This leverages cache locality and avoids
>   a potentially unnecessary migration.
> - If the `prev_cpu` is considered busy or overutilized, the scheduler
>   falls back to the existing behavior of searching for an idle sibling.
> 
> Signed-off-by: Shubhang Kaushik <shubhang@os.amperecomputing.com>
> ---
> This patch optimizes the scheduler's wakeup path to prioritize cache 
> locality by keeping a task on its previous CPU if it is not overutilized,
> falling back to a sibling search only when necessary.
> ---
>  kernel/sched/fair.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index bc0b7ce8a65d6bbe616953f530f7a02bb619537c..bb0d28d7d9872642cb5a4076caeb3ac9d8fe7bcd 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8618,7 +8618,16 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
>  		new_cpu = sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag);
>  	} else if (wake_flags & WF_TTWU) { /* XXX always ? */
>  		/* Fast path */
> -		new_cpu = select_idle_sibling(p, prev_cpu, new_cpu);
> +
> +		/*
> +		 * Avoid wakeup on an overutilized CPU.
> +		 * If the previous CPU is not overloaded, retain the same for cache locality.
> +		 * Otherwise, search for an idle sibling.
> +		 */
> +		if (!cpu_overutilized(prev_cpu))
> +			new_cpu = prev_cpu;
> +		else
> +			new_cpu = select_idle_sibling(p, prev_cpu, new_cpu);

Won't this be checking if the cpu is overusitilzed without the wakee. It
might well be overutilized once the wakee is placed there.

I suspect this will hurt some workloads. Do you have numbers to share?


Cheers,
Phil


>  	}
>  	rcu_read_unlock();
>  
> 
> ---
> base-commit: 9b332cece987ee1790b2ed4c989e28162fa47860
> change-id: 20251017-b4-sched-cfs-refactor-propagate-2c4a820998a4
> 
> Best regards,
> -- 
> Shubhang Kaushik <shubhang@os.amperecomputing.com>
> 
> 
> 

-- 


  reply	other threads:[~2025-10-20 12:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 23:00 [PATCH] sched/fair: Prefer cache-hot prev_cpu for wakeup Shubhang Kaushik via B4 Relay
2025-10-20 12:36 ` Phil Auld [this message]
2025-10-22 16:45   ` Shubhang Kaushik OS
2025-10-22 16:54 ` Vincent Guittot
2025-10-28  7:29 ` kernel test robot
2025-10-29  4:17 ` kernel test robot
2025-10-30 10:14 ` Dietmar Eggemann
2025-10-30 16:35   ` Shubhang
2025-10-31 11:32     ` Dietmar Eggemann
2025-10-31 16:45       ` Shubhang Kaushik OS

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=20251020123648.GA851830@pauld.westford.csb \
    --to=pauld@redhat.com \
    --cc=Shijie.Huang@amperecomputing.com \
    --cc=adam.li@amperecomputing.com \
    --cc=bsegall@google.com \
    --cc=cl@gentwo.org \
    --cc=dietmar.eggemann@arm.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=sh@gentwo.org \
    --cc=shubhang@os.amperecomputing.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=zwang@amperecomputing.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