public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tao Zhou <tao.zhou@linux.dev>
To: linux-kernel@vger.kernel.org, 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>,
	Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Tao Zhou <tao.zhou@linux.dev>
Subject: [PATCH] sched/fair: Check idle_cpu in select_idle_core/cpu()
Date: Sun, 10 Oct 2021 02:09:41 +0800	[thread overview]
Message-ID: <20211009180941.20458-1-tao.zhou@linux.dev> (raw)

In select_idle_core(), the idle core returned may have no cpu
allowed. I think the idle core returned for the task is the one
that can be allowed to run. I insist on this semantics.

In select_idle_cpu(), if select_idle_core() can not find the
idle core, one reason is that the core is not allowed for the
task, but the core itself is idle from the point of
sds->has_idle_cores. I insist on this semantics.

No others, just two additional check.
---
 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f6a05d9b5443..a44aca5095d3 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6213,7 +6213,7 @@ static int select_idle_core(struct task_struct *p, int core, struct cpumask *cpu
 			*idle_cpu = cpu;
 	}
 
-	if (idle)
+	if (idle && *idle_cpu != -1)
 		return core;
 
 	cpumask_andnot(cpus, cpus, cpu_smt_mask(core));
@@ -6324,7 +6324,7 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool
 		}
 	}
 
-	if (has_idle_core)
+	if (has_idle_core && *idle_cpu != -1)
 		set_idle_cores(target, false);
 
 	if (sched_feat(SIS_PROP) && !has_idle_core) {
-- 
2.32.0


             reply	other threads:[~2021-10-09 18:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-09 18:09 Tao Zhou [this message]
2021-10-09 22:50 ` [PATCH] sched/fair: Check idle_cpu in select_idle_core/cpu() Peter Zijlstra
2021-10-10  9:39   ` Tao Zhou
2021-10-10 12:19     ` Barry Song
2021-10-10 14:27       ` Tao Zhou
2021-10-10 20:24         ` Barry Song

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=20211009180941.20458-1-tao.zhou@linux.dev \
    --to=tao.zhou@linux.dev \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --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=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