mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: peterz@infradead.org, linux-kernel@vger.kernel.org,
	pierre.gondois@arm.com, kprateek.nayak@amd.com,
	qyousef@layalina.io, christian.loehle@arm.com,
	luis.machado@arm.com
Subject: Re: [RFC PATCH 6/6 v7] sched/fair: Add EAS and idle cpu push trigger
Date: Tue,  2 Dec 2025 17:44:52 +0800	[thread overview]
Message-ID: <20251202094454.9608-1-hdanton@sina.com> (raw)
In-Reply-To: <20251201091308.761711-7-vincent.guittot@linaro.org>

On Mon,  1 Dec 2025 10:13:08 +0100 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 worht pushing hte 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.
> 
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>  kernel/sched/fair.c     | 65 +++++++++++++++++++++++++++++++++++++++++
>  kernel/sched/topology.c |  3 ++
>  2 files changed, 68 insertions(+)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 9af8d0a61856..e9e1d0c05805 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6990,6 +6990,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
>  }
>  
>  static void fair_remove_pushable_task(struct rq *rq, struct task_struct *p);
> +
>  /*
>   * Basically dequeue_task_fair(), except it can deal with dequeue_entity()
>   * failing half-way through and resume the dequeue later.
> @@ -8499,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));
> +	util = max(task_util_est(p), task_runnable(p));
> +
> +	/*
> +	 * 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;

Task is queued on rq.
> +
> +	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 task is stuck on CPU, it could not be on rq. Weird.
> +
> +	if (sched_idle_push_task(p, rq))
> +		return true;
> +
>  	return false;
>  }
>  
More, in the tick path,

task_tick_fair
  check_pushable_task
    fair_push_task
      task_on_rq_queued // this check makes no sense

  parent reply	other threads:[~2025-12-02  9:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01  9:13 [PATCH 0/6 v7] sched/fair: Add push task mecansim and hadle more EAS cases Vincent Guittot
2025-12-01  9:13 ` [PATCH 1/6 v7] sched/fair: Filter false overloaded_group case for EAS Vincent Guittot
2025-12-01  9:13 ` [PATCH 2/6 v7] sched/fair: Update overutilized detection Vincent Guittot
2025-12-01  9:13 ` [PATCH 3/6 v7] sched/fair: Prepare select_task_rq_fair() to be called for new cases Vincent Guittot
2025-12-01  9:13 ` [PATCH 4/6 v7] sched/fair: Add push task mechanism for fair Vincent Guittot
2025-12-01  9:13 ` [RFC PATCH 5/6 v7] sched/fair: Enable idle core tracking for !SMT Vincent Guittot
2025-12-01  9:13 ` [RFC PATCH 6/6 v7] sched/fair: Add EAS and idle cpu push trigger Vincent Guittot
2025-12-01 13:53   ` Christian Loehle
2025-12-01 17:49     ` Vincent Guittot
2025-12-01 19:33       ` Vincent Guittot
2025-12-02  9:44   ` Hillf Danton [this message]
2025-12-02 13:01     ` Vincent Guittot
2025-12-03  9:00       ` Hillf Danton
2025-12-03 13:32         ` Vincent Guittot
2025-12-04  6:59           ` Hillf Danton
2025-12-05 15:02             ` Vincent Guittot
2025-12-06 10:31               ` Hillf Danton
2025-12-01 13:31 ` [PATCH 0/6 v7] sched/fair: Add push task mecansim and hadle more EAS cases Christian Loehle
2025-12-01 13:57   ` Christian Loehle
2025-12-01 17:48     ` Vincent Guittot
2025-12-01 17:48   ` Vincent Guittot
2025-12-01 22:02 ` David Laight
2025-12-02 13:24   ` 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=20251202094454.9608-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=christian.loehle@arm.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luis.machado@arm.com \
    --cc=peterz@infradead.org \
    --cc=pierre.gondois@arm.com \
    --cc=qyousef@layalina.io \
    --cc=vincent.guittot@linaro.org \
    /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®