mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] sched/fair: Improve the for loop in select_idle_core()
Date: Mon, 11 Feb 2019 10:30:14 +0100	[thread overview]
Message-ID: <20190211093014.GS32511@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <6b165676325a47d67e667582a7b78da85c5c118a.1549536337.git.viresh.kumar@linaro.org>

On Thu, Feb 07, 2019 at 04:16:06PM +0530, Viresh Kumar wrote:
> @@ -6081,10 +6082,14 @@ static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int
>  	for_each_cpu_wrap(core, cpus, target) {
>  		bool idle = true;
>  
> -		for_each_cpu(cpu, cpu_smt_mask(core)) {
> -			cpumask_clear_cpu(cpu, cpus);
> -			if (!available_idle_cpu(cpu))
> +		smt = cpu_smt_mask(core);
> +		cpumask_andnot(cpus, cpus, smt);

So where the previous code was like 1-2 stores, you just added 16.

(assuming 64bit and NR_CPUS=1024)

And we still do the iteration anyway:

> +		for_each_cpu(cpu, smt) {
> +			if (!available_idle_cpu(cpu)) {
>  				idle = false;
> +				break;
> +			}
>  		}

An actual improvement would've been:

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 38d4669aa2ef..2d352d6d15c7 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6082,7 +6082,7 @@ static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int
 		bool idle = true;
 
 		for_each_cpu(cpu, cpu_smt_mask(core)) {
-			cpumask_clear_cpu(cpu, cpus);
+			__cpumask_clear_cpu(cpu, cpus);
 			if (!available_idle_cpu(cpu))
 				idle = false;
 		}

  reply	other threads:[~2019-02-11  9:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07 10:46 [PATCH 1/2] sched/fair: Don't pass sd to select_idle_smt() Viresh Kumar
2019-02-07 10:46 ` [PATCH 2/2] sched/fair: Improve the for loop in select_idle_core() Viresh Kumar
2019-02-11  9:30   ` Peter Zijlstra [this message]
2019-02-11 10:26     ` Viresh Kumar
2019-02-11 10:44       ` Peter Zijlstra
2019-02-11 10:54 ` [tip:sched/core] sched/fair: Remove unused 'sd' parameter from select_idle_smt() tip-bot for Viresh Kumar

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=20190211093014.GS32511@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@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®