All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: mgorman@techsingularity.net, vincent.guittot@linaro.org
Cc: peterz@infradead.org, linux-kernel@vger.kernel.org,
	aubrey.li@linux.intel.com, mingo@redhat.com,
	juri.lelli@redhat.com, valentin.schneider@arm.com,
	qais.yousef@arm.com, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com,
	tim.c.chen@linux.intel.com, benbjiang@gmail.com
Subject: [RFC][PATCH 2/5] sched/fair: Make select_idle_cpu() proportional to cores
Date: Mon, 14 Dec 2020 17:48:24 +0100	[thread overview]
Message-ID: <20201214170017.938791025@infradead.org> (raw)
In-Reply-To: 20201214164822.402812729@infradead.org

Instead of calculating how many (logical) CPUs to scan, compute how
many cores to scan.

This changes behaviour for anything !SMT2.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 kernel/sched/core.c |   19 ++++++++++++++-----
 kernel/sched/fair.c |   12 ++++++++++--
 2 files changed, 24 insertions(+), 7 deletions(-)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7454,11 +7454,20 @@ int sched_cpu_activate(unsigned int cpu)
 	balance_push_set(cpu, false);
 
 #ifdef CONFIG_SCHED_SMT
-	/*
-	 * When going up, increment the number of cores with SMT present.
-	 */
-	if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
-		static_branch_inc_cpuslocked(&sched_smt_present);
+	do {
+		int weight = cpumask_weight(cpu_smt_mask(cpu));
+		extern int sched_smt_weight;
+
+		if (weight > sched_smt_weight)
+			sched_smt_weight = weight;
+
+		/*
+		 * When going up, increment the number of cores with SMT present.
+		 */
+		if (weight == 2)
+			static_branch_inc_cpuslocked(&sched_smt_present);
+
+	} while (0);
 #endif
 	set_cpu_active(cpu, true);
 
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6010,6 +6010,8 @@ static inline int find_idlest_cpu(struct
 DEFINE_STATIC_KEY_FALSE(sched_smt_present);
 EXPORT_SYMBOL_GPL(sched_smt_present);
 
+int sched_smt_weight = 1;
+
 static inline void set_idle_cores(int cpu, int val)
 {
 	struct sched_domain_shared *sds;
@@ -6124,6 +6126,8 @@ static int select_idle_smt(struct task_s
 
 #else /* CONFIG_SCHED_SMT */
 
+#define sched_smt_weight	1
+
 static inline int select_idle_core(struct task_struct *p, struct sched_domain *sd, int target)
 {
 	return -1;
@@ -6136,6 +6140,8 @@ static inline int select_idle_smt(struct
 
 #endif /* CONFIG_SCHED_SMT */
 
+#define sis_min_cores		2
+
 /*
  * Scan the LLC domain for idle CPUs; this is dynamically regulated by
  * comparing the average scan cost (tracked in sd->avg_scan_cost) against the
@@ -6166,10 +6172,12 @@ static int select_idle_cpu(struct task_s
 		avg_cost = this_sd->avg_scan_cost + 1;
 
 		span_avg = sd->span_weight * avg_idle;
-		if (span_avg > 4*avg_cost)
+		if (span_avg > sis_min_cores * avg_cost)
 			nr = div_u64(span_avg, avg_cost);
 		else
-			nr = 4;
+			nr = sis_min_cores;
+
+		nr *= sched_smt_weight;
 
 		time = cpu_clock(this);
 	}



  parent reply	other threads:[~2020-12-14 17:13 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 16:48 [RFC][PATCH 0/5] select_idle_sibling() wreckage Peter Zijlstra
2020-12-14 16:48 ` [RFC][PATCH 1/5] sched/fair: Fix select_idle_cpu()s cost accounting Peter Zijlstra
2020-12-15  3:36   ` Li, Aubrey
2020-12-15  7:59     ` Peter Zijlstra
2020-12-15 11:45       ` Mel Gorman
2020-12-15 12:13       ` Li, Aubrey
2021-01-08 10:27       ` Mel Gorman
2021-01-08 13:01         ` Qais Yousef
2021-01-08 13:47           ` Mel Gorman
2021-01-08 13:41         ` Vincent Guittot
2021-01-08 14:40           ` Mel Gorman
2021-01-08 15:10             ` Vincent Guittot
2021-01-08 16:14               ` Mel Gorman
2021-01-11 14:36                 ` Vincent Guittot
2021-01-11 15:58                   ` Mel Gorman
2021-01-08 19:45               ` Peter Zijlstra
2021-01-09 14:12                 ` Mel Gorman
2021-01-11 14:39                 ` Vincent Guittot
2021-01-08 19:49               ` Peter Zijlstra
2021-01-11 14:52                 ` Vincent Guittot
2021-01-08 20:21         ` Peter Zijlstra
2021-01-09 13:59           ` Mel Gorman
2020-12-14 16:48 ` Peter Zijlstra [this message]
2020-12-23 13:31   ` [RFC][PATCH 2/5] sched/fair: Make select_idle_cpu() proportional to cores Vincent Guittot
2020-12-14 16:48 ` [RFC][PATCH 3/5] sched/fair: Remove select_idle_smt() Peter Zijlstra
2020-12-14 16:48 ` [RFC][PATCH 4/5] sched/fair: Merge select_idle_core/cpu() Peter Zijlstra
2020-12-14 16:48 ` [RFC][PATCH 5/5] sched/fair: SIS_PROP the idle core scan Peter Zijlstra
2020-12-16 12:59 ` [RFC][PATCH 0/5] select_idle_sibling() wreckage Li, Aubrey
2020-12-16 18:07   ` Vincent Guittot
2020-12-23 13:23     ` Vincent Guittot
2021-01-04 15:40       ` Mel Gorman

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=20201214170017.938791025@infradead.org \
    --to=peterz@infradead.org \
    --cc=aubrey.li@linux.intel.com \
    --cc=benbjiang@gmail.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=mingo@redhat.com \
    --cc=qais.yousef@arm.com \
    --cc=rostedt@goodmis.org \
    --cc=tim.c.chen@linux.intel.com \
    --cc=valentin.schneider@arm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.