This is v5 the series. v1, v2, v3, and v4 patches and test results can be
found in [1], [2], [3], and [4], respectively.
=== Problem statement ===
++ Load balancing ++
When using asymmetric packing, there exists CPU topologies with three
priority levels in which only a subset of the physical cores support SMT.
An instance of such topology is Intel Alderlake, a hybrid processor with
a mixture of Intel Core (with support for SMT) and Intel Atom CPUs.
On Alderlake, it is almost always beneficial to spread work by picking
first the Core CPUs, then the Atoms and at last the SMT siblings.
The current load balancer, however, does not behave as described when using
ASYM_PACKING. Instead, the load balancer will choose higher-priority CPUs
(an Intel Core) over medium-priority CPUs (an Intel Atom), and subsequently
overflow the load to a low priority SMT sibling CPU. This leaves medium-
priority CPUs idle while low-priority CPUs are busy.
This patchset fixes this behavior by also checking the idle state of the
SMT siblings of both the CPU doing the load balance and the busiest
candidate group when deciding whether the destination CPUs can pull tasks
from the busiest CPU.
++ Rework ASYM_PACKING priorities with ITMT ++
We also reworked the priority computation of the SMT siblings to ensure
that higher-numbered SMT siblings are always low priority. The current
computation may lead to situations in which in some processors those
higher-numbered SMT siblings have the same priority as the Intel Atom
CPUs.
=== Testing ===
I ran a few benchmarks with and without this version of the patchset on
an Intel Alderlake system with 8 Intel Core (with SMT) and 8 Intel
Atom CPUs.
The baseline for the results is an unmodified v5.14 kernel. Results
show a comparative percentage of improvement (positive) or degradation
(negative). Each test case is repeated eight times, and the standard
deviation among repetitions is also documented.
Table 1 shows the results when using hardware-controlled performance
performance states (HWP), a common use case. The impact of the patches
is overall positive with a few test cases showing slight degradation.
hackbench is especially difficult to assess it shows a high degree of
variability.
Thanks and BR,
Ricardo
ITMT: Intel Turbo Boost Max Technology 3.0
========
Changes since v4:
* Use sg_lb_stats::sum_nr_running the idle state of a scheduling group.
(patch 6, Vincent, Peter)
* Do not even idle CPUs in asym_smt_can_pull_tasks(). (patch 6, Vincent)
* Unchanged patches: 1, 2, 3, 4, 5.
Changes since v3:
* Reworked the ITMT priority computation to further reduce the priority
of SMT siblings (patch 1).
* Clear scheduling group flags when a child scheduling level
degenerates (patch 2).
* Removed arch-specific hooks (patch 6, PeterZ)
* Removed redundant checks for the local group. (patch 5, Dietmar)
* Removed redundant check for local idle CPUs and local group
utilization. (patch 6, Joel)
* Reworded commit messages of patches 2, 3, 5, and 6 for clarity.
(Len, PeterZ)
* Added Joel's Reviewed-by tag.
* Unchanged patches: 4
Changes since v2:
* Removed arch_sched_asym_prefer_early() and re-evaluation of the
candidate busiest group in update_sd_pick_busiest(). (PeterZ)
* Introduced sched_group::flags to reflect the properties of CPUs
in the scheduling group. This helps to identify scheduling groups
whose CPUs are SMT siblings. (PeterZ)
* Modified update_sg_lb_stats() to get statistics of the scheduling
domain as an argument. This provides it with the statistics of the
local domain. (PeterZ)
* Introduced sched_asym() to decide if a busiest candidate group can
be marked for asymmetric packing.
* Reworded patch 1 for clarity. (PeterZ)
Changes since v1:
* Don't bailout in update_sd_pick_busiest() if dst_cpu cannot pull
tasks. Instead, reclassify the candidate busiest group, as it
may still be selected. (PeterZ)
* Avoid an expensive and unnecessary call to cpumask_weight() when
determining if a sched_group is comprised of SMT siblings.
(PeterZ).
* Updated test results using the v2 patches.
======== Table 1. Test results of patches with HWP ========
=======================================================================
hackbench
=========
case load baseline(std%) compare%( std%)
process-pipe group-1 1.00 ( 18.21) +4.95 ( 11.79)
process-pipe group-2 1.00 ( 10.09) -2.41 ( 14.12)
process-pipe group-4 1.00 ( 29.09) -4.04 ( 22.58)
process-pipe group-8 1.00 ( 6.76) -1.61 ( 8.13)
process-pipe group-12 1.00 ( 12.39) +3.90 ( 7.59)
process-pipe group-16 1.00 ( 5.78) -3.65 ( 7.90)
process-pipe group-20 1.00 ( 4.71) -2.70 ( 5.17)
process-pipe group-24 1.00 ( 9.44) -11.20 ( 10.22)
process-pipe group-32 1.00 ( 9.29) -0.84 ( 7.04)
process-pipe group-48 1.00 ( 7.47) +0.66 ( 5.90)
process-sockets group-1 1.00 ( 13.53) -9.60 ( 7.91)
process-sockets group-2 1.00 ( 21.92) +7.48 ( 9.23)
process-sockets group-4 1.00 ( 14.59) +9.43 ( 11.85)
process-sockets group-8 1.00 ( 9.43) +4.67 ( 6.23)
process-sockets group-12 1.00 ( 12.80) +7.44 ( 12.62)
process-sockets group-16 1.00 ( 8.47) +2.12 ( 9.45)
process-sockets group-20 1.00 ( 5.86) +2.41 ( 3.20)
process-sockets group-24 1.00 ( 4.47) +4.56 ( 3.14)
process-sockets group-32 1.00 ( 4.40) +5.41 ( 3.11)
process-sockets group-48 1.00 ( 16.60) +14.69 ( 3.08)
threads-pipe group-1 1.00 ( 3.49) -0.91 ( 3.37)
threads-pipe group-2 1.00 ( 17.48) +7.36 ( 8.81)
threads-pipe group-4 1.00 ( 17.58) -2.36 ( 18.80)
threads-pipe group-8 1.00 ( 9.58) -1.26 ( 6.24)
threads-pipe group-12 1.00 ( 6.49) +2.34 ( 4.37)
threads-pipe group-16 1.00 ( 15.49) -6.13 ( 14.84)
threads-pipe group-20 1.00 ( 2.76) -7.87 ( 7.93)
threads-pipe group-24 1.00 ( 13.80) +3.46 ( 11.91)
threads-pipe group-32 1.00 ( 8.12) -2.91 ( 8.20)
threads-pipe group-48 1.00 ( 5.79) -3.95 ( 5.44)
threads-sockets group-1 1.00 ( 11.24) -4.56 ( 10.01)
threads-sockets group-2 1.00 ( 6.81) +0.60 ( 4.95)
threads-sockets group-4 1.00 ( 8.78) -0.79 ( 7.86)
threads-sockets group-8 1.00 ( 6.51) -15.64 ( 15.33)
threads-sockets group-12 1.00 ( 12.30) -7.09 ( 12.45)
threads-sockets group-16 1.00 ( 8.65) +3.77 ( 8.25)
threads-sockets group-20 1.00 ( 5.52) +4.40 ( 3.48)
threads-sockets group-24 1.00 ( 2.89) +2.54 ( 2.68)
threads-sockets group-32 1.00 ( 3.49) +1.17 ( 3.02)
threads-sockets group-48 1.00 ( 3.15) -3.95 ( 10.64)
netperf
=======
case load baseline(std%) compare%( std%)
TCP_RR thread-1 1.00 ( 0.55) -0.12 ( 0.47)
TCP_RR thread-2 1.00 ( 0.77) -0.44 ( 0.65)
TCP_RR thread-4 1.00 ( 0.73) +0.26 ( 0.61)
TCP_RR thread-8 1.00 ( 1.21) -0.18 ( 1.18)
TCP_RR thread-12 1.00 ( 1.91) -0.29 ( 2.25)
TCP_RR thread-16 1.00 ( 4.18) -0.45 ( 3.78)
TCP_RR thread-20 1.00 ( 2.09) -0.83 ( 1.75)
TCP_RR thread-24 1.00 ( 1.23) -0.42 ( 1.35)
TCP_RR thread-32 1.00 ( 13.72) +6.22 ( 16.10)
TCP_RR thread-48 1.00 ( 12.91) -0.38 ( 13.37)
UDP_RR thread-1 1.00 ( 0.85) +0.04 ( 0.75)
UDP_RR thread-2 1.00 ( 0.57) -0.56 ( 0.62)
UDP_RR thread-4 1.00 ( 0.65) -0.04 ( 0.78)
UDP_RR thread-8 1.00 ( 1.24) -0.46 ( 8.31)
UDP_RR thread-12 1.00 ( 6.87) +0.01 ( 1.27)
UDP_RR thread-16 1.00 ( 6.07) -0.30 ( 1.51)
UDP_RR thread-20 1.00 ( 1.00) -0.97 ( 0.87)
UDP_RR thread-24 1.00 ( 0.67) +0.65 ( 4.39)
UDP_RR thread-32 1.00 ( 15.59) +3.27 ( 17.34)
UDP_RR thread-48 1.00 ( 12.56) -1.28 ( 13.43)
tbench
======
case load baseline(std%) compare%( std%)
loopback thread-1 1.00 ( 0.59) +0.06 ( 0.53)
loopback thread-2 1.00 ( 0.44) -0.69 ( 0.66)
loopback thread-4 1.00 ( 0.27) +0.61 ( 0.31)
loopback thread-8 1.00 ( 0.25) -0.18 ( 0.20)
loopback thread-12 1.00 ( 1.12) -0.23 ( 0.85)
loopback thread-16 1.00 ( 0.40) -0.25 ( 1.59)
loopback thread-20 1.00 ( 0.20) +0.58 ( 0.34)
loopback thread-24 1.00 ( 6.93) +0.73 ( 8.46)
loopback thread-32 1.00 ( 4.61) +0.96 ( 1.62)
loopback thread-48 1.00 ( 2.33) +1.45 ( 0.97)
schbench
========
case load baseline(std%) compare%( std%)
normal mthread-1 1.00 ( 4.39) -0.37 ( 6.53)
normal mthread-2 1.00 ( 2.44) +0.96 ( 4.31)
normal mthread-4 1.00 ( 9.47) +13.26 ( 19.52)
normal mthread-8 1.00 ( 0.06) -1.05 ( 2.31)
normal mthread-12 1.00 ( 2.62) -0.66 ( 2.21)
normal mthread-16 1.00 ( 1.90) +0.21 ( 1.70)
normal mthread-20 1.00 ( 2.25) -0.44 ( 2.41)
normal mthread-24 1.00 ( 1.89) -0.05 ( 1.78)
normal mthread-32 1.00 ( 2.04) -0.28 ( 1.92)
normal mthread-48 1.00 ( 4.43) +1.10 ( 3.86)
[1]. https://lore.kernel.org/lkml/20210406041108.7416-1-ricardo.neri-calderon@linux.intel.com/
[2]. https://lore.kernel.org/lkml/20210414020436.12980-1-ricardo.neri-calderon@linux.intel.com/
[3]. https://lore.kernel.org/lkml/20210513154909.6385-1-ricardo.neri-calderon@linux.intel.com/
[4]. https://lore.kernel.org/lkml/20210810144145.18776-1-ricardo.neri-calderon@linux.intel.com/
Ricardo Neri (6):
x86/sched: Decrease further the priorities of SMT siblings
sched/topology: Introduce sched_group::flags
sched/fair: Optimize checking for group_asym_packing
sched/fair: Provide update_sg_lb_stats() with sched domain statistics
sched/fair: Carve out logic to mark a group for asymmetric packing
sched/fair: Consider SMT in ASYM_PACKING load balance
arch/x86/kernel/itmt.c | 2 +-
kernel/sched/fair.c | 121 ++++++++++++++++++++++++++++++++++++----
kernel/sched/sched.h | 1 +
kernel/sched/topology.c | 21 ++++++-
4 files changed, 131 insertions(+), 14 deletions(-)
--
2.17.1
When scheduling, it is better to prefer a separate physical core rather
than the SMT sibling of a high priority core. The existing formula to
compute priorities takes such fact in consideration. There may exist,
however, combinations of priorities (i.e., maximum frequencies) in which
the priority of high-numbered SMT siblings of high-priority cores collides
with the priority of low-numbered SMT siblings of low-priority cores.
Consider for instance an SMT2 system with CPUs [0, 1] with priority 60 and
[2, 3] with priority 30(CPUs in brackets are SMT siblings. In such a case,
the resulting priorities would be [120, 60], [60, 30]. Thus, to ensure
that CPU2 has higher priority than CPU1, divide the raw priority by the
squared SMT iterator. The resulting priorities are [120, 30]. [60, 15].
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Joel Fernandes (Google) <redacted>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Originally-by: Len Brown [off-list ref]
Signed-off-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* None
Changes since v3:
* Introduced this patch
Changes since v2:
* N/A
Changes since v1:
* N/A
---
arch/x86/kernel/itmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
There exist situations in which the load balance needs to know the
properties of the CPUs in a scheduling group. When using asymmetric
packing, for instance, the load balancer needs to know not only the
state of dst_cpu but also of its SMT siblings, if any.
Use the flags of the child scheduling domains to initialize scheduling
group flags. This will reflect the properties of the CPUs in the
group.
A subsequent changeset will make use of these new flags. No functional
changes are introduced.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Originally-by: Peter Zijlstra (Intel) [off-list ref]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* None
Changes since v3:
* Clear the flags of the scheduling groups of a domain if its child is
destroyed.
* Minor rewording of the commit message.
Changes since v2:
* Introduced this patch.
Changes since v1:
* N/A
---
kernel/sched/sched.h | 1 +
kernel/sched/topology.c | 21 ++++++++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
@@ -1809,6 +1809,7 @@ struct sched_group {unsignedintgroup_weight;structsched_group_capacity*sgc;intasym_prefer_cpu;/* CPU of highest priority in group */+intflags;/**TheCPUsthisgroupcovers.
From: Vincent Guittot <vincent.guittot@linaro.org> Date: 2021-09-17 15:26:17
On Sat, 11 Sept 2021 at 03:19, Ricardo Neri
[off-list ref] wrote:
There exist situations in which the load balance needs to know the
properties of the CPUs in a scheduling group. When using asymmetric
packing, for instance, the load balancer needs to know not only the
state of dst_cpu but also of its SMT siblings, if any.
Use the flags of the child scheduling domains to initialize scheduling
group flags. This will reflect the properties of the CPUs in the
group.
A subsequent changeset will make use of these new flags. No functional
changes are introduced.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Originally-by: Peter Zijlstra (Intel) [off-list ref]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ricardo Neri <redacted>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
quoted hunk
---
Changes since v4:
* None
Changes since v3:
* Clear the flags of the scheduling groups of a domain if its child is
destroyed.
* Minor rewording of the commit message.
Changes since v2:
* Introduced this patch.
Changes since v1:
* N/A
---
kernel/sched/sched.h | 1 +
kernel/sched/topology.c | 21 ++++++++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
@@ -1809,6 +1809,7 @@ struct sched_group {unsignedintgroup_weight;structsched_group_capacity*sgc;intasym_prefer_cpu;/* CPU of highest priority in group */+intflags;/**TheCPUsthisgroupcovers.
sched_asmy_prefer() always returns false when called on the local group. By
checking local_group, we can avoid additional checks and invoking
sched_asmy_prefer() when it is not needed. No functional changes are
introduced.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* None
Changes since v3:
* Further rewording of the commit message. (Len)
Changes since v2:
* Reworded the commit message for clarity. (Peter Z)
Changes since v1:
* None
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -8657,7 +8657,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,}/* Check if dst CPU is idle and preferred to this group */-if(env->sd->flags&SD_ASYM_PACKING&&+if(!local_group&&env->sd->flags&SD_ASYM_PACKING&&env->idle!=CPU_NOT_IDLE&&sgs->sum_h_nr_running&&sched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu)){
From: Vincent Guittot <vincent.guittot@linaro.org> Date: 2021-09-17 15:26:42
On Sat, 11 Sept 2021 at 03:19, Ricardo Neri
[off-list ref] wrote:
sched_asmy_prefer() always returns false when called on the local group. By
checking local_group, we can avoid additional checks and invoking
sched_asmy_prefer() when it is not needed. No functional changes are
introduced.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
quoted hunk
---
Changes since v4:
* None
Changes since v3:
* Further rewording of the commit message. (Len)
Changes since v2:
* Reworded the commit message for clarity. (Peter Z)
Changes since v1:
* None
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -8657,7 +8657,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,}/* Check if dst CPU is idle and preferred to this group */-if(env->sd->flags&SD_ASYM_PACKING&&+if(!local_group&&env->sd->flags&SD_ASYM_PACKING&&env->idle!=CPU_NOT_IDLE&&sgs->sum_h_nr_running&&sched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu)){--
Create a separate function, sched_asym(). A subsequent changeset will
introduce logic to deal with SMT in conjunction with asmymmetric
packing. Such logic will need the statistics of the scheduling
group provided as argument. Update them before calling sched_asym().
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Co-developed-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* None
Changes since v3:
* Remove a redundant check for the local group in sched_asym().
(Dietmar)
* Reworded commit message for clarity. (Len)
Changes since v2:
* Introduced this patch.
Changes since v1:
* N/A
---
kernel/sched/fair.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
@@ -8597,6 +8597,13 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+staticinlinebool+sched_asym(structlb_env*env,structsd_lb_stats*sds,structsg_lb_stats*sgs,+structsched_group*group)+{+returnsched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu);+}+/***update_sg_lb_stats-Updatesched_group'sstatisticsforloadbalancing.*@env:Theloadbalancingenvironment.
@@ -8657,18 +8664,17 @@ static inline void update_sg_lb_stats(struct lb_env *env,}}+sgs->group_capacity=group->sgc->capacity;++sgs->group_weight=group->group_weight;+/* Check if dst CPU is idle and preferred to this group */if(!local_group&&env->sd->flags&SD_ASYM_PACKING&&-env->idle!=CPU_NOT_IDLE&&-sgs->sum_h_nr_running&&-sched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu)){+env->idle!=CPU_NOT_IDLE&&sgs->sum_h_nr_running&&+sched_asym(env,sds,sgs,group)){sgs->group_asym_packing=1;}-sgs->group_capacity=group->sgc->capacity;--sgs->group_weight=group->group_weight;-sgs->group_type=group_classify(env->sd->imbalance_pct,group,sgs);/* Computing avg_load makes sense only when group is overloaded */
From: Vincent Guittot <vincent.guittot@linaro.org> Date: 2021-09-17 15:27:30
On Sat, 11 Sept 2021 at 03:19, Ricardo Neri
[off-list ref] wrote:
Create a separate function, sched_asym(). A subsequent changeset will
introduce logic to deal with SMT in conjunction with asmymmetric
packing. Such logic will need the statistics of the scheduling
group provided as argument. Update them before calling sched_asym().
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Co-developed-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ricardo Neri <redacted>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
quoted hunk
---
Changes since v4:
* None
Changes since v3:
* Remove a redundant check for the local group in sched_asym().
(Dietmar)
* Reworded commit message for clarity. (Len)
Changes since v2:
* Introduced this patch.
Changes since v1:
* N/A
---
kernel/sched/fair.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
@@ -8597,6 +8597,13 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+staticinlinebool+sched_asym(structlb_env*env,structsd_lb_stats*sds,structsg_lb_stats*sgs,+structsched_group*group)+{+returnsched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu);+}+/***update_sg_lb_stats-Updatesched_group'sstatisticsforloadbalancing.*@env:Theloadbalancingenvironment.
@@ -8657,18 +8664,17 @@ static inline void update_sg_lb_stats(struct lb_env *env,}}+sgs->group_capacity=group->sgc->capacity;++sgs->group_weight=group->group_weight;+/* Check if dst CPU is idle and preferred to this group */if(!local_group&&env->sd->flags&SD_ASYM_PACKING&&-env->idle!=CPU_NOT_IDLE&&-sgs->sum_h_nr_running&&-sched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu)){+env->idle!=CPU_NOT_IDLE&&sgs->sum_h_nr_running&&+sched_asym(env,sds,sgs,group)){sgs->group_asym_packing=1;}-sgs->group_capacity=group->sgc->capacity;--sgs->group_weight=group->group_weight;-sgs->group_type=group_classify(env->sd->imbalance_pct,group,sgs);/* Computing avg_load makes sense only when group is overloaded */--
Before deciding to pull tasks when using asymmetric packing of tasks,
on some architectures (e.g., x86) it is necessary to know not only the
state of dst_cpu but also of its SMT siblings. The decision to classify
a candidate busiest group as group_asym_packing is done in
update_sg_lb_stats(). Give this function access to the scheduling domain
statistics, which contains the statistics of the local group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Originally-by: Peter Zijlstra (Intel) [off-list ref]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* None
Changes since v3:
* None
Changes since v2:
* Introduced this patch.
Changes since v1:
* N/A
---
kernel/sched/fair.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
From: Vincent Guittot <vincent.guittot@linaro.org> Date: 2021-09-17 15:27:17
On Sat, 11 Sept 2021 at 03:19, Ricardo Neri
[off-list ref] wrote:
Before deciding to pull tasks when using asymmetric packing of tasks,
on some architectures (e.g., x86) it is necessary to know not only the
state of dst_cpu but also of its SMT siblings. The decision to classify
a candidate busiest group as group_asym_packing is done in
update_sg_lb_stats(). Give this function access to the scheduling domain
statistics, which contains the statistics of the local group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Originally-by: Peter Zijlstra (Intel) [off-list ref]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ricardo Neri <redacted>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
quoted hunk
---
Changes since v4:
* None
Changes since v3:
* None
Changes since v2:
* Introduced this patch.
Changes since v1:
* N/A
---
kernel/sched/fair.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* Use sg_lb_stats::sum_nr_running the idle state of a scheduling group.
(Vincent, Peter)
* Do not even idle CPUs in asym_smt_can_pull_tasks(). (Vincent)
* Updated function documentation and corrected a typo.
Changes since v3:
* Removed the arch_asym_check_smt_siblings() hook. Discussions with the
powerpc folks showed that this patch should not impact them. Also, more
recent powerpc processor no longer use asym_packing. (PeterZ)
* Removed unnecessary local variable in asym_can_pull_tasks(). (Dietmar)
* Removed unnecessary check for local CPUs when the local group has zero
utilization. (Joel)
* Renamed asym_can_pull_tasks() as asym_smt_can_pull_tasks() to reflect
the fact that it deals with SMT cases.
* Made asym_smt_can_pull_tasks() return false for !CONFIG_SCHED_SMT so
that callers can deal with non-SMT cases.
Changes since v2:
* Reworded the commit message to reflect updates in code.
* Corrected misrepresentation of dst_cpu as the CPU doing the load
balancing. (PeterZ)
* Removed call to arch_asym_check_smt_siblings() as it is now called in
sched_asym().
Changes since v1:
* Don't bailout in update_sd_pick_busiest() if dst_cpu cannot pull
tasks. Instead, reclassify the candidate busiest group, as it
may still be selected. (PeterZ)
* Avoid an expensive and unnecessary call to cpumask_weight() when
determining if a sched_group is comprised of SMT siblings.
(PeterZ).
---
kernel/sched/fair.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
@@ -8597,10 +8597,98 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_is_smt&&sg_busy_cpus>=2)+returntrue;++/*+*@dst_cpudoesnothaveSMTsiblings.@sgmayhaveSMT+*siblingsandonlyoneisbusy.Insuchcase,@dst_cpu+*canhelpifithashigherpriorityandisidle(i.e.,+*ithasnorunningtasks).+*/+return!sds->local_stat.sum_nr_running&&+sched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);+}++/* @dst_cpu has SMT siblings. */++if(sg_is_smt){+intlocal_busy_cpus=sds->local->group_weight-+sds->local_stat.idle_cpus;+intbusy_cpus_delta=sg_busy_cpus-local_busy_cpus;++if(busy_cpus_delta==1)+returnsched_asym_prefer(dst_cpu,+sg->asym_prefer_cpu);++returnfalse;+}++/*+*@sgdoesnothaveSMTsiblings.Ensurethat@sds::localdoesnotend+*upwithmorethanonebusySMTsiblingandonlypulltasksifthere+*arenotbusyCPUs(i.e.,noCPUhasrunningtasks).+*/+if(!sds->local_stat.sum_nr_running)+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);++returnfalse;+#else+/* Always return false so that callers deal with non-SMT cases. */+returnfalse;+#endif+}+staticinlineboolsched_asym(structlb_env*env,structsd_lb_stats*sds,structsg_lb_stats*sgs,structsched_group*group){+/* Only do SMT checks if either local or candidate have SMT siblings */+if((sds->local->flags&SD_SHARE_CPUCAPACITY)||+(group->flags&SD_SHARE_CPUCAPACITY))+returnasym_smt_can_pull_tasks(env->dst_cpu,sds,sgs,group);+returnsched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu);}
@@ -9606,6 +9694,12 @@ static struct rq *find_busiest_queue(struct lb_env *env,nr_running==1)continue;+/* Make sure we only pull tasks from a CPU of lower priority */+if((env->sd->flags&SD_ASYM_PACKING)&&+sched_asym_prefer(i,env->dst_cpu)&&+nr_running==1)+continue;+switch(env->migration_type){casemigrate_load:/*
From: Vincent Guittot <vincent.guittot@linaro.org> Date: 2021-09-15 15:43:58
On Sat, 11 Sept 2021 at 03:19, Ricardo Neri
[off-list ref] wrote:
quoted hunk
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* Use sg_lb_stats::sum_nr_running the idle state of a scheduling group.
(Vincent, Peter)
* Do not even idle CPUs in asym_smt_can_pull_tasks(). (Vincent)
* Updated function documentation and corrected a typo.
Changes since v3:
* Removed the arch_asym_check_smt_siblings() hook. Discussions with the
powerpc folks showed that this patch should not impact them. Also, more
recent powerpc processor no longer use asym_packing. (PeterZ)
* Removed unnecessary local variable in asym_can_pull_tasks(). (Dietmar)
* Removed unnecessary check for local CPUs when the local group has zero
utilization. (Joel)
* Renamed asym_can_pull_tasks() as asym_smt_can_pull_tasks() to reflect
the fact that it deals with SMT cases.
* Made asym_smt_can_pull_tasks() return false for !CONFIG_SCHED_SMT so
that callers can deal with non-SMT cases.
Changes since v2:
* Reworded the commit message to reflect updates in code.
* Corrected misrepresentation of dst_cpu as the CPU doing the load
balancing. (PeterZ)
* Removed call to arch_asym_check_smt_siblings() as it is now called in
sched_asym().
Changes since v1:
* Don't bailout in update_sd_pick_busiest() if dst_cpu cannot pull
tasks. Instead, reclassify the candidate busiest group, as it
may still be selected. (PeterZ)
* Avoid an expensive and unnecessary call to cpumask_weight() when
determining if a sched_group is comprised of SMT siblings.
(PeterZ).
---
kernel/sched/fair.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
@@ -8597,10 +8597,98 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_is_smt&&sg_busy_cpus>=2)
Do you really need to test sg_is_smt ? if sg_busy_cpus >= 2 then
sd_is_smt must be true ?
Also, This is the default behavior where we want to even the number of
busy cpu. Shouldn't you return false and fall back to the default
behavior ?
That being said, the default behavior tries to even the number of idle
cpus which is easier to compute and is equal to even the number of
busy cpus in "normal" system with the same number of cpus in groups
but this is not the case here. It could be good to change the default
behavior to even the number of busy cpus and that you use the default
behavior here. Additional condition will be used to select the busiest
group like more busy cpu or more number of running tasks
+ return true;
+
+ /*
+ * @dst_cpu does not have SMT siblings. @sg may have SMT
+ * siblings and only one is busy. In such case, @dst_cpu
+ * can help if it has higher priority and is idle (i.e.,
+ * it has no running tasks).
The previous comment above assume that "@dst_cpu is idle" but now you
need to check that sds->local_stat.sum_nr_running == 0
quoted hunk
+ */
+ return !sds->local_stat.sum_nr_running &&
+ 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);
+
+ return false;
+ }
+
+ /*
+ * @sg does not have SMT siblings. Ensure that @sds::local does not end
+ * up with more than one busy SMT sibling and only pull tasks if there
+ * are not busy CPUs (i.e., no CPU has running tasks).
+ */
+ if (!sds->local_stat.sum_nr_running)
+ return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu);
+
+ return false;
+#else
+ /* Always return false so that callers deal with non-SMT cases. */
+ return false;
+#endif
+}
+
static inline bool
sched_asym(struct lb_env *env, struct sd_lb_stats *sds, struct sg_lb_stats *sgs,
struct sched_group *group)
{
+ /* Only do SMT checks if either local or candidate have SMT siblings */
+ if ((sds->local->flags & SD_SHARE_CPUCAPACITY) ||
+ (group->flags & SD_SHARE_CPUCAPACITY))
+ return asym_smt_can_pull_tasks(env->dst_cpu, sds, sgs, group);
+
return sched_asym_prefer(env->dst_cpu, group->asym_prefer_cpu);
}
@@ -9606,6 +9694,12 @@ static struct rq *find_busiest_queue(struct lb_env *env, nr_running == 1) continue;+ /* Make sure we only pull tasks from a CPU of lower priority */+ if ((env->sd->flags & SD_ASYM_PACKING) &&+ sched_asym_prefer(i, env->dst_cpu) &&+ nr_running == 1)+ continue;+ switch (env->migration_type) { case migrate_load: /*--
On Wed, Sep 15, 2021 at 05:43:44PM +0200, Vincent Guittot wrote:
On Sat, 11 Sept 2021 at 03:19, Ricardo Neri
[off-list ref] wrote:
quoted
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* Use sg_lb_stats::sum_nr_running the idle state of a scheduling group.
(Vincent, Peter)
* Do not even idle CPUs in asym_smt_can_pull_tasks(). (Vincent)
* Updated function documentation and corrected a typo.
Changes since v3:
* Removed the arch_asym_check_smt_siblings() hook. Discussions with the
powerpc folks showed that this patch should not impact them. Also, more
recent powerpc processor no longer use asym_packing. (PeterZ)
* Removed unnecessary local variable in asym_can_pull_tasks(). (Dietmar)
* Removed unnecessary check for local CPUs when the local group has zero
utilization. (Joel)
* Renamed asym_can_pull_tasks() as asym_smt_can_pull_tasks() to reflect
the fact that it deals with SMT cases.
* Made asym_smt_can_pull_tasks() return false for !CONFIG_SCHED_SMT so
that callers can deal with non-SMT cases.
Changes since v2:
* Reworded the commit message to reflect updates in code.
* Corrected misrepresentation of dst_cpu as the CPU doing the load
balancing. (PeterZ)
* Removed call to arch_asym_check_smt_siblings() as it is now called in
sched_asym().
Changes since v1:
* Don't bailout in update_sd_pick_busiest() if dst_cpu cannot pull
tasks. Instead, reclassify the candidate busiest group, as it
may still be selected. (PeterZ)
* Avoid an expensive and unnecessary call to cpumask_weight() when
determining if a sched_group is comprised of SMT siblings.
(PeterZ).
---
kernel/sched/fair.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
@@ -8597,10 +8597,98 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_is_smt&&sg_busy_cpus>=2)
Do you really need to test sg_is_smt ? if sg_busy_cpus >= 2 then
sd_is_smt must be true ?
Thank you very much for your feedback Vincent!
Yes, it is true that sg_busy_cpus >=2 is only true if @sg is SMT. I will
remove this check.
Also, This is the default behavior where we want to even the number of
busy cpu. Shouldn't you return false and fall back to the default
behavior ?
This is also true.
That being said, the default behavior tries to even the number of idle
cpus which is easier to compute and is equal to even the number of
busy cpus in "normal" system with the same number of cpus in groups
but this is not the case here. It could be good to change the default
behavior to even the number of busy cpus and that you use the default
behavior here. Additional condition will be used to select the busiest
group like more busy cpu or more number of running tasks
That is a very good observation. Checking the number of idle CPUs
assumes that both groups have the same number of CPUs. I'll look into
modifying the default behavior.
quoted
+ return true;
+
+ /*
+ * @dst_cpu does not have SMT siblings. @sg may have SMT
+ * siblings and only one is busy. In such case, @dst_cpu
+ * can help if it has higher priority and is idle (i.e.,
+ * it has no running tasks).
The previous comment above assume that "@dst_cpu is idle" but now you
need to check that sds->local_stat.sum_nr_running == 0
But we already know that, right? We are here because in
update_sg_lb_stats() we determine that dst CPU is idle (env->idle !=
CPU_NOT_IDLE).
Thanks and BR,
Ricardo
From: Vincent Guittot <vincent.guittot@linaro.org> Date: 2021-09-17 07:41:37
On Fri, 17 Sept 2021 at 03:01, Ricardo Neri
[off-list ref] wrote:
On Wed, Sep 15, 2021 at 05:43:44PM +0200, Vincent Guittot wrote:
quoted
On Sat, 11 Sept 2021 at 03:19, Ricardo Neri
[off-list ref] wrote:
quoted
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* Use sg_lb_stats::sum_nr_running the idle state of a scheduling group.
(Vincent, Peter)
* Do not even idle CPUs in asym_smt_can_pull_tasks(). (Vincent)
* Updated function documentation and corrected a typo.
Changes since v3:
* Removed the arch_asym_check_smt_siblings() hook. Discussions with the
powerpc folks showed that this patch should not impact them. Also, more
recent powerpc processor no longer use asym_packing. (PeterZ)
* Removed unnecessary local variable in asym_can_pull_tasks(). (Dietmar)
* Removed unnecessary check for local CPUs when the local group has zero
utilization. (Joel)
* Renamed asym_can_pull_tasks() as asym_smt_can_pull_tasks() to reflect
the fact that it deals with SMT cases.
* Made asym_smt_can_pull_tasks() return false for !CONFIG_SCHED_SMT so
that callers can deal with non-SMT cases.
Changes since v2:
* Reworded the commit message to reflect updates in code.
* Corrected misrepresentation of dst_cpu as the CPU doing the load
balancing. (PeterZ)
* Removed call to arch_asym_check_smt_siblings() as it is now called in
sched_asym().
Changes since v1:
* Don't bailout in update_sd_pick_busiest() if dst_cpu cannot pull
tasks. Instead, reclassify the candidate busiest group, as it
may still be selected. (PeterZ)
* Avoid an expensive and unnecessary call to cpumask_weight() when
determining if a sched_group is comprised of SMT siblings.
(PeterZ).
---
kernel/sched/fair.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
@@ -8597,10 +8597,98 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_is_smt&&sg_busy_cpus>=2)
Do you really need to test sg_is_smt ? if sg_busy_cpus >= 2 then
sd_is_smt must be true ?
Thank you very much for your feedback Vincent!
Yes, it is true that sg_busy_cpus >=2 is only true if @sg is SMT. I will
remove this check.
quoted
Also, This is the default behavior where we want to even the number of
busy cpu. Shouldn't you return false and fall back to the default
behavior ?
This is also true.
quoted
That being said, the default behavior tries to even the number of idle
cpus which is easier to compute and is equal to even the number of
busy cpus in "normal" system with the same number of cpus in groups
but this is not the case here. It could be good to change the default
behavior to even the number of busy cpus and that you use the default
behavior here. Additional condition will be used to select the busiest
group like more busy cpu or more number of running tasks
That is a very good observation. Checking the number of idle CPUs
assumes that both groups have the same number of CPUs. I'll look into
modifying the default behavior.
quoted
quoted
+ return true;
+
+ /*
+ * @dst_cpu does not have SMT siblings. @sg may have SMT
+ * siblings and only one is busy. In such case, @dst_cpu
+ * can help if it has higher priority and is idle (i.e.,
+ * it has no running tasks).
The previous comment above assume that "@dst_cpu is idle" but now you
need to check that sds->local_stat.sum_nr_running == 0
But we already know that, right? We are here because in
update_sg_lb_stats() we determine that dst CPU is idle (env->idle !=
CPU_NOT_IDLE).
That's my point:
Why do you add the condition !sds->local_stat.sum_nr_running below ? I
assume that it's to check that the cpu is idle, isn't it ?
From: Vincent Guittot <vincent.guittot@linaro.org> Date: 2021-09-17 15:25:17
On Fri, 17 Sept 2021 at 03:01, Ricardo Neri
[off-list ref] wrote:
On Wed, Sep 15, 2021 at 05:43:44PM +0200, Vincent Guittot wrote:
quoted
On Sat, 11 Sept 2021 at 03:19, Ricardo Neri
[off-list ref] wrote:
quoted
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* Use sg_lb_stats::sum_nr_running the idle state of a scheduling group.
(Vincent, Peter)
* Do not even idle CPUs in asym_smt_can_pull_tasks(). (Vincent)
* Updated function documentation and corrected a typo.
Changes since v3:
* Removed the arch_asym_check_smt_siblings() hook. Discussions with the
powerpc folks showed that this patch should not impact them. Also, more
recent powerpc processor no longer use asym_packing. (PeterZ)
* Removed unnecessary local variable in asym_can_pull_tasks(). (Dietmar)
* Removed unnecessary check for local CPUs when the local group has zero
utilization. (Joel)
* Renamed asym_can_pull_tasks() as asym_smt_can_pull_tasks() to reflect
the fact that it deals with SMT cases.
* Made asym_smt_can_pull_tasks() return false for !CONFIG_SCHED_SMT so
that callers can deal with non-SMT cases.
Changes since v2:
* Reworded the commit message to reflect updates in code.
* Corrected misrepresentation of dst_cpu as the CPU doing the load
balancing. (PeterZ)
* Removed call to arch_asym_check_smt_siblings() as it is now called in
sched_asym().
Changes since v1:
* Don't bailout in update_sd_pick_busiest() if dst_cpu cannot pull
tasks. Instead, reclassify the candidate busiest group, as it
may still be selected. (PeterZ)
* Avoid an expensive and unnecessary call to cpumask_weight() when
determining if a sched_group is comprised of SMT siblings.
(PeterZ).
---
kernel/sched/fair.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
@@ -8597,10 +8597,98 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_is_smt&&sg_busy_cpus>=2)
Do you really need to test sg_is_smt ? if sg_busy_cpus >= 2 then
sd_is_smt must be true ?
Thank you very much for your feedback Vincent!
Yes, it is true that sg_busy_cpus >=2 is only true if @sg is SMT. I will
remove this check.
quoted
Also, This is the default behavior where we want to even the number of
busy cpu. Shouldn't you return false and fall back to the default
behavior ?
This is also true.
quoted
That being said, the default behavior tries to even the number of idle
cpus which is easier to compute and is equal to even the number of
busy cpus in "normal" system with the same number of cpus in groups
but this is not the case here. It could be good to change the default
behavior to even the number of busy cpus and that you use the default
behavior here. Additional condition will be used to select the busiest
group like more busy cpu or more number of running tasks
That is a very good observation. Checking the number of idle CPUs
assumes that both groups have the same number of CPUs. I'll look into
modifying the default behavior.
Because this change will impact default smt/smp system, we might
prefer to do that in a separate step
With the removal of the condition !sds->local_stat.sum_nr_running
which seems useless because dst_cpu is idle and not SMT, this patch
looks good to me
quoted
quoted
+ return true;
+
+ /*
+ * @dst_cpu does not have SMT siblings. @sg may have SMT
+ * siblings and only one is busy. In such case, @dst_cpu
+ * can help if it has higher priority and is idle (i.e.,
+ * it has no running tasks).
The previous comment above assume that "@dst_cpu is idle" but now you
need to check that sds->local_stat.sum_nr_running == 0
But we already know that, right? We are here because in
update_sg_lb_stats() we determine that dst CPU is idle (env->idle !=
CPU_NOT_IDLE).
Thanks and BR,
Ricardo
From: Peter Zijlstra <peterz@infradead.org> Date: 2021-09-17 18:47:39
On Fri, Sep 17, 2021 at 05:25:02PM +0200, Vincent Guittot wrote:
With the removal of the condition !sds->local_stat.sum_nr_running
which seems useless because dst_cpu is idle and not SMT, this patch
looks good to me
I've made it look like this. Thanks!
---
Subject: sched/fair: Consider SMT in ASYM_PACKING load balance
From: Ricardo Neri <redacted>
Date: Fri, 10 Sep 2021 18:18:19 -0700
From: Ricardo Neri <redacted>
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Signed-off-by: Ricardo Neri <redacted>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Link: https://lkml.kernel.org/r/20210911011819.12184-7-ricardo.neri-calderon@linux.intel.com
---
kernel/sched/fair.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
@@ -8538,10 +8538,96 @@ group_type group_classify(unsigned int ireturngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_busy_cpus>=2)/* implies sg_is_smt */+returntrue;++/*+*@dst_cpudoesnothaveSMTsiblings.@sgmayhaveSMT+*siblingsandonlyoneisbusy.Insuchcase,@dst_cpu+*canhelpifithashigherpriorityandisidle(i.e.,+*ithasnorunningtasks).+*/+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);+}++/* @dst_cpu has SMT siblings. */++if(sg_is_smt){+intlocal_busy_cpus=sds->local->group_weight-+sds->local_stat.idle_cpus;+intbusy_cpus_delta=sg_busy_cpus-local_busy_cpus;++if(busy_cpus_delta==1)+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);++returnfalse;+}++/*+*@sgdoesnothaveSMTsiblings.Ensurethat@sds::localdoesnotend+*upwithmorethanonebusySMTsiblingandonlypulltasksifthere+*arenotbusyCPUs(i.e.,noCPUhasrunningtasks).+*/+if(!sds->local_stat.sum_nr_running)+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);++returnfalse;+#else+/* Always return false so that callers deal with non-SMT cases. */+returnfalse;+#endif+}+staticinlineboolsched_asym(structlb_env*env,structsd_lb_stats*sds,structsg_lb_stats*sgs,structsched_group*group){+/* Only do SMT checks if either local or candidate have SMT siblings */+if((sds->local->flags&SD_SHARE_CPUCAPACITY)||+(group->flags&SD_SHARE_CPUCAPACITY))+returnasym_smt_can_pull_tasks(env->dst_cpu,sds,sgs,group);+returnsched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu);}
@@ -9547,6 +9633,12 @@ static struct rq *find_busiest_queue(strnr_running==1)continue;+/* Make sure we only pull tasks from a CPU of lower priority */+if((env->sd->flags&SD_ASYM_PACKING)&&+sched_asym_prefer(i,env->dst_cpu)&&+nr_running==1)+continue;+switch(env->migration_type){casemigrate_load:/*
From: Vincent Guittot <vincent.guittot@linaro.org> Date: 2021-09-18 09:33:57
On Fri, 17 Sept 2021 at 20:47, Peter Zijlstra [off-list ref] wrote:
On Fri, Sep 17, 2021 at 05:25:02PM +0200, Vincent Guittot wrote:
quoted
With the removal of the condition !sds->local_stat.sum_nr_running
which seems useless because dst_cpu is idle and not SMT, this patch
looks good to me
I've made it look like this. Thanks!
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Thanks
quoted hunk
---
Subject: sched/fair: Consider SMT in ASYM_PACKING load balance
From: Ricardo Neri <redacted>
Date: Fri, 10 Sep 2021 18:18:19 -0700
From: Ricardo Neri <redacted>
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Signed-off-by: Ricardo Neri <redacted>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Link: https://lkml.kernel.org/r/20210911011819.12184-7-ricardo.neri-calderon@linux.intel.com
---
kernel/sched/fair.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
@@ -8538,10 +8538,96 @@ group_type group_classify(unsigned int ireturngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_busy_cpus>=2)/* implies sg_is_smt */+returntrue;++/*+*@dst_cpudoesnothaveSMTsiblings.@sgmayhaveSMT+*siblingsandonlyoneisbusy.Insuchcase,@dst_cpu+*canhelpifithashigherpriorityandisidle(i.e.,+*ithasnorunningtasks).+*/+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);+}++/* @dst_cpu has SMT siblings. */++if(sg_is_smt){+intlocal_busy_cpus=sds->local->group_weight-+sds->local_stat.idle_cpus;+intbusy_cpus_delta=sg_busy_cpus-local_busy_cpus;++if(busy_cpus_delta==1)+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);++returnfalse;+}++/*+*@sgdoesnothaveSMTsiblings.Ensurethat@sds::localdoesnotend+*upwithmorethanonebusySMTsiblingandonlypulltasksifthere+*arenotbusyCPUs(i.e.,noCPUhasrunningtasks).+*/+if(!sds->local_stat.sum_nr_running)+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);++returnfalse;+#else+/* Always return false so that callers deal with non-SMT cases. */+returnfalse;+#endif+}+staticinlineboolsched_asym(structlb_env*env,structsd_lb_stats*sds,structsg_lb_stats*sgs,structsched_group*group){+/* Only do SMT checks if either local or candidate have SMT siblings */+if((sds->local->flags&SD_SHARE_CPUCAPACITY)||+(group->flags&SD_SHARE_CPUCAPACITY))+returnasym_smt_can_pull_tasks(env->dst_cpu,sds,sgs,group);+returnsched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu);}
@@ -9547,6 +9633,12 @@ static struct rq *find_busiest_queue(strnr_running==1)continue;+/* Make sure we only pull tasks from a CPU of lower priority */+if((env->sd->flags&SD_ASYM_PACKING)&&+sched_asym_prefer(i,env->dst_cpu)&&+nr_running==1)+continue;+switch(env->migration_type){casemigrate_load:/*
Hi Ricardo,
Please see the bisection report below about a boot failure on
rk3288-rock64.
Reports aren't automatically sent to the public while we're
trialing new bisection features on kernelci.org but this one
looks valid.
Some more details can be found here:
https://linux.kernelci.org/test/case/id/6155a4b0836c79a98f99a31d/
It looks like some i.MX arm64 platforms also regressed with
next-20210920 although it hasn't been verified yet whether that's
due to the same commit:
https://linux.kernelci.org/test/job/next/branch/master/kernel/next-20210930/plan/baseline/
The x86 platforms don't seem to be impacted though.
Please let us know if you need help debugging the issue or if you
have a fix to try.
Best wishes,
Guillaume
GitHub: https://github.com/kernelci/kernelci-project/issues/65
-------------------------------------------------------------------------------
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This automated bisection report was sent to you on the basis *
* that you may be involved with the breaking commit it has *
* found. No manual investigation has been done to verify it, *
* and the root cause of the problem may be somewhere else. *
* *
* If you do send a fix, please include this trailer: *
* Reported-by: "kernelci.org bot" [off-list ref] *
* *
* Hope this helps! *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
next/master bisection: baseline.login on rk3328-rock64
Summary:
Start: 2d02a18f75fc Add linux-next specific files for 20210929
Plain log: https://storage.kernelci.org/next/master/next-20210929/arm64/defconfig+CONFIG_RANDOMIZE_BASE=y/gcc-8/lab-baylibre/baseline-rk3328-rock64.txt
HTML log: https://storage.kernelci.org/next/master/next-20210929/arm64/defconfig+CONFIG_RANDOMIZE_BASE=y/gcc-8/lab-baylibre/baseline-rk3328-rock64.html
Result: eac6f3841f1d sched/fair: Consider SMT in ASYM_PACKING load balance
Checks:
revert: PASS
verify: PASS
Parameters:
Tree: next
URL: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
Branch: master
Target: rk3328-rock64
CPU arch: arm64
Lab: lab-baylibre
Compiler: gcc-8
Config: defconfig+CONFIG_RANDOMIZE_BASE=y
Test case: baseline.login
Breaking commit found:
-------------------------------------------------------------------------------
commit eac6f3841f1dac7b6f43002056b63f44cc1f1543
Author: Ricardo Neri [off-list ref]
Date: Fri Sep 10 18:18:19 2021 -0700
sched/fair: Consider SMT in ASYM_PACKING load balance
On 11/09/2021 03:18, Ricardo Neri wrote:
quoted hunk
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* Use sg_lb_stats::sum_nr_running the idle state of a scheduling group.
(Vincent, Peter)
* Do not even idle CPUs in asym_smt_can_pull_tasks(). (Vincent)
* Updated function documentation and corrected a typo.
Changes since v3:
* Removed the arch_asym_check_smt_siblings() hook. Discussions with the
powerpc folks showed that this patch should not impact them. Also, more
recent powerpc processor no longer use asym_packing. (PeterZ)
* Removed unnecessary local variable in asym_can_pull_tasks(). (Dietmar)
* Removed unnecessary check for local CPUs when the local group has zero
utilization. (Joel)
* Renamed asym_can_pull_tasks() as asym_smt_can_pull_tasks() to reflect
the fact that it deals with SMT cases.
* Made asym_smt_can_pull_tasks() return false for !CONFIG_SCHED_SMT so
that callers can deal with non-SMT cases.
Changes since v2:
* Reworded the commit message to reflect updates in code.
* Corrected misrepresentation of dst_cpu as the CPU doing the load
balancing. (PeterZ)
* Removed call to arch_asym_check_smt_siblings() as it is now called in
sched_asym().
Changes since v1:
* Don't bailout in update_sd_pick_busiest() if dst_cpu cannot pull
tasks. Instead, reclassify the candidate busiest group, as it
may still be selected. (PeterZ)
* Avoid an expensive and unnecessary call to cpumask_weight() when
determining if a sched_group is comprised of SMT siblings.
(PeterZ).
---
kernel/sched/fair.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
@@ -8597,10 +8597,98 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_is_smt&&sg_busy_cpus>=2)+returntrue;++/*+*@dst_cpudoesnothaveSMTsiblings.@sgmayhaveSMT+*siblingsandonlyoneisbusy.Insuchcase,@dst_cpu+*canhelpifithashigherpriorityandisidle(i.e.,+*ithasnorunningtasks).+*/+return!sds->local_stat.sum_nr_running&&+sched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);+}++/* @dst_cpu has SMT siblings. */++if(sg_is_smt){+intlocal_busy_cpus=sds->local->group_weight-+sds->local_stat.idle_cpus;+intbusy_cpus_delta=sg_busy_cpus-local_busy_cpus;++if(busy_cpus_delta==1)+returnsched_asym_prefer(dst_cpu,+sg->asym_prefer_cpu);++returnfalse;+}++/*+*@sgdoesnothaveSMTsiblings.Ensurethat@sds::localdoesnotend+*upwithmorethanonebusySMTsiblingandonlypulltasksifthere+*arenotbusyCPUs(i.e.,noCPUhasrunningtasks).+*/+if(!sds->local_stat.sum_nr_running)+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);++returnfalse;+#else+/* Always return false so that callers deal with non-SMT cases. */+returnfalse;+#endif+}+staticinlineboolsched_asym(structlb_env*env,structsd_lb_stats*sds,structsg_lb_stats*sgs,structsched_group*group){+/* Only do SMT checks if either local or candidate have SMT siblings */+if((sds->local->flags&SD_SHARE_CPUCAPACITY)||+(group->flags&SD_SHARE_CPUCAPACITY))+returnasym_smt_can_pull_tasks(env->dst_cpu,sds,sgs,group);+returnsched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu);}
@@ -9606,6 +9694,12 @@ static struct rq *find_busiest_queue(struct lb_env *env,nr_running==1)continue;+/* Make sure we only pull tasks from a CPU of lower priority */+if((env->sd->flags&SD_ASYM_PACKING)&&+sched_asym_prefer(i,env->dst_cpu)&&+nr_running==1)+continue;+switch(env->migration_type){casemigrate_load:/*
From: Vincent Guittot <vincent.guittot@linaro.org> Date: 2021-10-01 10:25:57
Hi Guillaume,
This patch and the patchset which includes this patch only impacts
systems with hyperthreading which is not the case of rk3328-rock64
AFAICT. So there is no reason that this code is used by the board. The
only impact should be an increase of the binary for this platform.
Could it be that it reached a limit ?
Regards,
Vincent
On Fri, 1 Oct 2021 at 11:33, Guillaume Tucker
[off-list ref] wrote:
Hi Ricardo,
Please see the bisection report below about a boot failure on
rk3288-rock64.
Reports aren't automatically sent to the public while we're
trialing new bisection features on kernelci.org but this one
looks valid.
Some more details can be found here:
https://linux.kernelci.org/test/case/id/6155a4b0836c79a98f99a31d/
It looks like some i.MX arm64 platforms also regressed with
next-20210920 although it hasn't been verified yet whether that's
due to the same commit:
https://linux.kernelci.org/test/job/next/branch/master/kernel/next-20210930/plan/baseline/
The x86 platforms don't seem to be impacted though.
Please let us know if you need help debugging the issue or if you
have a fix to try.
Best wishes,
Guillaume
GitHub: https://github.com/kernelci/kernelci-project/issues/65
-------------------------------------------------------------------------------
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This automated bisection report was sent to you on the basis *
* that you may be involved with the breaking commit it has *
* found. No manual investigation has been done to verify it, *
* and the root cause of the problem may be somewhere else. *
* *
* If you do send a fix, please include this trailer: *
* Reported-by: "kernelci.org bot" [off-list ref] *
* *
* Hope this helps! *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
next/master bisection: baseline.login on rk3328-rock64
Summary:
Start: 2d02a18f75fc Add linux-next specific files for 20210929
Plain log: https://storage.kernelci.org/next/master/next-20210929/arm64/defconfig+CONFIG_RANDOMIZE_BASE=y/gcc-8/lab-baylibre/baseline-rk3328-rock64.txt
HTML log: https://storage.kernelci.org/next/master/next-20210929/arm64/defconfig+CONFIG_RANDOMIZE_BASE=y/gcc-8/lab-baylibre/baseline-rk3328-rock64.html
Result: eac6f3841f1d sched/fair: Consider SMT in ASYM_PACKING load balance
Checks:
revert: PASS
verify: PASS
Parameters:
Tree: next
URL: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
Branch: master
Target: rk3328-rock64
CPU arch: arm64
Lab: lab-baylibre
Compiler: gcc-8
Config: defconfig+CONFIG_RANDOMIZE_BASE=y
Test case: baseline.login
Breaking commit found:
-------------------------------------------------------------------------------
commit eac6f3841f1dac7b6f43002056b63f44cc1f1543
Author: Ricardo Neri [off-list ref]
Date: Fri Sep 10 18:18:19 2021 -0700
sched/fair: Consider SMT in ASYM_PACKING load balance
On 11/09/2021 03:18, Ricardo Neri wrote:
quoted
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* Use sg_lb_stats::sum_nr_running the idle state of a scheduling group.
(Vincent, Peter)
* Do not even idle CPUs in asym_smt_can_pull_tasks(). (Vincent)
* Updated function documentation and corrected a typo.
Changes since v3:
* Removed the arch_asym_check_smt_siblings() hook. Discussions with the
powerpc folks showed that this patch should not impact them. Also, more
recent powerpc processor no longer use asym_packing. (PeterZ)
* Removed unnecessary local variable in asym_can_pull_tasks(). (Dietmar)
* Removed unnecessary check for local CPUs when the local group has zero
utilization. (Joel)
* Renamed asym_can_pull_tasks() as asym_smt_can_pull_tasks() to reflect
the fact that it deals with SMT cases.
* Made asym_smt_can_pull_tasks() return false for !CONFIG_SCHED_SMT so
that callers can deal with non-SMT cases.
Changes since v2:
* Reworded the commit message to reflect updates in code.
* Corrected misrepresentation of dst_cpu as the CPU doing the load
balancing. (PeterZ)
* Removed call to arch_asym_check_smt_siblings() as it is now called in
sched_asym().
Changes since v1:
* Don't bailout in update_sd_pick_busiest() if dst_cpu cannot pull
tasks. Instead, reclassify the candidate busiest group, as it
may still be selected. (PeterZ)
* Avoid an expensive and unnecessary call to cpumask_weight() when
determining if a sched_group is comprised of SMT siblings.
(PeterZ).
---
kernel/sched/fair.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
@@ -8597,10 +8597,98 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_is_smt&&sg_busy_cpus>=2)+returntrue;++/*+*@dst_cpudoesnothaveSMTsiblings.@sgmayhaveSMT+*siblingsandonlyoneisbusy.Insuchcase,@dst_cpu+*canhelpifithashigherpriorityandisidle(i.e.,+*ithasnorunningtasks).+*/+return!sds->local_stat.sum_nr_running&&+sched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);+}++/* @dst_cpu has SMT siblings. */++if(sg_is_smt){+intlocal_busy_cpus=sds->local->group_weight-+sds->local_stat.idle_cpus;+intbusy_cpus_delta=sg_busy_cpus-local_busy_cpus;++if(busy_cpus_delta==1)+returnsched_asym_prefer(dst_cpu,+sg->asym_prefer_cpu);++returnfalse;+}++/*+*@sgdoesnothaveSMTsiblings.Ensurethat@sds::localdoesnotend+*upwithmorethanonebusySMTsiblingandonlypulltasksifthere+*arenotbusyCPUs(i.e.,noCPUhasrunningtasks).+*/+if(!sds->local_stat.sum_nr_running)+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);++returnfalse;+#else+/* Always return false so that callers deal with non-SMT cases. */+returnfalse;+#endif+}+staticinlineboolsched_asym(structlb_env*env,structsd_lb_stats*sds,structsg_lb_stats*sgs,structsched_group*group){+/* Only do SMT checks if either local or candidate have SMT siblings */+if((sds->local->flags&SD_SHARE_CPUCAPACITY)||+(group->flags&SD_SHARE_CPUCAPACITY))+returnasym_smt_can_pull_tasks(env->dst_cpu,sds,sgs,group);+returnsched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu);}
@@ -9606,6 +9694,12 @@ static struct rq *find_busiest_queue(struct lb_env *env,nr_running==1)continue;+/* Make sure we only pull tasks from a CPU of lower priority */+if((env->sd->flags&SD_ASYM_PACKING)&&+sched_asym_prefer(i,env->dst_cpu)&&+nr_running==1)+continue;+switch(env->migration_type){casemigrate_load:/*
On Fri, Oct 01, 2021 at 12:25:42PM +0200, Vincent Guittot wrote:
Hi Guillaume,
This patch and the patchset which includes this patch only impacts
systems with hyperthreading which is not the case of rk3328-rock64
AFAICT. So there is no reason that this code is used by the board. The
only impact should be an increase of the binary for this platform.
Could it be that it reached a limit ?
Regards,
Vincent
On Fri, 1 Oct 2021 at 11:33, Guillaume Tucker
[off-list ref] wrote:
quoted
Hi Ricardo,
Please see the bisection report below about a boot failure on
rk3288-rock64.
Reports aren't automatically sent to the public while we're
trialing new bisection features on kernelci.org but this one
looks valid.
Some more details can be found here:
https://linux.kernelci.org/test/case/id/6155a4b0836c79a98f99a31d/
It looks like some i.MX arm64 platforms also regressed with
next-20210920 although it hasn't been verified yet whether that's
due to the same commit:
https://linux.kernelci.org/test/job/next/branch/master/kernel/next-20210930/plan/baseline/
The x86 platforms don't seem to be impacted though.
Please let us know if you need help debugging the issue or if you
have a fix to try.
Hi Guillaume,
I accessed the bug report above. It does not seem to include any kernel
log or crash. Maybe it hangs very early at boot? As Vicent mention, this
code is specific to hyperthreading. Furthermore, for this code path to
be executed the scheduling domains must have the SD_ASYM_PACKING flag.
AFAIK, only powerpc and x86 use this flag. Also, by the time this code
is executed, we should be past early boot. At least some messages should
have been printed to the kernel console.
Maybe Vincent's idea on the binary size is the issue?
Thanks and BR,
Ricardo
quoted
Best wishes,
Guillaume
GitHub: https://github.com/kernelci/kernelci-project/issues/65
-------------------------------------------------------------------------------
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This automated bisection report was sent to you on the basis *
* that you may be involved with the breaking commit it has *
* found. No manual investigation has been done to verify it, *
* and the root cause of the problem may be somewhere else. *
* *
* If you do send a fix, please include this trailer: *
* Reported-by: "kernelci.org bot" [off-list ref] *
* *
* Hope this helps! *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
next/master bisection: baseline.login on rk3328-rock64
Summary:
Start: 2d02a18f75fc Add linux-next specific files for 20210929
Plain log: https://storage.kernelci.org/next/master/next-20210929/arm64/defconfig+CONFIG_RANDOMIZE_BASE=y/gcc-8/lab-baylibre/baseline-rk3328-rock64.txt
HTML log: https://storage.kernelci.org/next/master/next-20210929/arm64/defconfig+CONFIG_RANDOMIZE_BASE=y/gcc-8/lab-baylibre/baseline-rk3328-rock64.html
Result: eac6f3841f1d sched/fair: Consider SMT in ASYM_PACKING load balance
Checks:
revert: PASS
verify: PASS
Parameters:
Tree: next
URL: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
Branch: master
Target: rk3328-rock64
CPU arch: arm64
Lab: lab-baylibre
Compiler: gcc-8
Config: defconfig+CONFIG_RANDOMIZE_BASE=y
Test case: baseline.login
Breaking commit found:
-------------------------------------------------------------------------------
commit eac6f3841f1dac7b6f43002056b63f44cc1f1543
Author: Ricardo Neri [off-list ref]
Date: Fri Sep 10 18:18:19 2021 -0700
sched/fair: Consider SMT in ASYM_PACKING load balance
On 11/09/2021 03:18, Ricardo Neri wrote:
quoted
When deciding to pull tasks in ASYM_PACKING, it is necessary not only to
check for the idle state of the destination CPU, dst_cpu, but also of
its SMT siblings.
If dst_cpu is idle but its SMT siblings are busy, performance suffers
if it pulls tasks from a medium priority CPU that does not have SMT
siblings.
Implement asym_smt_can_pull_tasks() to inspect the state of the SMT
siblings of both dst_cpu and the CPUs in the candidate busiest group.
Cc: Aubrey Li <redacted>
Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <redacted>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Quentin Perret <redacted>
Cc: Rafael J. Wysocki <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <redacted>
Reviewed-by: Joel Fernandes (Google) <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
Changes since v4:
* Use sg_lb_stats::sum_nr_running the idle state of a scheduling group.
(Vincent, Peter)
* Do not even idle CPUs in asym_smt_can_pull_tasks(). (Vincent)
* Updated function documentation and corrected a typo.
Changes since v3:
* Removed the arch_asym_check_smt_siblings() hook. Discussions with the
powerpc folks showed that this patch should not impact them. Also, more
recent powerpc processor no longer use asym_packing. (PeterZ)
* Removed unnecessary local variable in asym_can_pull_tasks(). (Dietmar)
* Removed unnecessary check for local CPUs when the local group has zero
utilization. (Joel)
* Renamed asym_can_pull_tasks() as asym_smt_can_pull_tasks() to reflect
the fact that it deals with SMT cases.
* Made asym_smt_can_pull_tasks() return false for !CONFIG_SCHED_SMT so
that callers can deal with non-SMT cases.
Changes since v2:
* Reworded the commit message to reflect updates in code.
* Corrected misrepresentation of dst_cpu as the CPU doing the load
balancing. (PeterZ)
* Removed call to arch_asym_check_smt_siblings() as it is now called in
sched_asym().
Changes since v1:
* Don't bailout in update_sd_pick_busiest() if dst_cpu cannot pull
tasks. Instead, reclassify the candidate busiest group, as it
may still be selected. (PeterZ)
* Avoid an expensive and unnecessary call to cpumask_weight() when
determining if a sched_group is comprised of SMT siblings.
(PeterZ).
---
kernel/sched/fair.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
@@ -8597,10 +8597,98 @@ group_type group_classify(unsigned int imbalance_pct,returngroup_has_spare;}+/**+*asym_smt_can_pull_tasks-CheckwhethertheloadbalancingCPUcanpulltasks+*@dst_cpu:DestinationCPUoftheloadbalancing+*@sds:Load-balancingdatawithstatisticsofthelocalgroup+*@sgs:Load-balancingstatisticsofthecandidatebusiestgroup+*@sg:Thecandidatebusiestgroup+*+*CheckthestateoftheSMTsiblingsofboth@sds::localand@sganddecide+*if@dst_cpucanpulltasks.+*+*If@dst_cpudoesnothaveSMTsiblings,itcanpulltasksiftwoormoreof+*theSMTsiblingsof@sgarebusy.IfonlyoneCPUin@sgisbusy,pulltasks+*onlyif@dst_cpuhashigherpriority.+*+*Ifboth@dst_cpuand@sghaveSMTsiblings,and@sghasexactlyonemore+*busyCPUthan@sds::local,let@dst_cpupulltasksifithashigherpriority.+*BiggerimbalancesinthenumberofbusyCPUswillbedealtwithin+*update_sd_pick_busiest().+*+*If@sgdoesnothaveSMTsiblings,onlypulltasksifalloftheSMTsiblings+*of@dst_cpuareidleand@sghaslowerpriority.+*/+staticboolasym_smt_can_pull_tasks(intdst_cpu,structsd_lb_stats*sds,+structsg_lb_stats*sgs,+structsched_group*sg)+{+#ifdef CONFIG_SCHED_SMT+boollocal_is_smt,sg_is_smt;+intsg_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){+/*+*Ifwearehere,@dst_cpuisidleanddoesnothaveSMT+*siblings.Pulltasksifcandidategrouphastwoormore+*busyCPUs.+*/+if(sg_is_smt&&sg_busy_cpus>=2)+returntrue;++/*+*@dst_cpudoesnothaveSMTsiblings.@sgmayhaveSMT+*siblingsandonlyoneisbusy.Insuchcase,@dst_cpu+*canhelpifithashigherpriorityandisidle(i.e.,+*ithasnorunningtasks).+*/+return!sds->local_stat.sum_nr_running&&+sched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);+}++/* @dst_cpu has SMT siblings. */++if(sg_is_smt){+intlocal_busy_cpus=sds->local->group_weight-+sds->local_stat.idle_cpus;+intbusy_cpus_delta=sg_busy_cpus-local_busy_cpus;++if(busy_cpus_delta==1)+returnsched_asym_prefer(dst_cpu,+sg->asym_prefer_cpu);++returnfalse;+}++/*+*@sgdoesnothaveSMTsiblings.Ensurethat@sds::localdoesnotend+*upwithmorethanonebusySMTsiblingandonlypulltasksifthere+*arenotbusyCPUs(i.e.,noCPUhasrunningtasks).+*/+if(!sds->local_stat.sum_nr_running)+returnsched_asym_prefer(dst_cpu,sg->asym_prefer_cpu);++returnfalse;+#else+/* Always return false so that callers deal with non-SMT cases. */+returnfalse;+#endif+}+staticinlineboolsched_asym(structlb_env*env,structsd_lb_stats*sds,structsg_lb_stats*sgs,structsched_group*group){+/* Only do SMT checks if either local or candidate have SMT siblings */+if((sds->local->flags&SD_SHARE_CPUCAPACITY)||+(group->flags&SD_SHARE_CPUCAPACITY))+returnasym_smt_can_pull_tasks(env->dst_cpu,sds,sgs,group);+returnsched_asym_prefer(env->dst_cpu,group->asym_prefer_cpu);}
@@ -9606,6 +9694,12 @@ static struct rq *find_busiest_queue(struct lb_env *env,nr_running==1)continue;+/* Make sure we only pull tasks from a CPU of lower priority */+if((env->sd->flags&SD_ASYM_PACKING)&&+sched_asym_prefer(i,env->dst_cpu)&&+nr_running==1)+continue;+switch(env->migration_type){casemigrate_load:/*