mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
To: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>
Cc: Ricardo Neri <ricardo.neri@intel.com>,
	"Ravi V. Shankar" <ravi.v.shankar@intel.com>,
	Ben Segall <bsegall@google.com>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Len Brown <len.brown@intel.com>, Mel Gorman <mgorman@suse.de>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	Valentin Schneider <vschneid@redhat.com>,
	Ionela Voinescu <ionela.voinescu@arm.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Ricardo Neri <ricardo.neri-calderon@linux.intel.com>,
	"Tim C . Chen" <tim.c.chen@intel.com>
Subject: [PATCH v4 03/12] sched/fair: Simplify asym_packing logic for SMT cores
Date: Thu,  6 Apr 2023 13:31:39 -0700	[thread overview]
Message-ID: <20230406203148.19182-4-ricardo.neri-calderon@linux.intel.com> (raw)
In-Reply-To: <20230406203148.19182-1-ricardo.neri-calderon@linux.intel.com>

Callers of asym_smt_can_pull_tasks() check the idle state of the
destination CPU and its SMT siblings, if any. No extra checks are needed
in such function.

Since SMT cores divide capacity among its siblings, priorities only really
make sense if only one sibling is active. This is true for SMT2, SMT4,
SMT8, etc. Do not use asym_packing load balance for this case. Instead,
let find_busiest_group() handle imbalances.

When balancing non-SMT cores or at higher scheduling domains (e.g.,
between MC scheduling groups), continue using priorities.

Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Ionela Voinescu <ionela.voinescu@arm.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim C. Chen <tim.c.chen@intel.com>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Len Brown <len.brown@intel.com>
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
Changes since v3:
 * Dropped checks for a destination SMT core.
 * Limited the check of a single busy CPU to SMT cores. This fixes a bug
   when balancing between MC scheduling groups of different priority.

Changes since v2:
 * Updated documentation of the function to reflect the new behavior.
   (Dietmar)

Changes since v1:
 * Reworded commit message and inline comments for clarity.
 * Stated that this changeset does not impact SMT4 or SMT8.
---
 kernel/sched/fair.c | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ec7ddbfd1136..b6bbe0300635 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9313,12 +9313,9 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)
  * the SMT siblings of @sg are busy. If only one CPU in @sg is busy, pull tasks
  * only if @dst_cpu has higher priority.
  *
- * If both @dst_cpu and @sg have SMT siblings, and @sg has exactly one more
- * busy CPU than @sds::local, let @dst_cpu pull tasks if it has higher priority.
- * Bigger imbalances in the number of busy CPUs will be dealt with in
- * update_sd_pick_busiest().
- *
- * If @sg does not have SMT siblings, only pull tasks if @sg has lower priority.
+ * When dealing with SMT cores, only use priorities if the SMT core has exactly
+ * one busy sibling. find_busiest_group() will handle bigger imbalances in the
+ * number of busy CPUs.
  *
  * Return: true if @dst_cpu can pull tasks, false otherwise.
  */
@@ -9327,12 +9324,10 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds,
 				    struct sched_group *sg)
 {
 #ifdef CONFIG_SCHED_SMT
-	bool local_is_smt, sg_is_smt;
+	bool local_is_smt;
 	int sg_busy_cpus;
 
 	local_is_smt = sds->local->flags & SD_SHARE_CPUCAPACITY;
-	sg_is_smt = sg->flags & SD_SHARE_CPUCAPACITY;
-
 	sg_busy_cpus = sgs->group_weight - sgs->idle_cpus;
 
 	if (!local_is_smt) {
@@ -9353,21 +9348,17 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds,
 		return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu);
 	}
 
-	/* @dst_cpu has SMT siblings. */
-
-	if (sg_is_smt) {
-		int local_busy_cpus = sds->local->group_weight -
-				      sds->local_stat.idle_cpus;
-		int busy_cpus_delta = sg_busy_cpus - local_busy_cpus;
-
-		if (busy_cpus_delta == 1)
-			return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu);
-
+	/*
+	 * If we are here @dst_cpu has SMT siblings and are also idle.
+	 *
+	 * CPU priorities does not make sense for SMT cores with more than one
+	 * busy sibling.
+	 */
+	if (group->flags & SD_SHARE_CPUCAPACITY && sg_busy_cpus != 1)
 		return false;
-	}
 
-	/* If we are here @dst_cpu has SMT siblings and are also idle. */
 	return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu);
+
 #else
 	/* Always return false so that callers deal with non-SMT cases. */
 	return false;
-- 
2.25.1


  parent reply	other threads:[~2023-04-06 20:21 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06 20:31 [PATCH v4 00/12] sched: Avoid unnecessary migrations within SMT domains Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 01/12] sched/fair: Move is_core_idle() out of CONFIG_NUMA Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 02/12] sched/fair: Only do asym_packing load balancing from fully idle SMT cores Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` Ricardo Neri [this message]
2023-05-10 13:49   ` [tip: sched/core] sched/fair: Simplify asym_packing logic for " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 04/12] sched/fair: Let low-priority cores help high-priority busy " Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 05/12] sched/fair: Keep a fully_busy SMT sched group as busiest Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-05-12 18:41   ` [PATCH v4 05/12] " Shrikanth Hegde
2023-05-19  0:01     ` Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 06/12] sched/fair: Use the busiest group to set prefer_sibling Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 07/12] sched/fair: Do not even the number of busy CPUs via asym_packing Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 08/12] sched/topology: Check SDF_SHARED_CHILD in highest_flag_domain() Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 09/12] sched/topology: Remove SHARED_CHILD from ASYM_PACKING Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 10/12] x86/sched: Remove SD_ASYM_PACKING from the SMT domain flags Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 11/12] x86/sched/itmt: Give all SMT siblings of a core the same priority Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Ricardo Neri
2023-04-06 20:31 ` [PATCH v4 12/12] x86/sched: Add the SD_ASYM_PACKING flag to the die domain of hybrid processors Ricardo Neri
2023-05-10 13:49   ` [tip: sched/core] " tip-bot2 for Chen Yu
2023-04-29 15:32 ` [PATCH v4 00/12] sched: Avoid unnecessary migrations within SMT domains Peter Zijlstra
2023-05-01 18:30   ` Tim Chen
2023-05-02  1:42   ` Ricardo Neri
2023-05-02  1:52     ` Steven Rostedt
2023-05-12 18:23   ` Shrikanth Hegde
2023-05-19  0:03     ` Ricardo Neri
2023-05-22  7:55       ` Shrikanth Hegde

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=20230406203148.19182-4-ricardo.neri-calderon@linux.intel.com \
    --to=ricardo.neri-calderon@linux.intel.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=ionela.voinescu@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=ravi.v.shankar@intel.com \
    --cc=ricardo.neri@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=tim.c.chen@intel.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=x86@kernel.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®