mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Xuewen Yan <xuewen.yan@unisoc.com>,
	mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org
Cc: rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	vschneid@redhat.com, vdonnefort@google.com, ke.wang@unisoc.com,
	xuewen.yan94@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] sched/feec: Simplify the traversal of pd'cpus
Date: Thu, 14 Aug 2025 09:46:08 +0100	[thread overview]
Message-ID: <cf7847e4-78a6-4286-baba-60ace0c3d507@arm.com> (raw)
In-Reply-To: <20250812093339.8895-1-xuewen.yan@unisoc.com>



On 12.08.25 10:33, Xuewen Yan wrote:
> Now we use for_each_cpu() to traversal all pd's cpus,
> it is in order to compute the pd_cap. This approach may
> result in some unnecessary judgments.
> We can simply calculate pd_cap as follows:
> 
> pd_cap = cpu_actual_cap * cpumask_weight(pd_cpus);
> 
> Then we can AND pd'scpus, sd's cpus and task's cpus_ptr
> before traversing, which can save some unnecessary judgment.
> 
> Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
> ---
>  kernel/sched/fair.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index b173a059315c..e47fe94d6889 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8330,18 +8330,12 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)

Just a thought ...

for (; pd; pd = pd->next)

  cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);    <-- (1)
  cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask);


  if (cpumask_empty(cpus))
    continue;                                               <-- (2)

Can you not mask cpus already early in the pd loop (1) and then profit
from (2) in these rare cases? IIRC, the sd only plays a role here in
exclusive cpusets scenarios which I don't thing anybody deploys with EAS?

>  		cpu_actual_cap = get_actual_cpu_capacity(cpu);
>  
>  		eenv.cpu_cap = cpu_actual_cap;
> -		eenv.pd_cap = 0;
> +		eenv.pd_cap = cpu_actual_cap * cpumask_weight(cpus);
>  
> -		for_each_cpu(cpu, cpus) {
> -			struct rq *rq = cpu_rq(cpu);
> -
> -			eenv.pd_cap += cpu_actual_cap;
> -
> -			if (!cpumask_test_cpu(cpu, sched_domain_span(sd)))
> -				continue;
> +		cpumask_and(cpus, cpus, sched_domain_span(sd));
>  
> -			if (!cpumask_test_cpu(cpu, p->cpus_ptr))
> -				continue;
> +		for_each_cpu_and(cpu, cpus, p->cpus_ptr) {
> +			struct rq *rq = cpu_rq(cpu);
>  
>  			util = cpu_util(cpu, p, cpu, 0);
>  			cpu_cap = capacity_of(cpu);


  parent reply	other threads:[~2025-08-14  8:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-12  9:33 Xuewen Yan
2025-08-12 21:29 ` Christian Loehle
2025-08-14  8:46 ` Dietmar Eggemann [this message]
2025-08-14  9:52   ` Xuewen Yan
2025-08-15 13:01     ` Dietmar Eggemann
2025-08-18 11:05       ` Xuewen Yan
2025-08-18 15:24         ` Dietmar Eggemann
2025-08-19  2:02           ` Xuewen Yan
2025-08-19 14:01             ` Dietmar Eggemann
2025-08-20 11:09               ` Xuewen Yan

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=cf7847e4-78a6-4286-baba-60ace0c3d507@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=bsegall@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=ke.wang@unisoc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vdonnefort@google.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=xuewen.yan94@gmail.com \
    --cc=xuewen.yan@unisoc.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®