mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qais Yousef <qyousef@layalina.io>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
	linux-kernel@vger.kernel.org, pierre.gondois@arm.com,
	kprateek.nayak@amd.com, hongyan.xia2@arm.com,
	christian.loehle@arm.com, luis.machado@arm.com
Subject: Re: [RFC PATCH 6/6 v8] sched/fair: Add EAS and idle cpu push trigger
Date: Fri, 6 Feb 2026 18:30:17 +0000	[thread overview]
Message-ID: <20260206183017.ovewgke6r4cvt5pf@airbuntu> (raw)
In-Reply-To: <20251202181242.1536213-7-vincent.guittot@linaro.org>

On 12/02/25 19:12, Vincent Guittot wrote:
> EAS is based on wakeup events to efficiently place tasks on the system, but
> there are cases where a task doesn't have wakeup events anymore or at a far
> too low pace. For such cases, we check if it's worth pushing the task on
> another CPUs instead of putting it back in the enqueued list.
> 
> Wake up events remain the main way to migrate tasks but we now detect
> situation where a task is stuck on a CPU by checking that its utilization
> is larger than the max available compute capacity (max cpu capacity or
> uclamp max setting).
> 
> When the system becomes overutilized and some CPUs are idle, we try to
> push tasks instead of waiting periodic load balance.

I am fine with these wording. But I think enable lb based on power is a very
good description too. Basically we don't have the concept on down migration for
HMP systems to help save power for tasks that are hinted are fine with running
at lower performance level via uclamp_max.

> 
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>  kernel/sched/fair.c     | 64 +++++++++++++++++++++++++++++++++++++++++
>  kernel/sched/topology.c |  2 ++
>  2 files changed, 66 insertions(+)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 0c0c675f39cf..e9e1d0c05805 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8500,8 +8500,72 @@ static inline bool sched_push_task_enabled(void)
>  	return static_branch_unlikely(&sched_push_task);
>  }
>  
> +static inline bool task_stuck_on_cpu(struct task_struct *p, int cpu)
> +{
> +	unsigned long max_capa, util;
> +
> +	max_capa = min(get_actual_cpu_capacity(cpu),
> +		       uclamp_eff_value(p, UCLAMP_MAX));

I think we check if uclamp_max is == SCHED_CAPACITY_SCALE. By definition these
are not stuck. I found without this condition we can trigger this a lot
unnecessarily.

> +	util = max(task_util_est(p), task_runnable(p));

We must take the min(util, SCHED_CAPACITY_SCALE) here since runnable can get
too large making the condition above true even if you are on the biggest
capacity cpu.

> +
> +	/*
> +	 * Return true only if the task might not sleep/wakeup because of a low
> +	 * compute capacity. Tasks, which wake up regularly, will be handled by
> +	 * feec().
> +	 */
> +	return (util > max_capa);
> +}
> +
> +static inline bool sched_energy_push_task(struct task_struct *p, struct rq *rq)
> +{
> +	if (!sched_energy_enabled())
> +		return false;
> +
> +	if (is_rd_overutilized(rq->rd))
> +		return false;
> +
> +	if (task_stuck_on_cpu(p, cpu_of(rq)))
> +		return true;
> +
> +	if (!task_fits_cpu(p, cpu_of(rq)))
> +		return true;
> +
> +	return false;
> +}
> +
> +static inline bool sched_idle_push_task(struct task_struct *p, struct rq *rq)
> +{
> +	if (rq->nr_running == 1)
> +		return false;
> +
> +	if (!is_rd_overutilized(rq->rd))
> +		return false;
> +
> +	/* If there are idle cpus in the llc then try to push the task on it */
> +	if (test_idle_cores(cpu_of(rq)))
> +		return true;
> +
> +	return false;
> +}
> +
> +
>  static bool fair_push_task(struct rq *rq, struct task_struct *p)
>  {
> +	if (!task_on_rq_queued(p))
> +		return false;
> +
> +	if (p->se.sched_delayed)
> +		return false;
> +
> +	if (p->nr_cpus_allowed == 1)
> +		return false;
> +
> +	if (sched_energy_push_task(p, rq))
> +		return true;
> +
> +	if (sched_idle_push_task(p, rq))
> +		return true;

In my testing (of earlier version of the patch) I found adding a new
is_rq_overloaded(rq) test which simply checks if rq->nr_running > 1 is helpful
to make the whole regular lb required at all (get rid of overutilized). Still
testing it though, something to consider now or later. I don't mind.

> +
>  	return false;
>  }
>  
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index cf643a5ddedd..00abd01acb84 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -391,10 +391,12 @@ static void sched_energy_set(bool has_eas)
>  		if (sched_debug())
>  			pr_info("%s: stopping EAS\n", __func__);
>  		static_branch_disable_cpuslocked(&sched_energy_present);
> +		static_branch_dec_cpuslocked(&sched_push_task);
>  	} else if (has_eas && !static_branch_unlikely(&sched_energy_present)) {
>  		if (sched_debug())
>  			pr_info("%s: starting EAS\n", __func__);
>  		static_branch_enable_cpuslocked(&sched_energy_present);
> +		static_branch_inc_cpuslocked(&sched_push_task);
>  	}
>  }
>  
> -- 
> 2.43.0
> 

  reply	other threads:[~2026-02-06 18:30 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-02 18:12 [PATCH 0/6 v8] sched/fair: Add push task mechanism and handle more EAS cases Vincent Guittot
2025-12-02 18:12 ` [PATCH 1/6 v8] sched/fair: Filter false overloaded_group case for EAS Vincent Guittot
2025-12-02 18:12 ` [PATCH 2/6 v8] sched/fair: Update overutilized detection Vincent Guittot
2026-02-06 17:42   ` Qais Yousef
2025-12-02 18:12 ` [PATCH 3/6 v8] sched/fair: Prepare select_task_rq_fair() to be called for new cases Vincent Guittot
2025-12-07 13:23   ` Shrikanth Hegde
2026-02-09 13:21     ` Vincent Guittot
2026-02-06 18:03   ` Qais Yousef
2026-02-09 13:21     ` Vincent Guittot
2025-12-02 18:12 ` [PATCH 4/6 v8] sched/fair: Add push task mechanism for fair Vincent Guittot
2025-12-04 10:46   ` Peter Zijlstra
2025-12-04 14:32     ` Vincent Guittot
2025-12-04 11:29   ` Peter Zijlstra
2025-12-04 14:34     ` Vincent Guittot
2025-12-05  8:59       ` Peter Zijlstra
2025-12-05 12:49         ` K Prateek Nayak
2025-12-05 12:56           ` Peter Zijlstra
2025-12-05 13:05             ` K Prateek Nayak
2025-12-05 13:36           ` Vincent Guittot
2025-12-06  3:08             ` K Prateek Nayak
2025-12-05 13:26         ` Vincent Guittot
2025-12-07 12:13   ` Shrikanth Hegde
2026-02-09 13:17     ` Vincent Guittot
2025-12-10 14:01   ` Dietmar Eggemann
2026-02-09 13:17     ` Vincent Guittot
2026-02-06 18:21   ` Qais Yousef
2026-02-09 13:18     ` Vincent Guittot
2025-12-02 18:12 ` [RFC PATCH 5/6 v8] sched/fair: Enable idle core tracking for !SMT Vincent Guittot
2025-12-05 15:52   ` Christian Loehle
2025-12-06  2:11     ` Chen, Yu C
2025-12-06 10:18       ` Vincent Guittot
2025-12-06 10:09     ` Vincent Guittot
2025-12-08 18:43   ` Christian Loehle
2025-12-02 18:12 ` [RFC PATCH 6/6 v8] sched/fair: Add EAS and idle cpu push trigger Vincent Guittot
2026-02-06 18:30   ` Qais Yousef [this message]
2026-02-09 13:20     ` Vincent Guittot
2026-02-11  0:59       ` Qais Yousef
2025-12-03 14:06 ` [PATCH 0/6 v8] sched/fair: Add push task mechanism and handle more EAS cases Christian Loehle
2025-12-10 13:30 ` Dietmar Eggemann
2026-02-06 18:32 ` Qais Yousef
2026-02-09 13:20   ` Vincent Guittot
2026-02-26 17:34 ` Pierre Gondois
2026-03-10  4:16   ` Qais Yousef
2026-03-10 10:27     ` Pierre Gondois
2026-03-10 15:11       ` Qais Yousef
2026-03-10 16:59         ` Pierre Gondois
2026-03-12  8:19           ` Vincent Guittot

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=20260206183017.ovewgke6r4cvt5pf@airbuntu \
    --to=qyousef@layalina.io \
    --cc=bsegall@google.com \
    --cc=christian.loehle@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=hongyan.xia2@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luis.machado@arm.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pierre.gondois@arm.com \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --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®