sched: Introduce idle SMT priority for asymmetric capacity systems
cover sched: Introduce idle SMT priority for asymmetric capacity systems
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle cores over idle SMT siblings of busy cores. This works generally well but virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.
Background
===========================================================================
The scheduler has been moving toward better utilization of fully idle cores and avoiding SMT penalties. This trend (notably after commit 25a32e400a14 ("sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection") broke the behavior s390 is relying on to concentrate workloads on its high-capacity cores. On s390 CPU capacities represent the CPUs runtime entitlement assigned by the hypervisor. The idle SMT siblings of busy high-capacity cores start to perform better than fully idle low-capacity cores as the whole machine(containing the logical partitions) starts approaching to a {fully,over}loaded state. Grouping load on high-capacity cores keeps shared low-capacity cores(which are shared more aggressively) idle longer, reducing noise to neighboring partitions and improving overall performance.
Approach
===========================================================================
This series introduces SCHED_IDLE_SMT_PRIO config option and the sched_idle_smt_prio static branch, allowing architectures to treat idle SMT siblings of busy cores as equal candidates during asymmetric capacity load balancing.
Static branch checks are placed at paths considering fully idle cores over idle SMT threads in presence of asymmetric CPU capacities within scheduling groups. Inserted checks mostly override hints for idle core selection or cause early exits favoring idle SMT siblings. One more static branch check is added to new task path in order to favor high capacity SMT siblings during initial task placement, therefore the tasks are immediately placed in high capacity SMT siblings instead of considering most idle but low capacity cores.
Architectures opt in by selecting ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO and implementing arch_needs_idle_smt_prio(), which is evaluated during each asym_cpu_capacity_scan() to track the state as runtime topology changes.
The second patch enables the feature for s390 when running on hardware-backed topology in an LPAR with vertical polarization active and system is approaching to a target state.
Otherwise the branch stays disabled and the scheduler falls back to the standard idle-core preference.
No functional change on architectures that do not select ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO.
Performance Results
===========================================================================
Since this change effects the {fully,over}loaded state it is difficult to test at the moment. Therefore there are no concrete numbers or metrics for now for s390.
For architectures which do not opt in to this feature, no performance change is expected.
Considerations and Open Questions
===========================================================================
The main goal for this series is adding a simple mechanism for architectures to switch between idle core and idle SMT priority while keeping the introduced footprint as small as possible. But there are some ideas and questions to consider;
1. Should arch_needs_idle_smt_prio() hook be removed?
The architecture hook is there to allow for any sort of logic to dynamically decide when to flip the mechanism, but it can also be removed if everyone agrees that this behaviour is not something that should be dynamically flipped. It can be simply tied to detection of asymmetric capacities and selection of Kconfig option.
2. Is there a simpler way to implement this mechanism?
The proposed approach is chosen as the other features effecting the scheduler's behavior, use the same method. If there is a more efficient way to implement the same mechanism I'd be glad to use that instead.
3. There are no performance measurements *yet*.
On s390 the ideal conditions for this mechanism to be beneficial usually surface when the whole system is fully loaded and resource sharing between the logical partitions starts to get expensive. Creating such an environment requires time, therefore no benchmark results are available yet.
---
base-commit: 587858367581b9c55c3690f4e63382ad622719d4
Mete Durlu (2):
kernel/sched: Introduce idle SMT priority
s390/topology: Enable SCHED_IDLE_SMT_PRIO
arch/Kconfig | 14 +++++++++ arch/s390/Kconfig | 1 + arch/s390/include/asm/topology.h | 5 +++ arch/s390/kernel/topology.c | 9 ++++++ include/linux/sched/topology.h | 9 ++++++ kernel/sched/fair.c | 67 +++++++++++++++++++++++++++++----------- kernel/sched/sched.h | 10 ++++++ kernel/sched/topology.c | 17 ++++++++++ 8 files changed, 114 insertions(+), 18 deletions(-)
RFC PATCH 1/2 kernel/sched: Introduce idle SMT priority
On systems with asymmetric CPU capacities and SMT, the scheduler currently prefers fully idle cores over idle SMT siblings of busy cores. This leads tasks onto lower capacity idle cores when a higher-capacity core has an idle sibling thread available. This hurts performance in cases where an SMT sibling of a busy but high capacity core can outperform a fully idle but low capacity core.
Introduce SCHED_IDLE_SMT_PRIO and the sched_idle_smt_prio static branch to allow architectures to override this preference. When enabled, idle SMT siblings of busy cores are treated as regular candidates.
The static branch defaults to false and is opt-in per architecture, so systems that do not select ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO see no change in behavior.
Architectures opt in by selecting ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO and implementing arch_needs_idle_smt_prio(), which is called during each asym_cpu_capacity_scan(). In case there is no asymmetric capacities static branches get disabled.
--- arch/Kconfig | 14 +++++++++ include/linux/sched/topology.h | 9 ++++++ kernel/sched/fair.c | 67 ++++++++++++++++++++++++++++++------------ kernel/sched/sched.h | 10 +++++++ kernel/sched/topology.c | 17 +++++++++++ 5 files changed, 99 insertions(+), 18 deletions(-)
arch/Kconfig +14 -0
@@ -47,6 +47,9 @@ config ARCH_SUPPORTS_SCHED_SMT config ARCH_SUPPORTS_SCHED_CLUSTER bool +config ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO + bool + config ARCH_SUPPORTS_SCHED_MC bool
@@ -79,6 +82,17 @@ config SCHED_MC making when dealing with multi-core CPU chips at a cost of slightly increased overhead in some places. If unsure say N here. +config SCHED_IDLE_SMT_PRIO + bool "Idle SMT priority support in presence of asymmetric capacities" + depends on SCHED_SMT + depends on ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO + default y + help + On asymmetric CPU capacity systems, an idle SMT sibling of a + busy high-capacity core can outperform a fully idle low-capacity + core. Allows architectures to override the schedulers default + idle core preference accordingly. + # Selected by HOTPLUG_CORE_SYNC_DEAD or HOTPLUG_CORE_SYNC_FULL config HOTPLUG_CORE_SYNC bool
include/linux/sched/topology.h +9 -0
@@ -275,6 +275,15 @@ unsigned int arch_scale_freq_ref(int cpu) }#endif +#ifdef CONFIG_SCHED_IDLE_SMT_PRIO +#ifndef arch_needs_idle_smt_prio +static __always_inline bool arch_needs_idle_smt_prio(void) +{ +return true; +} +#endif +#endif +static inline int task_node (const struct task_struct *p) {return cpu_to_node (task_cpu (p));
kernel/sched/fair.c +49 -18
129 lines not on this page · raw message
kernel/sched/sched.h +10 -0
@@ -2241,12 +2241,22 @@ DECLARE_PER_CPU(struct sched_domain __rcu *, sd_asym_cpucapacity);extern struct static_key_false sched_asym_cpucapacity;extern struct static_key_false sched_cluster_active; +DECLARE_STATIC_KEY_FALSE (sched_idle_smt_prio); static __always_inline bool sched_asym_cpucap_active(void) {return static_branch_unlikely (&sched_asym_cpucapacity); } +static __always_inline bool sched_idle_smt_prio_active(void) +{ +#ifdef CONFIG_SCHED_IDLE_SMT_PRIO +return static_branch_unlikely (&sched_idle_smt_prio); +#else +return false; +#endif +} +struct sched_group_capacity {atomic_t ref;/*
kernel/sched/topology.c +17 -0
@@ -684,6 +684,7 @@ DEFINE_PER_CPU(struct sched_domain __rcu *, sd_asym_cpucapacity);DEFINE_STATIC_KEY_FALSE (sched_asym_cpucapacity);DEFINE_STATIC_KEY_FALSE (sched_cluster_active); +DEFINE_STATIC_KEY_FALSE (sched_idle_smt_prio);static void update_top_cache_domain (int cpu) {
@@ -1559,6 +1560,21 @@ build_sched_groups(struct sched_domain *sd, int cpu)return 0 ; } +#ifdef CONFIG_SCHED_IDLE_SMT_PRIO +static void sched_set_idle_smt_prio (int asym_detected) +{ +bool smt_prio; + + smt_prio =arch_needs_idle_smt_prio () && asym_detected; +if (smt_prio && !sched_idle_smt_prio_active ()) +static_branch_enable_cpuslocked (&sched_idle_smt_prio); +else if (!smt_prio &&sched_idle_smt_prio_active ()) +static_branch_disable_cpuslocked (&sched_idle_smt_prio); +} +#else +static void sched_set_idle_smt_prio (int asym_detected) {} +#endif +/* * Initialize sched groups cpu_capacity. *
@@ -1769,6 +1785,7 @@ static void asym_cpu_capacity_scan(void) } } +sched_set_idle_smt_prio (!list_is_singular (&asym_cap_list));/* * Only one capacity value has been detected i.e. this system is symmetric. * No need to keep this data around.
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 1/2] kernel/sched: Introduce idle SMT priority
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] sched: Unintended loss of SMT balancing within same-capacity clusters during wakeup --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] sched: Unintended loss of SMT balancing within same-capacity clusters during wakeup --
commit e7b6978e87f4966f837633079b0ad5b78914e3c2
Author: Mete Durlu <[email protected]>
kernel/sched: Introduce idle SMT priority
On systems with asymmetric CPU capacities and SMT, this patch introduces SCHED_IDLE_SMT_PRIO to allow architectures to prefer idle SMT siblings of busy high-capacity cores over fully idle low-capacity cores.
Quoted 11 lines
kernel/sched/fair.c +0
-3@@ -8813,11 +8813,14 @@ static int select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) {/* -* On !SMT systems, has_idle_core is always false and preferred_core -* is always true (CPU == core), so the SMT preference logic below -* collapses to the plain capacity scan.
kernel/sched/fair.c static int · line 8823
Quoted 10 lines
kernel/sched/fair.c +8
-2-*/ -bool has_idle_core =sched_smt_active () &&test_idle_cores (target); +* On !SMT systems or when idle SMT thread priority is active, +* has_idle_core is always false and preferred_core is always true +* (CPU == core), so the SMT preference logic below collapses to the +* plain capacity scan. +*/ +bool has_idle_core =sched_smt_active () && + !sched_idle_smt_prio_active () && +test_idle_cores (target);
[Severity: High]
By unconditionally setting has_idle_core to false here when sched_idle_smt_prio_active() is true, does this bypass idle core detection system-wide for all capacities?
[ ... ]
kernel/sched/fair.c select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) · line 8870
Quoted 11 lines
kernel/sched/fair.c +2
-2@@ -8860,8 +8863,8 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)/* * Perfect fit: capacity satisfies util + uclamp and the CPU -* sits on a fully-idle SMT core, this is a !SMT system, or -* there is no idle core to find. +* sits on a fully-idle SMT core, this is a !SMT system, idle +* smt priority is active, or there is no idle core to find. * Short-circuit the rank-based selection and return * immediately. */
[Severity: High]
Since has_idle_core is now false, preferred_core will evaluate to true for all CPUs scanned.
Could this cause the loop below:
if (fits > 0 && preferred_core)
return cpu;to short-circuit prematurely and return an idle SMT thread of a busy core, failing to scan for fully idle cores of the identical capacity? This appears to lead to an unintended loss of SMT balancing within same-capacity clusters during wakeup.
[ ... ]
Quoted 10 lines
kernel/sched/fair.c +2
-2@@ -8936,15 +8939,17 @@ static inline bool asym_fits_cpu(unsigned long util,* Return true only if the cpu fully fits the task requirements * which include the utilization and the performance hints. * -* When SMT is active, also require that the core has no busy -* siblings. +* When SMT is active or idle SMT priority is disabled, also +* require that the core has no busy siblings. * * Note: gating on is_core_idle() also makes the early-bailout
kernel/sched/fair.c static inline bool asym_fits_cpu(unsigned long util, · line 8954
Quoted 10 lines
kernel/sched/fair.c +3
-1* candidates in select_idle_sibling() (target, prev, * recent_used_cpu) idle-core-aware on ASYM+SMT, which the * NO_ASYM path does not do. */ -return (!sched_smt_active () ||is_core_idle (cpu)) && +return (!sched_smt_active () || +sched_idle_smt_prio_active () || +is_core_idle (cpu)) && (util_fits_cpu (util, util_min, util_max, cpu) >0 ); }
[Severity: High]
Does bypassing the is_core_idle() check here when sched_idle_smt_prio_active() is true inadvertently allow the early-bailout candidates (target, prev, recent_used_cpu) to further exacerbate same-capacity SMT packing?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
RFC PATCH 2/2 s390/topology: Enable SCHED_IDLE_SMT_PRIO
In reply to Mete DurluOn s390, vertical polarization configuration assigns CPUs different polarization values and capacities. These capacities represent the virtual runtime being assigned to the shared CPUs by the underlying hypervisor. Consequently running load on high capacity cores, even if the SMT sibling (SMT=2 on s390) of a given core is busy is more favorable compared to a fully idle low capacity CPU.
Implement arch_needs_idle_smt_prio() to enable the sched_idle_smt_prio static branch when the machine has hardware backed topology.
--- arch/s390/Kconfig | 1 + arch/s390/include/asm/topology.h | 5 +++++ arch/s390/kernel/topology.c | 9 +++++++++ 3 files changed, 15 insertions(+)
arch/s390/Kconfig +1 -0
@@ -564,6 +564,7 @@ config NODES_SHIFT config SCHED_TOPOLOGY def_bool y prompt "Topology scheduler support" + select ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO select ARCH_SUPPORTS_SCHED_SMT select ARCH_SUPPORTS_SCHED_MC select SCHED_SMT
arch/s390/include/asm/topology.h +5 -0
@@ -49,6 +49,11 @@ void update_cpu_masks(void);void topology_expect_change (void );const struct cpumask *cpu_coregroup_mask (int cpu); +#ifdef CONFIG_SCHED_IDLE_SMT_PRIO +#define arch_needs_idle_smt_prio arch_needs_idle_smt_prio +bool arch_needs_idle_smt_prio (void ); +#endif +#else /* CONFIG_SCHED_TOPOLOGY */ static inline void topology_init_early (void ) { }
arch/s390/kernel/topology.c +9 -0
@@ -344,6 +344,15 @@ int arch_update_cpu_topology(void)return rc; } +#ifdef CONFIG_SCHED_IDLE_SMT_PRIO +bool arch_needs_idle_smt_prio (void ) +{ +if (topology_mode !=TOPOLOGY_MODE_HW ) +return false; +return true; +} +#endif +static void topology_work_fn (struct work_struct *work) {rebuild_sched_domains ();
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 2/2] s390/topology: Enable SCHED_IDLE_SMT_PRIO
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
On s390, vertical polarization configuration assigns CPUs different polarization values and capacities. These capacities represent the virtual runtime being assigned to the shared CPUs by the underlying hypervisor. Consequently running load on high capacity cores, even if the SMT sibling (SMT=2 on s390) of a given core is busy is more favorable compared to a fully idle low capacity CPU.
Implement
arch_needs_idle_smt_prio()to enable thesched_idle_smt_priostatic branch when the machine has hardware backed topology.Signed-off-by Mete Durlu <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Hi Mete,
Quoted 79 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle cores over idle SMT siblings of busy cores. This works generally well but virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.Background
===========================================================================
The scheduler has been moving toward better utilization of fully idle cores and avoiding SMT penalties. This trend (notably after commit25a32e400a14("sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection") broke the behavior s390 is relying on to concentrate workloads on its high-capacity cores. On s390 CPU capacities represent the CPUs runtime entitlement assigned by the hypervisor. The idle SMT siblings of busy high-capacity cores start to perform better than fully idle low-capacity cores as the whole machine(containing the logical partitions) starts approaching to a {fully,over}loaded state. Grouping load on high-capacity cores keeps shared low-capacity cores(which are shared more aggressively) idle longer, reducing noise to neighboring partitions and improving overall performance.Approach
===========================================================================
This series introducesSCHED_IDLE_SMT_PRIOconfig option and thesched_idle_smt_priostatic branch, allowing architectures to treat idle SMT siblings of busy cores as equal candidates during asymmetric capacity load balancing.
Static branch checks are placed at paths considering fully idle cores over idle SMT threads in presence of asymmetric CPU capacities within scheduling groups. Inserted checks mostly override hints for idle core selection or cause early exits favoring idle SMT siblings. One more static branch check is added to new task path in order to favor high capacity SMT siblings during initial task placement, therefore the tasks are immediately placed in high capacity SMT siblings instead of considering most idle but low capacity cores.Architectures opt in by selecting
ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIOand implementingarch_needs_idle_smt_prio(), which is evaluated during eachasym_cpu_capacity_scan()to track the state as runtime topology changes.The second patch enables the feature for s390 when running on hardware-backed topology in an LPAR with vertical polarization active and system is approaching to a target state.
Otherwise the branch stays disabled and the scheduler falls back to the standard idle-core preference.No functional change on architectures that do not select
ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO.Performance Results
===========================================================================
Since this change effects the {fully,over}loaded state it is difficult to test at the moment. Therefore there are no concrete numbers or metrics for now for s390.
For architectures which do not opt in to this feature, no performance change is expected.Considerations and Open Questions
===========================================================================
The main goal for this series is adding a simple mechanism for architectures to switch between idle core and idle SMT priority while keeping the introduced footprint as small as possible. But there are some ideas and questions to consider;1. Should
arch_needs_idle_smt_prio()hook be removed?
The architecture hook is there to allow for any sort of logic to dynamically decide when to flip the mechanism, but it can also be removed if everyone agrees that this behaviour is not something that should be dynamically flipped. It can be simply tied to detection of asymmetric capacities and selection ofKconfigoption.2. Is there a simpler way to implement this mechanism?
The proposed approach is chosen as the other features effecting the scheduler's behavior, use the same method. If there is a more efficient way to implement the same mechanism I'd be glad to use that instead.
Quoted 6 lines
3. There are no performance measurements *yet*.
On s390 the ideal conditions for this mechanism to be beneficial usually surface when the whole system is fully loaded and resource sharing between the logical partitions starts to get expensive. Creating such an environment requires time, therefore no benchmark results are available yet.
I'm wondering if we could build on Shrikanth's cpu_preferred_mask infrastructure to express a "soft preference" for the s390 higher-entitlement CPUs. Unlike the mask's current behavior, soft preference would allow tasks to spill onto other CPUs once the preferred CPUs have no idle threads available (we have something like this in sched_ext's scx_cosmos).
That might let us preserve the general preference for fully idle SMT cores while searching in this order: fully idle preferred cores, idle SMT threads on preferred cores, then non-preferred cores. This current patch series seems to drop the first distinction, allowing a partially idle preferred core to win even when another preferred core is fully idle.
This would need to coexist with the steal governor's stronger use of cpu_preferred_mask, so I'm suggesting it as a potential direction to explore rather than a drop-in replacement.
What do you think (Mete / Shrikanth)?
Thanks,
-Andrea
Hi Meter/Andrea.
Quoted 10 lines · Andrea Righi
Hi Mete,
Quoted 7 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle cores over idle SMT siblings of busy cores. This works generally well but virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.
That's true only under physical CPU contention right? or is it always?
Quoted 72 lines
Quoted 72 lines
Background
===========================================================================
The scheduler has been moving toward better utilization of fully idle cores and avoiding SMT penalties. This trend (notably after commit25a32e400a14("sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection") broke the behavior s390 is relying on to concentrate workloads on its high-capacity cores. On s390 CPU capacities represent the CPUs runtime entitlement assigned by the hypervisor. The idle SMT siblings of busy high-capacity cores start to perform better than fully idle low-capacity cores as the whole machine(containing the logical partitions) starts approaching to a {fully,over}loaded state. Grouping load on high-capacity cores keeps shared low-capacity cores(which are shared more aggressively) idle longer, reducing noise to neighboring partitions and improving overall performance.Approach
===========================================================================
This series introducesSCHED_IDLE_SMT_PRIOconfig option and thesched_idle_smt_priostatic branch, allowing architectures to treat idle SMT siblings of busy cores as equal candidates during asymmetric capacity load balancing.
Static branch checks are placed at paths considering fully idle cores over idle SMT threads in presence of asymmetric CPU capacities within scheduling groups. Inserted checks mostly override hints for idle core selection or cause early exits favoring idle SMT siblings. One more static branch check is added to new task path in order to favor high capacity SMT siblings during initial task placement, therefore the tasks are immediately placed in high capacity SMT siblings instead of considering most idle but low capacity cores.Architectures opt in by selecting
ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIOand implementingarch_needs_idle_smt_prio(), which is evaluated during eachasym_cpu_capacity_scan()to track the state as runtime topology changes.The second patch enables the feature for s390 when running on hardware-backed topology in an LPAR with vertical polarization active and system is approaching to a target state.
Otherwise the branch stays disabled and the scheduler falls back to the standard idle-core preference.No functional change on architectures that do not select
ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO.Performance Results
===========================================================================
Since this change effects the {fully,over}loaded state it is difficult to test at the moment. Therefore there are no concrete numbers or metrics for now for s390.
For architectures which do not opt in to this feature, no performance change is expected.Considerations and Open Questions
===========================================================================
The main goal for this series is adding a simple mechanism for architectures to switch between idle core and idle SMT priority while keeping the introduced footprint as small as possible. But there are some ideas and questions to consider;1. Should
arch_needs_idle_smt_prio()hook be removed?
The architecture hook is there to allow for any sort of logic to dynamically decide when to flip the mechanism, but it can also be removed if everyone agrees that this behaviour is not something that should be dynamically flipped. It can be simply tied to detection of asymmetric capacities and selection ofKconfigoption.2. Is there a simpler way to implement this mechanism?
The proposed approach is chosen as the other features effecting the scheduler's behavior, use the same method. If there is a more efficient way to implement the same mechanism I'd be glad to use that instead.
Quoted 6 lines
Quoted 6 lines
3. There are no performance measurements *yet*.
On s390 the ideal conditions for this mechanism to be beneficial usually surface when the whole system is fully loaded and resource sharing between the logical partitions starts to get expensive. Creating such an environment requires time, therefore no benchmark results are available yet.
If it only under contention, then you probably don't want to use low cores for anything right? If above is yes, then using steal governor would help to avoid low core if you mark them as non-preferred. (which i guess you guys are exploring already)
But, find_new_ilb isn't aware of preferred CPU state as of initial patches.
I had thought of making a change to pick a idle preferred CPU instead of a idle non-preferred core for idle load balancing. It is not done due to below reasons.
- Performance numbers didn't show any major improvements with real life workloads.
- Code becomes quite complex for find_new_ilb.
Quoted 7 lines
I'm wondering if we could build on Shrikanth's
cpu_preferred_maskinfrastructure to express a "soft preference" for the s390 higher-entitlement CPUs. Unlike the mask's current behavior, soft preference would allow tasks to spill onto other CPUs once the preferred CPUs have no idle threads available (we have something like this in sched_ext'sscx_cosmos).
cpu_preferred infra won't allow to spill over if preferred CPUs don't have an idle CPU. It rather enforces packing onto preferred CPUs even if it means rq has more than 1 task.
Quoted 14 lines
That might let us preserve the general preference for fully idle SMT cores while searching in this order: fully idle preferred cores, idle SMT threads on preferred cores, then non-preferred cores. This current patch series seems to drop the first distinction, allowing a partially idle preferred core to win even when another preferred core is fully idle.
This would need to coexist with the steal governor's stronger use of
cpu_preferred_mask, so I'm suggesting it as a potential direction to explore rather than a drop-in replacement.What do you think (Mete / Shrikanth)?
Thanks,
-Andrea
Quoted 14 lines · Shrikanth Hegde
Hi Meter/Andrea.
Quoted 10 lines · Andrea Righi
Hi Mete,
Quoted 7 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle cores over idle SMT siblings of busy cores. This works generally well but virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.
Quoted 1 line
That's true only under physical CPU contention right? or is it always?
Right, because of that s390 treats all CPUs as equal and starts to assign lower capacities to CPUs with low entitlement once a certain steal time threshold is crossed (aka physical CPU contention).
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Background
===========================================================================
The scheduler has been moving toward better utilization of fully idle cores and avoiding SMT penalties. This trend (notably after commit25a32e400a14("sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection") broke the behavior s390 is relying on to concentrate workloads on its high-capacity cores. On s390 CPU capacities represent the CPUs runtime entitlement assigned by the hypervisor. The idle SMT siblings of busy high-capacity cores start to perform better than fully idle low-capacity cores as the whole machine(containing the logical partitions) starts approaching to a {fully,over}loaded state. Grouping load on high- capacity cores keeps shared low-capacity cores(which are shared more aggressively) idle longer, reducing noise to neighboring partitions and improving overall performance.
[...snip...]
Quoted 27 lines
Quoted 20 lines
Quoted 20 lines
Considerations and Open Questions
===========================================================================
The main goal for this series is adding a simple mechanism for architectures to switch between idle core and idle SMT priority while keeping the introduced footprint as small as possible. But there are some ideas and questions to consider;1. Should
arch_needs_idle_smt_prio()hook be removed?
The architecture hook is there to allow for any sort of logic to dynamically decide when to flip the mechanism, but it can also be removed if everyone agrees that this behaviour is not something that should be dynamically flipped. It can be simply tied to detection of asymmetric capacities and selection ofKconfigoption.2. Is there a simpler way to implement this mechanism?
The proposed approach is chosen as the other features effecting the scheduler's behavior, use the same method. If there is a more efficient way to implement the same mechanism I'd be glad to use that instead.Quoted 6 lines
Quoted 6 lines
3. There are no performance measurements *yet*.
On s390 the ideal conditions for this mechanism to be beneficial usually surface when the whole system is fully loaded and resource sharing between the logical partitions starts to get expensive. Creating such an environment requires time, therefore no benchmark results are available yet.
Quoted 3 lines
If it only under contention, then you probably don't want to use low cores for anything right? If above is yes, then using steal governor would help to avoid low core if you mark them as non-preferred. (which i guess you guys are exploring already)
IMO it should be dynamically adjustable depending on the contention level. But yes, on worst case low capacity cores should be avoided by marking them as non-preferred.
Quoted 6 lines
But,
find_new_ilbisn't aware of preferred CPU state as of initial patches.
I had thought of making a change to pick a idle preferred CPU instead of a idle non-preferred core for idle load balancing. It is not done due to below reasons.
- Performance numbers didn't show any major improvements with real life workloads.
- Code becomes quite complex forfind_new_ilb.
IIUC, find_new_ilb() finds an idle CPU that can do load balancing for other idle CPUs. As long as the tasks don't land on non-preferred CPUs, where ilb occurs should not matter. (At least for s390)
Quoted 10 lines
Quoted 7 lines
I'm wondering if we could build on Shrikanth's
cpu_preferred_maskinfrastructure to express a "soft preference" for the s390 higher-entitlement CPUs. Unlike the mask's current behavior, soft preference would allow tasks to spill onto other CPUs once the preferred CPUs have no idle threads available (we have something like this in sched_ext'sscx_cosmos).
cpu_preferredinfra won't allow to spill over if preferred CPUs don't have an idle CPU. It rather enforces packing onto preferred CPUs even if it means rq has more than 1 task.
I think what Andrea has in mind is something similar to what he did with select_idle_capacity(). Depending on the state of the non-preferred mask and other factors cores and SMT siblings can be evaluated as ideal candidate somehow. Wouldn't it be possible to extend the infrastructure you introduced to achieve this?
Quoted 9 lines
Quoted 9 lines
That might let us preserve the general preference for fully idle SMT cores while searching in this order: fully idle preferred cores, idle SMT threads on preferred cores, then non-preferred cores. This current patch series seems to drop the first distinction, allowing a partially idle preferred core to win even when another preferred core is fully idle.
This would need to coexist with the steal governor's stronger use of
cpu_preferred_mask, so I'm suggesting it as a potential direction to explore rather than a drop-in replacement.
I think this makes a lot of sense. An approach to first fill preferred CPUs before spilling to the non-preferred cores until contention forces the evacuation of non-prefered CPUs.
Shrikanth, would it make sense if I try to find a way to extend your current implementation in this way?
Thanks!
-Mete
Hi Mete.
Quoted 81 lines · Mete Durlu
Quoted 14 lines · Shrikanth Hegde
Hi Meter/Andrea.
Quoted 10 lines · Andrea Righi
Hi Mete,
Quoted 7 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle cores over idle SMT siblings of busy cores. This works generally well but virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.Quoted 1 line
That's true only under physical CPU contention right? or is it always?
Right, because of that s390 treats all CPUs as equal and starts to assign lower capacities to CPUs with low entitlement once a certain steal time threshold is crossed (aka physical CPU contention).
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Background
===========================================================================
The scheduler has been moving toward better utilization of fully idle cores and avoiding SMT penalties. This trend (notably after commit25a32e400a14("sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection") broke the behavior s390 is relying on to concentrate workloads on its high-capacity cores. On s390 CPU capacities represent the CPUs runtime entitlement assigned by the hypervisor. The idle SMT siblings of busy high-capacity cores start to perform better than fully idle low-capacity cores as the whole machine(containing the logical partitions) starts approaching to a {fully,over}loaded state. Grouping load on high- capacity cores keeps shared low-capacity cores(which are shared more aggressively) idle longer, reducing noise to neighboring partitions and improving overall performance.[...snip...]
Quoted 27 lines
Quoted 20 lines
Quoted 20 lines
Considerations and Open Questions
===========================================================================
The main goal for this series is adding a simple mechanism for architectures to switch between idle core and idle SMT priority while keeping the introduced footprint as small as possible. But there are some ideas and questions to consider;1. Should
arch_needs_idle_smt_prio()hook be removed?
The architecture hook is there to allow for any sort of logic to dynamically decide when to flip the mechanism, but it can also be removed if everyone agrees that this behaviour is not something that should be dynamically flipped. It can be simply tied to detection of asymmetric capacities and selection ofKconfigoption.2. Is there a simpler way to implement this mechanism?
The proposed approach is chosen as the other features effecting the scheduler's behavior, use the same method. If there is a more efficient way to implement the same mechanism I'd be glad to use that instead.Quoted 6 lines
Quoted 6 lines
3. There are no performance measurements *yet*.
On s390 the ideal conditions for this mechanism to be beneficial usually surface when the whole system is fully loaded and resource sharing between the logical partitions starts to get expensive. Creating such an environment requires time, therefore no benchmark results are available yet.Quoted 3 lines
If it only under contention, then you probably don't want to use low cores for anything right? If above is yes, then using steal governor would help to avoid low core if you mark them as non-preferred. (which i guess you guys are exploring already)
IMO it should be dynamically adjustable depending on the contention level. But yes, on worst case low capacity cores should be avoided by marking them as non-preferred.
Quoted 5 lines
But,
find_new_ilbisn't aware of preferred CPU state as of initial patches.
I had thought of making a change to pick a idle preferred CPU instead of a idle non-preferred core for idle load balancing. It is not done due to below reasons.
- Performance numbers didn't show any major improvements with real life workloads.
- Code becomes quite complex forfind_new_ilb.
Quoted 4 lines
IIUC,
find_new_ilb()finds an idle CPU that can do load balancing for other idle CPUs. As long as the tasks don't land on non-preferred CPUs, where ilb occurs should not matter. (At least for s390)
If that is what you want, then steal governor is the right choice.
Even if idle load balancing runs on a non-preferred idle CPU, it is going to do the idle load balancing for all the idle CPUs. Including preferred and non-preferred. And actual load balancing bails out early and does not pull any task towards if it is a non-preferred CPU.
Quoted 23 lines
Quoted 10 lines
Quoted 7 lines
I'm wondering if we could build on Shrikanth's
cpu_preferred_maskinfrastructure to express a "soft preference" for the s390 higher-entitlement CPUs. Unlike the mask's current behavior, soft preference would allow tasks to spill onto other CPUs once the preferred CPUs have no idle threads available (we have something like this in sched_ext'sscx_cosmos).
cpu_preferredinfra won't allow to spill over if preferred CPUs don't have an idle CPU. It rather enforces packing onto preferred CPUs even if it means rq has more than 1 task.I think what Andrea has in mind is something similar to what he did with
select_idle_capacity(). Depending on the state of the non-preferred mask and other factors cores and SMT siblings can be evaluated as ideal candidate somehow. Wouldn't it be possible to extend the infrastructure you introduced to achieve this?Quoted 6 lines
Quoted 6 lines
That might let us preserve the general preference for fully idle SMT cores while searching in this order: fully idle preferred cores, idle SMT threads on preferred cores, then non-preferred cores. This current patch series seems to drop the first distinction, allowing a partially idle preferred core to win even when another preferred core is fully idle.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
This would need to coexist with the steal governor's stronger use of
cpu_preferred_mask, so I'm suggesting it as a potential direction to explore rather than a drop-in replacement.I think this makes a lot of sense. An approach to first fill preferred CPUs before spilling to the non-preferred cores until contention forces the evacuation of non-prefered CPUs.
Well, when we see steal time, it usually means there is high contention and we are using more vCPUs at this moment than possible.
So we mark them as non-preferred. Note that they are idle cpus. But non-preferred.
That means preferred CPUs may have more than 1 task. If we spill over if there is idle non-preferred CPUs, we will be back to square one. No?
Quoted 6 lines
Shrikanth, would it make sense if I try to find a way to extend your current implementation in this way?
Thanks!
-Mete
On Thu, Oct 08, 2026 at 09:14:49PM +0530, Shrikanth Hegde wrote:
...
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
That might let us preserve the general preference for fully idle SMT cores while searching in this order: fully idle preferred cores, idle SMT threads on preferred cores, then non-preferred cores. This current patch series seems to drop the first distinction, allowing a partially idle preferred core to win even when another preferred core is fully idle.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
This would need to coexist with the steal governor's stronger use of
cpu_preferred_mask, so I'm suggesting it as a potential direction to explore rather than a drop-in replacement.I think this makes a lot of sense. An approach to first fill preferred CPUs before spilling to the non-preferred cores until contention forces the evacuation of non-prefered CPUs.
Quoted 6 lines
Well, when we see steal time, it usually means there is high contention and we are using more vCPUs at this moment than possible.
So we mark them as non-preferred. Note that they are idle cpus. But non-preferred.That means preferred CPUs may have more than 1 task. If we spill over if there is idle non-preferred CPUs, we will be back to square one. No?
I agree that CPUs excluded by the steal governor should remain avoided even when all preferred CPUs are busy.
I'm wondering if we should have two levels: cpu_preferred_mask acting as a hard affinity constraint and an entitlement-based soft affinity within that mask? The soft affinity would prefer high-entitlement CPUs: first fully idle cores, then idle SMT siblings. Once those CPUs are busy, tasks could spill onto lower-entitlement CPUs still inside cpu_preferred_mask, again preferring fully idle cores over idle SMT siblings. If all CPUs inside cpu_preferred_mask are busy, tasks would queue there. The soft affinity would never override the governor's restriction by spilling onto CPUs it excluded due to contention.
Thanks,
-Andrea
Quoted 20 lines · Andrea Righi
On Thu, Oct 08, 2026 at 09:14:49PM +0530, Shrikanth Hegde wrote:
...Quoted 18 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
That might let us preserve the general preference for fully idle SMT cores while searching in this order: fully idle preferred cores, idle SMT threads on preferred cores, then non-preferred cores. This current patch series seems to drop the first distinction, allowing a partially idle preferred core to win even when another preferred core is fully idle.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
This would need to coexist with the steal governor's stronger use of
cpu_preferred_mask, so I'm suggesting it as a potential direction to explore rather than a drop-in replacement.I think this makes a lot of sense. An approach to first fill preferred CPUs before spilling to the non-preferred cores until contention forces the evacuation of non-prefered CPUs.
Well, when we see steal time, it usually means there is high contention and we are using more vCPUs at this moment than possible.
So we mark them as non-preferred. Note that they are idle cpus. But non-preferred.
Quoted 8 lines
Quoted 2 lines
That means preferred CPUs may have more than 1 task. If we spill over if there is idle non-preferred CPUs, we will be back to square one. No?
I agree that CPUs excluded by the steal governor should remain avoided even when all preferred CPUs are busy.
I'm wondering if we should have two levels:
cpu_preferred_maskacting as a hard affinity constraint and an entitlement-based soft affinity within that mask? The
That not what entitlement usually means. At least not PowerVM. when one creates VM, they assign VP=Virtual Cores and EC=Entitled Cores. and Hypervisor ensure at least EC worth of cores are always assigned to that VM. There is no need of priority within that entitlement.
Quoted 2 lines
soft affinity would prefer high-entitlement CPUs: first fully idle cores, then idle SMT siblings. Once those CPUs are busy, tasks could spill onto
I think when one has high steal time and hence reduced preferred CPUs, there will likely be no fully idle cores within preferred CPUs.
Note that current logic takes out last set of CPUs and find_new_ilb iterates from the beginning. So if there is idle core within the preferred CPUs, it will be chosen.
Quoted 5 lines
lower-entitlement CPUs still inside
cpu_preferred_mask, again preferring fully idle cores over idle SMT siblings. If all CPUs insidecpu_preferred_maskare busy, tasks would queue there. The soft affinity would never override the governor's restriction by spilling onto CPUs it excluded due to contention.
As we were discussing, as long as threads don't end up on non-preferred CPUs, we might be okay. With the above, find_new_ilb will becomes very complex IMHO and I am not sure if it is worth it.
likely what we need is,
- Fully idle preferred Core.
- idle preferred CPU.
- any idle CPU.
Hi,
sorry for the late reply, I have been sick since Friday. I though about what has been written for a bit.
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Well, when we see steal time, it usually means there is high contention and we are using more vCPUs at this moment than possible.
So we mark them as non-preferred. Note that they are idle cpus. But non-preferred.That means preferred CPUs may have more than 1 task. If we spill over if there is idle non-preferred CPUs, we will be back to square one. No?
I agree that CPUs excluded by the steal governor should remain avoided even when all preferred CPUs are busy.
Quoted 7 lines
Quoted 2 lines
I'm wondering if we should have two levels:
cpu_preferred_maskacting as a hard affinity constraint and an entitlement-based soft affinity within that mask? TheThat not what entitlement usually means. At least not PowerVM. when one creates VM, they assign VP=Virtual Cores and EC=Entitled Cores. and Hypervisor ensure at least EC worth of cores are always assigned to that VM. There is no need of priority within that entitlement.
Wouldn't it make sense to first fully load entitled cores before moving onto virtual cores on Power? On s390 we would definitely benefit from it on some cases.
Quoted 5 lines
Quoted 2 lines
soft affinity would prefer high-entitlement CPUs: first fully idle cores, then idle SMT siblings. Once those CPUs are busy, tasks could spill onto
I think when one has high steal time and hence reduced preferred CPUs, there will likely be no fully idle cores within preferred CPUs.
Shrikanth, wouldn't something like below still make sense?
Quoted 8 lines
Note that current logic takes out last set of CPUs and
find_new_ilbiterates from the beginning. So if there is idle core within the preferred CPUs, it will be chosen.Quoted 5 lines
lower-entitlement CPUs still inside
cpu_preferred_mask, again preferring fully idle cores over idle SMT siblings. If all CPUs insidecpu_preferred_maskare busy, tasks would queue there. The soft affinity would never override the governor's restriction by spilling onto CPUs it excluded due to contention.
Quoted 8 lines
As we were discussing, as long as threads don't end up on non-preferred CPUs, we might be okay. With the above,
find_new_ilbwill becomes very complex IMHO and I am not sure if it is worth it.likely what we need is,
- Fully idle preferred Core.
- idle preferred CPU.
- any idle CPU.
Andrea does this resemble what you were describing;
1-) (steal time == 0)
====================================================================cpu_preffered_mask = active_cpuscpu_soft_affinity = 0
All cpus are available for scheduler to pick and use. Idle cores are preferred in case of asymmetric capacities.
2-) (steal time > 0) && (steal time <= initial_threshold*)
====================================================================cpu_preffered_mask = active_cpus cpu_soft_affinity = entitled cpus
In this case entitled cores get fully filled (SMT siblings first) before spilling load onto the rest of the cpus on preferred mask. *Initial threshold is a value I just devised. Ideally arch specific and dynamically configurable, setting it to just 0 should also be an option.
3-) (steal time > initial_threshold)
====================================================================cpu_preffered_mask = entitled cpus + steal governor's modifications cpu_soft_affinity = entitled cpus
Carrying the logic from case 2 but shrinking the preferred mask according to the increased steal time value.
Shrikanth/Andrea,
does what I describe above make sense and would it make a reasonable addition to the vCPU backoff mechanism?
*Considering guests with hardware based topology and underlying hypervisor scheduling vCPUs per core;
I'd expect this approach to allow for guests having a smaller footprint for longer and steal time to start appearing later than usual as the entitled cores are fully utilized before touching other cores.
*This is the case for s390 for example. I am not sure if it is the same for Power or any other architecture.
Hi Mete.
Quoted 4 lines · Mete Durlu
Hi,
sorry for the late reply, I have been sick since Friday. I though about what has been written for a bit.
No issues. Take care.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 6 lines
Well, when we see steal time, it usually means there is high contention and we are using more vCPUs at this moment than possible.
So we mark them as non-preferred. Note that they are idle cpus. But non-preferred.That means preferred CPUs may have more than 1 task. If we spill over if there is idle non-preferred CPUs, we will be back to square one. No?
I agree that CPUs excluded by the steal governor should remain avoided even when all preferred CPUs are busy.
I'm wondering if we should have two levels:
cpu_preferred_maskacting as a hard affinity constraint and an entitlement-based soft affinity within that mask? The
Quoted 9 lines
Quoted 4 lines
That not what entitlement usually means. At least not PowerVM. when one creates VM, they assign VP=Virtual Cores and EC=Entitled Cores. and Hypervisor ensure at least EC worth of cores are always assigned to that VM. There is no need of priority within that entitlement.
Wouldn't it make sense to first fully load entitled cores before moving onto virtual cores on Power? On s390 we would definitely benefit from it on some cases.
Only when there is a high physical CPU contention.
Quoted 51 lines
Quoted 5 lines
Quoted 2 lines
soft affinity would prefer high-entitlement CPUs: first fully idle cores, then idle SMT siblings. Once those CPUs are busy, tasks could spill onto
I think when one has high steal time and hence reduced preferred CPUs, there will likely be no fully idle cores within preferred CPUs.
Shrikanth, wouldn't something like below still make sense?
Quoted 8 lines
Note that current logic takes out last set of CPUs and
find_new_ilbiterates from the beginning. So if there is idle core within the preferred CPUs, it will be chosen.Quoted 5 lines
lower-entitlement CPUs still inside
cpu_preferred_mask, again preferring fully idle cores over idle SMT siblings. If all CPUs insidecpu_preferred_maskare busy, tasks would queue there. The soft affinity would never override the governor's restriction by spilling onto CPUs it excluded due to contention.Quoted 8 lines
As we were discussing, as long as threads don't end up on non-preferred CPUs, we might be okay. With the above,
find_new_ilbwill becomes very complex IMHO and I am not sure if it is worth it.likely what we need is,
- Fully idle preferred Core.
- idle preferred CPU.
- any idle CPU.Andrea does this resemble what you were describing;
1-) (steal time == 0)
====================================================================cpu_preffered_mask=active_cpuscpu_soft_affinity= 0All cpus are available for scheduler to pick and use. Idle cores are preferred in case of asymmetric capacities.
2-) (steal time > 0) && (steal time <= initial_threshold*)
====================================================================cpu_preffered_mask=active_cpuscpu_soft_affinity= entitled cpusIn this case entitled cores get fully filled (SMT siblings first) before spilling load onto the rest of the cpus on preferred mask. *Initial threshold is a value I just devised. Ideally arch specific and dynamically configurable, setting it to just 0 should also be an option.
3-) (steal time >
initial_threshold)
====================================================================cpu_preffered_mask= entitled cpus + steal governor's modificationscpu_soft_affinity= entitled cpus
Quoted 7 lines
Carrying the logic from case 2 but shrinking the preferred mask according to the increased steal time value.
Shrikanth/Andrea,
does what I describe above make sense and would it make a reasonable addition to the vCPU backoff mechanism?
I am confused. Are you talking about
1. picking CPU to run idle load balancing?
Or
2. actual task placement decisions?
If it is 1, we should do only if there is any good improvement with real life workloads IMHO, as current find_new_ilb isn't aware of preferred CPUs. Even in that case just picking an idle preferred CPU over an idle non-preferred Core is better than above i think.
If it is 2, I am not sure. getting soft affinity is kind of tricky with load balance. It puts maximum effort in spreading the tasks. Since you have steal time, there is already enough tasks to create physical CPU contention.
PS: Steal governor provides a tunable named low_threshold, which means any steal value below is practically 0. So there is no soft affinity there.
Quoted 9 lines
*Considering guests with hardware based topology and underlying hypervisor scheduling vCPUs per core;
I'd expect this approach to allow for guests having a smaller footprint for longer and steal time to start appearing later than usual as the entitled cores are fully utilized before touching other cores.*This is the case for s390 for example. I am not sure if it is the same for Power or any other architecture.
[..snip..]
Quoted 34 lines
Quoted 26 lines
Andrea does this resemble what you were describing;
1-) (steal time == 0)
====================================================================cpu_preffered_mask=active_cpuscpu_soft_affinity= 0All cpus are available for scheduler to pick and use. Idle cores are preferred in case of asymmetric capacities.
2-) (steal time > 0) && (steal time <= initial_threshold*)
====================================================================cpu_preffered_mask=active_cpuscpu_soft_affinity= entitled cpusIn this case entitled cores get fully filled (SMT siblings first) before spilling load onto the rest of the cpus on preferred mask. *Initial threshold is a value I just devised. Ideally arch specific and dynamically configurable, setting it to just 0 should also be an option.
3-) (steal time >
initial_threshold)
====================================================================cpu_preffered_mask= entitled cpus + steal governor's modificationscpu_soft_affinity= entitled cpusQuoted 7 lines
Carrying the logic from case 2 but shrinking the preferred mask according to the increased steal time value.
Shrikanth/Andrea,
does what I describe above make sense and would it make a reasonable addition to the vCPU backoff mechanism?
Quoted 4 lines
I am confused. Are you talking about
1. picking CPU to run idle load balancing?
Or
2. actual task placement decisions?
I was talking about actual task placement decisions. I didn't really consider where idle load balancing should take place tbh. On s390 even if it takes place on a non-preferred CPU, there shouldn't be too much of a penalty. Is there a specific reason why you are asking for idle load balancing case? I might be missing some conceptual depth here.
[..snip..]
Quoted 3 lines
If it is 2, I am not sure. getting soft affinity is kind of tricky with load balance. It puts maximum effort in spreading the tasks. Since you have steal time, there is already enough tasks to create physical CPU contention.
I am not fully familiar with vCPU backoff yet, but couldn't the soft affinity be implemented in form of another cpu mask. We can traverse the new mask to make decisions there first and after its resources are depleted there, we can then move onto cpu_preferred_mask?
Quoted 2 lines
PS: Steal governor provides a tunable named
low_threshold, which means any steal value below is practically 0. So there is no soft affinity there.
Right, my initial instinct was to have an initial threshold like the low_threshold steal governor already has. I am not sure if it is a good idea to just use that with a higher default value but I need to think about this a bit more.
What do you think, does it worth exploring?
Thanks!
-Mete
Vincent Guittot
maintainerQuoted 18 lines · Mete Durlu
Quoted 16 lines · Shrikanth Hegde
Hi Meter/Andrea.
Quoted 12 lines · Andrea Righi
Hi Mete,
Quoted 9 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle
cores over idle SMT siblings of busy cores. This works generally well but
virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.
Quoted 5 lines
Quoted 1 line
That's true only under physical CPU contention right? or is it always?
Right, because of that s390 treats all CPUs as equal and starts to assign lower capacities to CPUs with low entitlement once a certain steal time threshold is crossed (aka physical CPU contention).
I'm not sure to get what your topology is because "if s390 treats all CPUs as equal" then you should never use select_idle_capacity() because their capacity should be fixed and equal and SD_ASYM_CPUCAPACITY_FULL never set.
If your hypervisor lowers the capacity once a certain threshold is crossed, we already account for the steal time in the scheduler with irq and remove it from the capacity available for tasks but the original capacity doesn't change.
Quoted 121 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Background
===========================================================================
The scheduler has been moving toward better utilization of fully idle cores
and avoiding SMT penalties. This trend (notably after commit25a32e400a14
("sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection")
broke the behavior s390 is relying on to concentrate workloads on its high-capacity cores. On s390 CPU capacities represent the CPUs runtime entitlement assigned by the hypervisor. The idle SMT siblings of busy high-capacity cores start to perform better than fully idle low-capacity cores as the whole machine(containing the logical partitions) starts approaching to a {fully,over}loaded state. Grouping load on high- capacity
cores keeps shared low-capacity cores(which are shared more aggressively)
idle longer, reducing noise to neighboring partitions and improving overall performance.[...snip...]
Quoted 27 lines
Quoted 20 lines
Quoted 20 lines
Considerations and Open Questions
===========================================================================
The main goal for this series is adding a simple mechanism for architectures to switch between idle core and idle SMT priority while keeping the introduced footprint as small as possible. But there are some ideas and questions to consider;1. Should
arch_needs_idle_smt_prio()hook be removed?
The architecture hook is there to allow for any sort of logic to dynamically decide when to flip the mechanism, but it can also be removed if everyone agrees that this behaviour is not something that should be dynamically flipped. It can be simply tied to detection of asymmetric capacities and selection ofKconfigoption.2. Is there a simpler way to implement this mechanism?
The proposed approach is chosen as the other features effecting the scheduler's behavior, use the same method. If there is a more efficient way to implement the same mechanism I'd be glad to use that instead.Quoted 6 lines
Quoted 6 lines
3. There are no performance measurements *yet*.
On s390 the ideal conditions for this mechanism to be beneficial usually surface when the whole system is fully loaded and resource sharing between the logical partitions starts to get expensive. Creating such an environment requires time, therefore no benchmark results are available yet.Quoted 6 lines
If it only under contention, then you probably don't want to use low cores for
anything right? If above is yes, then using steal governor would help to avoid low
core if you mark them as non-preferred. (which i guess you guys are exploring already)IMO it should be dynamically adjustable depending on the contention level. But yes, on worst case low capacity cores should be avoided by marking them as non-preferred.
Quoted 7 lines
But,
find_new_ilbisn't aware of preferred CPU state as of initial patches. I had thought of making a change to pick a idle preferred CPU instead of a idle non-preferred
core for idle load balancing. It is not done due to below reasons.
- Performance numbers didn't show any major improvements with real life workloads.
- Code becomes quite complex forfind_new_ilb.IIUC,
find_new_ilb()finds an idle CPU that can do load balancing for other idle CPUs. As long as the tasks don't land on non-preferred CPUs, where ilb occurs should not matter. (At least for s390)Quoted 12 lines
Quoted 11 lines
I'm wondering if we could build on Shrikanth's
cpu_preferred_maskinfrastructure
to express a "soft preference" for the s390 higher-entitlement CPUs. Unlike the
mask's current behavior, soft preference would allow tasks to spill onto other
CPUs once the preferred CPUs have no idle threads available (we have something
like this in sched_ext'sscx_cosmos).Quoted 4 lines
cpu_preferredinfra won't allow to spill over if preferred CPUs don't have an idle CPU.
It rather enforces packing onto preferred CPUs even if it means rq has more than 1 task.I think what Andrea has in mind is something similar to what he did with
select_idle_capacity(). Depending on the state of the non-preferred mask and other factors cores and SMT siblings can be evaluated as ideal candidate somehow. Wouldn't it be possible to extend the infrastructure you introduced to achieve this?Quoted 9 lines
Quoted 9 lines
That might let us preserve the general preference for fully idle SMT cores while
searching in this order: fully idle preferred cores, idle SMT threads on preferred cores, then non-preferred cores. This current patch series seems to
drop the first distinction, allowing a partially idle preferred core to win even
when another preferred core is fully idle.Quoted 4 lines
Quoted 4 lines
This would need to coexist with the steal governor's stronger use of
cpu_preferred_mask, so I'm suggesting it as a potential direction to explore
rather than a drop-in replacement.I think this makes a lot of sense. An approach to first fill preferred CPUs before spilling to the non-preferred cores until contention forces the evacuation of non-prefered CPUs.
Shrikanth, would it make sense if I try to find a way to extend your current implementation in this way?
Thanks!
-Mete
Quoted 19 lines · Vincent Guittot
Quoted 18 lines · Mete Durlu
Quoted 16 lines · Shrikanth Hegde
Hi Meter/Andrea.
Quoted 12 lines · Andrea Righi
Hi Mete,
Quoted 9 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle
cores over idle SMT siblings of busy cores. This works generally well but
virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
That's true only under physical CPU contention right? or is it always?
Right, because of that s390 treats all CPUs as equal and starts to assign lower capacities to CPUs with low entitlement once a certain steal time threshold is crossed (aka physical CPU contention).
Hi,
Sorry for causing a misunderstanding. I should have been more patient and detailed while writing my reply.
Quoted 4 lines
I'm not sure to get what your topology is because "if s390 treats all CPUs as equal" then you should never use
select_idle_capacity()because their capacity should be fixed and equal andSD_ASYM_CPUCAPACITY_FULLnever set.
On s390 the entitlement of the vCPUs are signified by an arch specific value we call polarization. We can tell which vCPUs are assigned high and low entitlement. This entitlement value tells us which vCPUs are prone to experience steal time first. Without any contention all vCPUs behave and perform *almost* the same(of course, we want some priority for CPUs with high entitlement).
Prior to experiencing steal time(it's what we use to determine contention) to get the most out of the system we assign all vCPUs the same capacities, making the system symmetric like you say. While there is no contention s390's vCPUs also perform better if fully idle cores are selected for task placement.
Quoted 4 lines
If your hypervisor lowers the capacity once a certain threshold is crossed, we already account for the steal time in the scheduler with irq and remove it from the capacity available for tasks but the original capacity doesn't change.
s390's linux implementation has a mechanism called hiperdispatch, that checks topology changes along with system steal time (and soon the total free capacity of the pyhsical machine) periodically and makes vCPU capacity adjustments accordingly.
After steal time starts ramping up and cross a certain threshold, we start assigning lower capacities to vCPUs with low entitlement to hint the scheduler that they should be avoided.
In this asymmetric configuration, utilizing low capacity but fully idle cores hurt performance. Instead packing the tasks first to SMT siblings of high capacity cores would give s390 a lot of benefit.
I hope that clears some of the fog that I unintentionally created.
[..snip..]
Vincent Guittot
maintainerQuoted 53 lines · Mete Durlu
Quoted 19 lines · Vincent Guittot
Quoted 18 lines · Mete Durlu
Quoted 16 lines · Shrikanth Hegde
Hi Meter/Andrea.
Quoted 12 lines · Andrea Righi
Hi Mete,
Quoted 9 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle
cores over idle SMT siblings of busy cores. This works generally well but
virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.Quoted 5 lines
Quoted 5 lines
Quoted 1 line
That's true only under physical CPU contention right? or is it always?
Right, because of that s390 treats all CPUs as equal and starts to assign lower capacities to CPUs with low entitlement once a certain steal time threshold is crossed (aka physical CPU contention).
Hi,
Sorry for causing a misunderstanding. I should have been more patient and detailed while writing my reply.Quoted 4 lines
I'm not sure to get what your topology is because "if s390 treats all CPUs as equal" then you should never use
select_idle_capacity()because their capacity should be fixed and equal andSD_ASYM_CPUCAPACITY_FULLnever set.On s390 the entitlement of the vCPUs are signified by an arch specific value we call polarization. We can tell which vCPUs are assigned high and low entitlement. This entitlement value tells us which vCPUs are prone to experience steal time first. Without any contention all vCPUs behave and perform *almost* the
same(of course, we want some priority for CPUs with high entitlement).Prior to experiencing steal time(it's what we use to determine contention) to get the most out of the system we assign all vCPUs the same capacities, making the system symmetric like you say. While there is no contention s390's vCPUs also perform better if fully idle cores are selected for task placement.
Quoted 4 lines
If your hypervisor lowers the capacity once a certain threshold is crossed, we already account for the steal time in the scheduler with irq and remove it from the capacity available for tasks but the original capacity doesn't change.
Quoted 8 lines
s390's linux implementation has a mechanism called hiperdispatch, that checks topology changes along with system steal time (and soon the total free capacity of the pyhsical machine) periodically and makes vCPU capacity adjustments accordingly.
After steal time starts ramping up and cross a certain threshold, we start assigning lower capacities to vCPUs with low entitlement to hint the scheduler that they should be avoided.
If all your vCPUs starts with the same capacity, you should not use asym_capacity or enabled it . What you describe above is system pressure (steal time or other) on your vCPU that change over time but not a capacity change. The value returned by arch_scale_cpu_capacity is not supposed to change at runtime or you need to rebuild the sched_domain topology. As an example, max_allowed_capacity does assume capacity fixed otherwise the misfit detection will sometimes fails.
What you describe really fit into the prefered core that Shrikanth Hegde has developped
Quoted 8 lines
In this asymmetric configuration, utilizing low capacity but fully idle cores hurt performance. Instead packing the tasks first to SMT siblings of high capacity cores would give s390 a lot of benefit.
I hope that clears some of the fog that I unintentionally created.
[..snip..]
Quoted 63 lines · Vincent Guittot
Quoted 53 lines · Mete Durlu
Quoted 19 lines · Vincent Guittot
Quoted 18 lines · Mete Durlu
Quoted 16 lines · Shrikanth Hegde
Hi Meter/Andrea.
Quoted 12 lines · Andrea Righi
Hi Mete,
Quoted 9 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle
cores over idle SMT siblings of busy cores. This works generally well but
virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.Quoted 5 lines
Quoted 5 lines
Quoted 1 line
That's true only under physical CPU contention right? or is it always?
Right, because of that s390 treats all CPUs as equal and starts to assign lower capacities to CPUs with low entitlement once a certain steal time threshold is crossed (aka physical CPU contention).
Hi,
Sorry for causing a misunderstanding. I should have been more patient and detailed while writing my reply.Quoted 4 lines
I'm not sure to get what your topology is because "if s390 treats all CPUs as equal" then you should never use
select_idle_capacity()because their capacity should be fixed and equal andSD_ASYM_CPUCAPACITY_FULLnever set.On s390 the entitlement of the vCPUs are signified by an arch specific value we call polarization. We can tell which vCPUs are assigned high and low entitlement. This entitlement value tells us which vCPUs are prone to experience steal time first. Without any contention all vCPUs behave and perform *almost* the
same(of course, we want some priority for CPUs with high entitlement).Prior to experiencing steal time(it's what we use to determine contention) to get the most out of the system we assign all vCPUs the same capacities, making the system symmetric like you say. While there is no contention s390's vCPUs also perform better if fully idle cores are selected for task placement.
Quoted 4 lines
If your hypervisor lowers the capacity once a certain threshold is crossed, we already account for the steal time in the scheduler with irq and remove it from the capacity available for tasks but the original capacity doesn't change.
Quoted 8 lines
s390's linux implementation has a mechanism called hiperdispatch, that checks topology changes along with system steal time (and soon the total free capacity of the pyhsical machine) periodically and makes vCPU capacity adjustments accordingly.
After steal time starts ramping up and cross a certain threshold, we start assigning lower capacities to vCPUs with low entitlement to hint the scheduler that they should be avoided.
Quoted 7 lines
If all your vCPUs starts with the same capacity, you should not use
asym_capacityor enabled it . What you describe above is system pressure (steal time or other) on your vCPU that change over time but not a capacity change. The value returned byarch_scale_cpu_capacityis not supposed to change at runtime or you need to rebuild thesched_domaintopology. As an example,max_allowed_capacitydoes assume capacity fixed otherwise the misfit detection will sometimes fails.
Exactly for that reason on s390 we do topology updates after capacity updates. Topology changes caused by the underlying hypervisor or the cpu capacity changes can get reflected without a problem via topology rebuilds. Without topology rebuild we wouldn't even get the correct SD_ flags to trigger asym_capacity behavior like you say.
Quoted 2 lines
What you describe really fit into the prefered core that Shrikanth Hegde has developped
I agree, but Shrikanth's solution can not bring some of the behavior changes required. cpu_preferred_mask can help direct task placement away from low capacity cores but idle core first approach still places tasks to fully idle low capacity cores. This patches proposal tries to move tasks first to the idle SMT siblings.
Consider the following;
On a system with 2 high capacity and 4 low capacity cpus. steal governor of vCPU backoff mechanism calculates 2 low capacity cpus should be taken off from the cpu_preferred_mask to decrease experienced steal time. cpu_preferred_mask has 2 high capacity and 2 low capacity cpus.
Current behavior tires to place tasks to fully idle cores first even if they are low capacity cores.
c0(high) c1(high) c2(low) c3(low) ...
-------------------------------------------
SMT 0 task task task task
SMT 1
With the proposal, the fully idle core preference is circumvented and the most fitting SMT thread is selected.
c0(high) c1(high) c2(low) c3(low) ...
-------------------------------------------
SMT 0 task task
SMT 1 task task
This is beneficial because at the time of contention(system pressure) low capacity cores could perform worse than SMT siblings of busy high capacity cores, even if there is not enough steal time for steal governor of Shrikanth's vCPU backoff to mark said low capacity cores as non-preferred.
Andrea came up with an idea to extend Shrikanth's mechanism further by adding a soft affinity to a selected set of CPUs. Task placement would first fully load these CPUs before spilling load onto rest of the CPUs on cpu_preferred_mask. That would help achieve the behavior I describe above if the soft affinity covers high capacity CPUs.
The discussion is still on going though. If Shrikanth thinks this is a worthwhile concept then I'd be glad to work on the implementation and provide the patches.
Hi Mete.
Quoted 88 lines · Mete Durlu
Quoted 63 lines · Vincent Guittot
Quoted 53 lines · Mete Durlu
Quoted 19 lines · Vincent Guittot
Quoted 18 lines · Mete Durlu
Quoted 16 lines · Shrikanth Hegde
Hi Meter/Andrea.
Quoted 12 lines · Andrea Righi
Hi Mete,
Quoted 9 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle
cores over idle SMT siblings of busy cores. This works generally well but
virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.Quoted 5 lines
Quoted 5 lines
Quoted 1 line
That's true only under physical CPU contention right? or is it always?
Right, because of that s390 treats all CPUs as equal and starts to assign lower capacities to CPUs with low entitlement once a certain steal time threshold is crossed (aka physical CPU contention).
Hi,
Sorry for causing a misunderstanding. I should have been more patient and detailed while writing my reply.Quoted 4 lines
I'm not sure to get what your topology is because "if s390 treats all CPUs as equal" then you should never use
select_idle_capacity()because their capacity should be fixed and equal andSD_ASYM_CPUCAPACITY_FULLnever set.On s390 the entitlement of the vCPUs are signified by an arch specific value we call polarization. We can tell which vCPUs are assigned high and low entitlement. This entitlement value tells us which vCPUs are prone to experience steal time first. Without any contention all vCPUs behave and perform *almost* the
same(of course, we want some priority for CPUs with high entitlement).Prior to experiencing steal time(it's what we use to determine contention) to get the most out of the system we assign all vCPUs the same capacities, making the system symmetric like you say. While there is no contention s390's vCPUs also perform better if fully idle cores are selected for task placement.
Quoted 4 lines
If your hypervisor lowers the capacity once a certain threshold is crossed, we already account for the steal time in the scheduler with irq and remove it from the capacity available for tasks but the original capacity doesn't change.
Quoted 8 lines
s390's linux implementation has a mechanism called hiperdispatch, that checks topology changes along with system steal time (and soon the total free capacity of the pyhsical machine) periodically and makes vCPU capacity adjustments accordingly.
After steal time starts ramping up and cross a certain threshold, we start assigning lower capacities to vCPUs with low entitlement to hint the scheduler that they should be avoided.
Quoted 7 lines
If all your vCPUs starts with the same capacity, you should not use
asym_capacityor enabled it . What you describe above is system pressure (steal time or other) on your vCPU that change over time but not a capacity change. The value returned byarch_scale_cpu_capacityis not supposed to change at runtime or you need to rebuild thesched_domaintopology. As an example,max_allowed_capacitydoes assume capacity fixed otherwise the misfit detection will sometimes fails.Exactly for that reason on s390 we do topology updates after capacity updates. Topology changes caused by the underlying hypervisor or the cpu capacity changes can get reflected without a problem via topology rebuilds. Without topology rebuild we wouldn't even get the correct
SD_flags to triggerasym_capacitybehavior like you say.Quoted 2 lines
What you describe really fit into the prefered core that Shrikanth Hegde has developped
I agree, but Shrikanth's solution can not bring some of the behavior changes required.
cpu_preferred_maskcan help direct task placement away from low capacity cores but idle core first approach still places tasks to fully idle low capacity cores. This patches proposal tries to move tasks first to the idle SMT siblings.
Quoted 6 lines
Consider the following;
On a system with 2 high capacity and 4 low capacity cpus. steal governor of vCPU backoff mechanism calculates 2 low capacity cpus should be taken off from thecpu_preferred_maskto decrease experienced steal time.cpu_preferred_maskhas 2 high capacity and 2 low capacity cpus.
In this scenario, do you still have reasonable steal time or no?
Quoted 18 lines
Current behavior tires to place tasks to fully idle cores first even if they are low capacity cores.
c0(high) c1(high) c2(low) c3(low) ...
-------------------------------------------
SMT 0 task task task task
SMT 1With the proposal, the fully idle core preference is circumvented and the most fitting SMT thread is selected.
c0(high) c1(high) c2(low) c3(low) ...
-------------------------------------------
SMT 0 task task
SMT 1 task task
Quoted 6 lines
This is beneficial because at the time of contention(system pressure) low capacity cores could perform worse than SMT siblings of busy high capacity cores, even if there is not enough steal time for steal governor of Shrikanth's vCPU backoff to mark said low capacity cores as non-preferred.
I read this as tunable problem of low,high thresholds to adjust preferred_mask same as high capacity cores. No?
Quoted 10 lines
Andrea came up with an idea to extend Shrikanth's mechanism further by adding a soft affinity to a selected set of CPUs. Task placement would first fully load these CPUs before spilling load onto rest of the CPUs on
cpu_preferred_mask. That would help achieve the behavior I describe above if the soft affinity covers high capacity CPUs.The discussion is still on going though. If Shrikanth thinks this is a worthwhile concept then I'd be glad to work on the implementation and provide the patches.
What i don't understand is.
- if there is no system pressure to use those low capacity cores, why not use them if the task util fits its capacity. If the task utilization doesn't, it won't land on them anyways today right?
[..snip..]
Quoted 18 lines
Quoted 10 lines
Quoted 2 lines
What you describe really fit into the prefered core that Shrikanth Hegde has developped
I agree, but Shrikanth's solution can not bring some of the behavior changes required.
cpu_preferred_maskcan help direct task placement away from low capacity cores but idle core first approach still places tasks to fully idle low capacity cores. This patches proposal tries to move tasks first to the idle SMT siblings.Quoted 6 lines
Consider the following;
On a system with 2 high capacity and 4 low capacity cpus. steal governor of vCPU backoff mechanism calculates 2 low capacity cpus should be taken off from thecpu_preferred_maskto decrease experienced steal time.cpu_preferred_maskhas 2 high capacity and 2 low capacity cpus.
Quoted 1 line
In this scenario, do you still have reasonable steal time or no?
steal time should be sitting between low and high steal time threshold values of the steal governor. (no adjustments)
Quoted 25 lines
Quoted 18 lines
Current behavior tires to place tasks to fully idle cores first even if they are low capacity cores.
c0(high) c1(high) c2(low) c3(low) ...
-------------------------------------------
SMT 0 task task task task
SMT 1With the proposal, the fully idle core preference is circumvented and the most fitting SMT thread is selected.
c0(high) c1(high) c2(low) c3(low) ...
-------------------------------------------
SMT 0 task task
SMT 1 task taskQuoted 6 lines
This is beneficial because at the time of contention(system pressure) low capacity cores could perform worse than SMT siblings of busy high capacity cores, even if there is not enough steal time for steal governor of Shrikanth's vCPU backoff to mark said low capacity cores as non-preferred.
Quoted 2 lines
I read this as tunable problem of low,high thresholds to adjust
preferred_masksame as high capacity cores. No?
No, because cpu_preferred_mask would contain some low capacity cpus as the experienced steal time is not high enough to exclude all low capacity cpus from the mask.
And any new task could be placed on them like below as they should not cause an increase in steal time. See below (for 6 tasks); (non preferred cpus marked with X)
c0(high) c1(high) c2(low) c3(low) c4(low) c5(low) ------------------------------------------------------------ SMT 0 task task task task X X SMT 1 task task X X
The soft affinity should come in as full utilization of high capacity cores(and their SMT siblings) before placing tasks to low capacity cores (for 4 tasks);
c0(high) c1(high) c2(low) c3(low) c4(low) c5(low) ------------------------------------------------------------ SMT 0 task task X X SMT 1 task task X X
Quoted 7 lines
Quoted 7 lines
Andrea came up with an idea to extend Shrikanth's mechanism further by adding a soft affinity to a selected set of CPUs. Task placement would first fully load these CPUs before spilling load onto rest of the CPUs on
cpu_preferred_mask. That would help achieve the behavior I describe above if the soft affinity covers high capacity CPUs.
Quoted 8 lines
Quoted 3 lines
The discussion is still on going though. If Shrikanth thinks this is a worthwhile concept then I'd be glad to work on the implementation and provide the patches.
What i don't understand is.
- if there is no system pressure to use those low capacity cores, why not use them if the task util fits its capacity. If the task utilization doesn't, it won't land on them anyways today right?
Current task placement looks like this (5 tasks);
c0(high) c1(high) c2(low) c3(low) c4(low) c5(low) ------------------------------------------------------------ SMT 0 task task task task* X X SMT 1 task (**) X X
Even with lowered capacities task don't migrate away from fully idle cores, cpu selection prioritizes fully idle cores before everything else if i am not mistaken.
The proposal with this patch series tries to circumvent exactly that idle core prioritization and uses SMT threads first, like below;
c0(high) c1(high) c2(low) c3(low) c4(low) c5(low) ------------------------------------------------------------ SMT 0 task task task (**) X X SMT 1 task task* X X
*the task that got placed to SMT1 of core1 instead of fully idle
core3
**where the next task would likely land.
After high capacity CPUs are fully saturated, remaining low capacity CPUs in cpu_preferred_mask can be utilized with idle core priority once again as there are no distinction between them. Utilizing high capacity cores(or entitled cores...) should lower the footprint of the guest and allow less noise from guests. Steal time(or contention) is expected first on low capacity cores anyway.
Does this make sense?
Thank you!
-Mete
Hi Mete,
Quoted 122 lines · Mete Durlu
[..snip..]
Quoted 18 lines
Quoted 10 lines
Quoted 2 lines
What you describe really fit into the prefered core that Shrikanth Hegde has developped
I agree, but Shrikanth's solution can not bring some of the behavior changes required.
cpu_preferred_maskcan help direct task placement away from low capacity cores but idle core first approach still places tasks to fully idle low capacity cores. This patches proposal tries to move tasks first to the idle SMT siblings.Quoted 6 lines
Consider the following;
On a system with 2 high capacity and 4 low capacity cpus. steal governor of vCPU backoff mechanism calculates 2 low capacity cpus should be taken off from thecpu_preferred_maskto decrease experienced steal time.cpu_preferred_maskhas 2 high capacity and 2 low capacity cpus.Quoted 1 line
In this scenario, do you still have reasonable steal time or no?
steal time should be sitting between low and high steal time threshold values of the steal governor. (no adjustments)
Quoted 25 lines
Quoted 18 lines
Current behavior tires to place tasks to fully idle cores first even if they are low capacity cores.
c0(high) c1(high) c2(low) c3(low) ...
-------------------------------------------
SMT 0 task task task task
SMT 1With the proposal, the fully idle core preference is circumvented and the most fitting SMT thread is selected.
c0(high) c1(high) c2(low) c3(low) ...
-------------------------------------------
SMT 0 task task
SMT 1 task taskQuoted 6 lines
This is beneficial because at the time of contention(system pressure) low capacity cores could perform worse than SMT siblings of busy high capacity cores, even if there is not enough steal time for steal governor of Shrikanth's vCPU backoff to mark said low capacity cores as non-preferred.
Quoted 2 lines
I read this as tunable problem of low,high thresholds to adjust
preferred_masksame as high capacity cores. No?No, because
cpu_preferred_maskwould contain some low capacity cpus as the experienced steal time is not high enough to exclude all low capacity cpus from the mask.And any new task could be placed on them like below as they should not cause an increase in steal time. See below (for 6 tasks); (non preferred cpus marked with X)
c0(high) c1(high) c2(low) c3(low) c4(low) c5(low)
------------------------------------------------------------
SMT 0 task task task task X X SMT 1 task task X XThe soft affinity should come in as full utilization of high capacity cores(and their SMT siblings) before placing tasks to low capacity cores (for 4 tasks);
c0(high) c1(high) c2(low) c3(low) c4(low) c5(low)
------------------------------------------------------------
SMT 0 task task X X SMT 1 task task X XQuoted 7 lines
Quoted 7 lines
Andrea came up with an idea to extend Shrikanth's mechanism further by adding a soft affinity to a selected set of CPUs. Task placement would first fully load these CPUs before spilling load onto rest of the CPUs on
cpu_preferred_mask. That would help achieve the behavior I describe above if the soft affinity covers high capacity CPUs.Quoted 8 lines
Quoted 3 lines
The discussion is still on going though. If Shrikanth thinks this is a worthwhile concept then I'd be glad to work on the implementation and provide the patches.
What i don't understand is.
- if there is no system pressure to use those low capacity cores, why not use them if the task util fits its capacity. If the task utilization doesn't, it won't land on them anyways today right?Current task placement looks like this (5 tasks);
c0(high) c1(high) c2(low) c3(low) c4(low) c5(low)
------------------------------------------------------------
SMT 0 task task task task* X X SMT 1 task (**) X XEven with lowered capacities task don't migrate away from fully idle cores, cpu selection prioritizes fully idle cores before everything else if i am not mistaken.
The proposal with this patch series tries to circumvent exactly that idle core prioritization and uses SMT threads first, like below;
c0(high) c1(high) c2(low) c3(low) c4(low) c5(low)
------------------------------------------------------------
SMT 0 task task task (**) X X SMT 1 task task* X X*the task that got placed to SMT1 of core1 instead of fully idle
core3
**where the next task would likely land.After high capacity CPUs are fully saturated, remaining low capacity CPUs in
cpu_preferred_maskcan be utilized with idle core priority once again as there are no distinction between them. Utilizing high capacity cores(or entitled cores...) should lower the footprint of the guest and allow less noise from guests. Steal time(or contention) is expected first on low capacity cores anyway.
Quoted 1 line
Does this make sense?
The examples does make sense. But if one configures steal governor settings correctly, then number of low cores within the preferred mask must be very few when under physical CPU contention.
So I would recommend to see the reality of this in practice with reasonable thresholds. (Default may not be the best for all configs) You can also keep the low threshold to very low value to see if that ensure preferred mask is same as your number of entitled cores. i.e you don't have any low cores in the preferred mask. I agree steal governor is a reactive mechanism and it may have oscillations which might allow a few low cores sometimes.
Also, IMHO soft affinity thing is bit tricky to implement and need to ensure minimal cost for common cases.
PS: There might be significant delays in my responses.
Vincent Guittot
maintainerQuoted 73 lines · Mete Durlu
Quoted 63 lines · Vincent Guittot
Quoted 53 lines · Mete Durlu
Quoted 19 lines · Vincent Guittot
Quoted 18 lines · Mete Durlu
Quoted 16 lines · Shrikanth Hegde
Hi Meter/Andrea.
Quoted 12 lines · Andrea Righi
Hi Mete,
Quoted 9 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle
cores over idle SMT siblings of busy cores. This works generally well but
virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.Quoted 5 lines
Quoted 5 lines
Quoted 1 line
That's true only under physical CPU contention right? or is it always?
Right, because of that s390 treats all CPUs as equal and starts to assign lower capacities to CPUs with low entitlement once a certain steal time threshold is crossed (aka physical CPU contention).
Hi,
Sorry for causing a misunderstanding. I should have been more patient and detailed while writing my reply.Quoted 4 lines
I'm not sure to get what your topology is because "if s390 treats all CPUs as equal" then you should never use
select_idle_capacity()because their capacity should be fixed and equal andSD_ASYM_CPUCAPACITY_FULLnever set.On s390 the entitlement of the vCPUs are signified by an arch specific value we call polarization. We can tell which vCPUs are assigned high and low entitlement. This entitlement value tells us which vCPUs are prone to experience steal time first. Without any contention all vCPUs behave and perform *almost* the
same(of course, we want some priority for CPUs with high entitlement).Prior to experiencing steal time(it's what we use to determine contention) to get the most out of the system we assign all vCPUs the same capacities, making the system symmetric like you say. While there is no contention s390's vCPUs also perform better if fully idle cores are selected for task placement.
Quoted 4 lines
If your hypervisor lowers the capacity once a certain threshold is crossed, we already account for the steal time in the scheduler with irq and remove it from the capacity available for tasks but the original capacity doesn't change.
Quoted 8 lines
s390's linux implementation has a mechanism called hiperdispatch, that checks topology changes along with system steal time (and soon the total free capacity of the pyhsical machine) periodically and makes vCPU capacity adjustments accordingly.
After steal time starts ramping up and cross a certain threshold, we start assigning lower capacities to vCPUs with low entitlement to hint the scheduler that they should be avoided.
Quoted 7 lines
If all your vCPUs starts with the same capacity, you should not use
asym_capacityor enabled it . What you describe above is system pressure (steal time or other) on your vCPU that change over time but not a capacity change. The value returned byarch_scale_cpu_capacityis not supposed to change at runtime or you need to rebuild thesched_domaintopology. As an example,max_allowed_capacitydoes assume capacity fixed otherwise the misfit detection will sometimes fails.
Quoted 5 lines
Exactly for that reason on s390 we do topology updates after capacity updates. Topology changes caused by the underlying hypervisor or the cpu capacity changes can get reflected without a problem via topology rebuilds. Without topology rebuild we wouldn't even get the correct
SD_flags to triggerasym_capacitybehavior like you say.
okay as long as you call rebuild_sched_domains(), this is safe but I'm surprised that you chose to rebuild the topolgy because it's expensive
IMO you should use the pressure (steal or hw) reported to the scheduler to decide when a cpu become less efficient than others
Quoted 10 lines
Quoted 3 lines
What you describe really fit into the prefered core that Shrikanth Hegde has developped
I agree, but Shrikanth's solution can not bring some of the behavior changes required.
cpu_preferred_maskcan help direct task placement away from low capacity cores but idle core first approach still places tasks to fully idle low capacity cores. This patches proposal tries to move tasks first to the idle SMT siblings.
We have compute capacity to decide which CPU is better than others. The capacity of SMT CPU has also been somewhat random, but we should find a way to fix this instead of adding a threshold to decide whether to pack or spread tasks onto idle cores. With correct per CPU capacity, we can easily decide if an idle low core is better or not than the sibling of an already busy high core.
Quoted 41 lines
Consider the following;
On a system with 2 high capacity and 4 low capacity cpus. steal governor of vCPU backoff mechanism calculates 2 low capacity cpus should be taken off from thecpu_preferred_maskto decrease experienced steal time.cpu_preferred_maskhas 2 high capacity and 2 low capacity cpus.Current behavior tires to place tasks to fully idle cores first even if they are low capacity cores.
c0(high) c1(high) c2(low) c3(low) ...-------------------------------------------
SMT 0 task task task task
SMT 1With the proposal, the fully idle core preference is circumvented and the most fitting SMT thread is selected.
c0(high) c1(high) c2(low) c3(low) ...-------------------------------------------
SMT 0 task task
SMT 1 task taskThis is beneficial because at the time of contention(system pressure) low capacity cores could perform worse than SMT siblings of busy high capacity cores, even if there is not enough steal time for steal governor of Shrikanth's vCPU backoff to mark said low capacity cores as non-preferred.
Andrea came up with an idea to extend Shrikanth's mechanism further by adding a soft affinity to a selected set of CPUs. Task placement would first fully load these CPUs before spilling load onto rest of the CPUs on
cpu_preferred_mask. That would help achieve the behavior I describe above if the soft affinity covers high capacity CPUs.The discussion is still on going though. If Shrikanth thinks this is a worthwhile concept then I'd be glad to work on the implementation and provide the patches.
Hi again,
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
What you describe really fit into the prefered core that Shrikanth Hegde has developped
I agree, but Shrikanth's solution can not bring some of the behavior changes required.
cpu_preferred_maskcan help direct task placement away from low capacity cores but idle core first approach still places tasks to fully idle low capacity cores. This patches proposal tries to move tasks first to the idle SMT siblings.
Quoted 7 lines
We have compute capacity to decide which CPU is better than others. The capacity of SMT CPU has also been somewhat random, but we should find a way to fix this instead of adding a threshold to decide whether to pack or spread tasks onto idle cores. With correct per CPU capacity, we can easily decide if an idle low core is better or not than the sibling of an already busy high core.
After thinking about this a bit more, I have decided to work on a different approach rather than trying to integrate into Shrikanth's vCPU backoff or trying to expand this series.
I'll come back with another series after I become more familiar with how the SMT capacities are calculated and incorporated in the decision making process. My gut says the real challenge is going to be finding a way to benefit all architectures that configure asymmetric capacities but I'll give it a shot.
Thanks for the valuable comments and guidance.
-Mete
Hi Mete.
Quoted 23 lines · Mete Durlu
Hi again,
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
What you describe really fit into the prefered core that Shrikanth Hegde has developped
I agree, but Shrikanth's solution can not bring some of the behavior changes required.
cpu_preferred_maskcan help direct task placement away from low capacity cores but idle core first approach still places tasks to fully idle low capacity cores. This patches proposal tries to move tasks first to the idle SMT siblings.Quoted 7 lines
We have compute capacity to decide which CPU is better than others. The capacity of SMT CPU has also been somewhat random, but we should find a way to fix this instead of adding a threshold to decide whether to pack or spread tasks onto idle cores. With correct per CPU capacity, we can easily decide if an idle low core is better or not than the sibling of an already busy high core.
After thinking about this a bit more, I have decided to work on a different approach rather than trying to integrate into Shrikanth's vCPU backoff or trying to expand this series.
Quoted 6 lines
I'll come back with another series after I become more familiar with how the SMT capacities are calculated and incorporated in the decision making process. My gut says the real challenge is going to be finding a way to benefit all architectures that configure asymmetric capacities but I'll give it a shot.
I think you can split this issues into two.
1. Does choosing idle vertical high SMT CPU is always better than an idle vertical low SMT core. This isn't related to any system pressure or steal time. If yes, you may need something like ASYM_PACKING, or select_idle_capacity etc.
2. If you want to avoid vertical low cores when under high steal time, then using steal governor is probably right direction.
We could add arch specific hooks if current logic doesn't achieve it. But this is only under HW pressure, not always.
Quoted 2 lines
Thanks for the valuable comments and guidance.
-Mete
Quoted 89 lines · Andrea Righi
Hi Mete,
Quoted 79 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle cores over idle SMT siblings of busy cores. This works generally well but virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.Background
===========================================================================
The scheduler has been moving toward better utilization of fully idle cores and avoiding SMT penalties. This trend (notably after commit25a32e400a14("sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection") broke the behavior s390 is relying on to concentrate workloads on its high-capacity cores. On s390 CPU capacities represent the CPUs runtime entitlement assigned by the hypervisor. The idle SMT siblings of busy high-capacity cores start to perform better than fully idle low-capacity cores as the whole machine(containing the logical partitions) starts approaching to a {fully,over}loaded state. Grouping load on high-capacity cores keeps shared low-capacity cores(which are shared more aggressively) idle longer, reducing noise to neighboring partitions and improving overall performance.Approach
===========================================================================
This series introducesSCHED_IDLE_SMT_PRIOconfig option and thesched_idle_smt_priostatic branch, allowing architectures to treat idle SMT siblings of busy cores as equal candidates during asymmetric capacity load balancing.
Static branch checks are placed at paths considering fully idle cores over idle SMT threads in presence of asymmetric CPU capacities within scheduling groups. Inserted checks mostly override hints for idle core selection or cause early exits favoring idle SMT siblings. One more static branch check is added to new task path in order to favor high capacity SMT siblings during initial task placement, therefore the tasks are immediately placed in high capacity SMT siblings instead of considering most idle but low capacity cores.Architectures opt in by selecting
ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIOand implementingarch_needs_idle_smt_prio(), which is evaluated during eachasym_cpu_capacity_scan()to track the state as runtime topology changes.The second patch enables the feature for s390 when running on hardware-backed topology in an LPAR with vertical polarization active and system is approaching to a target state.
Otherwise the branch stays disabled and the scheduler falls back to the standard idle-core preference.No functional change on architectures that do not select
ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO.Performance Results
===========================================================================
Since this change effects the {fully,over}loaded state it is difficult to test at the moment. Therefore there are no concrete numbers or metrics for now for s390.
For architectures which do not opt in to this feature, no performance change is expected.Considerations and Open Questions
===========================================================================
The main goal for this series is adding a simple mechanism for architectures to switch between idle core and idle SMT priority while keeping the introduced footprint as small as possible. But there are some ideas and questions to consider;1. Should
arch_needs_idle_smt_prio()hook be removed?
The architecture hook is there to allow for any sort of logic to dynamically decide when to flip the mechanism, but it can also be removed if everyone agrees that this behaviour is not something that should be dynamically flipped. It can be simply tied to detection of asymmetric capacities and selection ofKconfigoption.2. Is there a simpler way to implement this mechanism?
The proposed approach is chosen as the other features effecting the scheduler's behavior, use the same method. If there is a more efficient way to implement the same mechanism I'd be glad to use that instead.Quoted 6 lines
3. There are no performance measurements *yet*.
On s390 the ideal conditions for this mechanism to be beneficial usually surface when the whole system is fully loaded and resource sharing between the logical partitions starts to get expensive. Creating such an environment requires time, therefore no benchmark results are available yet.
Quoted 5 lines
I'm wondering if we could build on Shrikanth's
cpu_preferred_maskinfrastructure to express a "soft preference" for the s390 higher-entitlement CPUs. Unlike the mask's current behavior, soft preference would allow tasks to spill onto other CPUs once the preferred CPUs have no idle threads available (we have something like this in sched_ext'sscx_cosmos).
Soft preference is okay if contention is low.
But if steal% remains high, we may still need to transition to hard boundaries/preferences on the cores to run on to bring steal% down.
Tim
Quoted 15 lines
That might let us preserve the general preference for fully idle SMT cores while searching in this order: fully idle preferred cores, idle SMT threads on preferred cores, then non-preferred cores. This current patch series seems to drop the first distinction, allowing a partially idle preferred core to win even when another preferred core is fully idle.
This would need to coexist with the steal governor's stronger use of
cpu_preferred_mask, so I'm suggesting it as a potential direction to explore rather than a drop-in replacement.What do you think (Mete / Shrikanth)?
Thanks,
-Andrea
Quoted 59 lines · Mete Durlu
Summary
===========================================================================
On systems with asymmetric CPU capacities, the scheduler prefers fully idle cores over idle SMT siblings of busy cores. This works generally well but virtualized platforms where low capacity cores should be avoided are not considered. Introduce a new config option and arch hook to prioritize SMT utilization.Background
===========================================================================
The scheduler has been moving toward better utilization of fully idle cores and avoiding SMT penalties. This trend (notably after commit25a32e400a14("sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection") broke the behavior s390 is relying on to concentrate workloads on its high-capacity cores. On s390 CPU capacities represent the CPUs runtime entitlement assigned by the hypervisor. The idle SMT siblings of busy high-capacity cores start to perform better than fully idle low-capacity cores as the whole machine(containing the logical partitions) starts approaching to a {fully,over}loaded state. Grouping load on high-capacity cores keeps shared low-capacity cores(which are shared more aggressively) idle longer, reducing noise to neighboring partitions and improving overall performance.Approach
===========================================================================
This series introducesSCHED_IDLE_SMT_PRIOconfig option and thesched_idle_smt_priostatic branch, allowing architectures to treat idle SMT siblings of busy cores as equal candidates during asymmetric capacity load balancing.
Static branch checks are placed at paths considering fully idle cores over idle SMT threads in presence of asymmetric CPU capacities within scheduling groups. Inserted checks mostly override hints for idle core selection or cause early exits favoring idle SMT siblings. One more static branch check is added to new task path in order to favor high capacity SMT siblings during initial task placement, therefore the tasks are immediately placed in high capacity SMT siblings instead of considering most idle but low capacity cores.Architectures opt in by selecting
ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIOand implementingarch_needs_idle_smt_prio(), which is evaluated during eachasym_cpu_capacity_scan()to track the state as runtime topology changes.The second patch enables the feature for s390 when running on hardware-backed topology in an LPAR with vertical polarization active and system is approaching to a target state.
Otherwise the branch stays disabled and the scheduler falls back to the standard idle-core preference.No functional change on architectures that do not select
ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO.Performance Results
===========================================================================
Since this change effects the {fully,over}loaded state it is difficult to test at the moment. Therefore there are no concrete numbers or metrics for now for s390.
For architectures which do not opt in to this feature, no performance change is expected.
Quoted 8 lines
Considerations and Open Questions
===========================================================================
The main goal for this series is adding a simple mechanism for architectures to switch between idle core and idle SMT priority while keeping the introduced footprint as small as possible. But there are some ideas and questions to consider;1. Should
arch_needs_idle_smt_prio()hook be removed?
Hi Mete,
One assumption in the series should be made explicit, and I think it answers your question 1.
The idea only works if two CPUs that the guest sees as SMT siblings really run on the same physical core. "An idle sibling of a busy high-capacity core" is cheaper than a fully idle low-capacity core only because it uses a physical core the partition already has. That holds on an LPAR, where hypervisor dispatches whole cores. It does not hold in general for a guest whose hypervisor schedules vCPUs one at a time, such as a typical KVM guest with "threads=2". There the guest's sibling masks are just a description, and packing onto "siblings" gives no benefit.
Nothing in the series checks this, and it is not documented:
- In patch 1, the default arch_needs_idle_smt_prio() returns true, and the Kconfig help does not mention that siblings must share a physical core. Any arch that selects ARCH_SUPPORTS_SCHED_IDLE_SMT_PRIO takes this on without being told.
- In patch 2, the hook checks only the topology mode:
Review
Quoted 6 lines
(quoted diff) +6
-0+bool arch_needs_idle_smt_prio(void) +{ + if (topology_mode != TOPOLOGY_MODE_HW) + return false; + return true; +}
Today s390 seems to be safe because sibling masks are only built in HW mode. It is the only place where this precondition can be enforced.
So I would keep the hook. It is the only place where this precondition can be enforced. Removing it and tying the feature to "Kconfig + asymmetric capacities" would drop the check entirely. Concretely:
1) Document the contract in the Kconfig help and above the hook, for example: "Only select this if CPUs reported as SMT siblings are always dispatched on the same physical core."
2) Make the s390 hook test the conditions from the cover letter, something like:
return machine_is_lpar() &&
topology_mode == TOPOLOGY_MODE_HW &&
smp_cpu_mtid;Tim
Quoted 35 lines
The architecture hook is there to allow for any sort of logic to dynamically decide when to flip the mechanism, but it can also be removed if everyone agrees that this behaviour is not something that should be dynamically flipped. It can be simply tied to detection of asymmetric capacities and selection of
Kconfigoption.2. Is there a simpler way to implement this mechanism?
The proposed approach is chosen as the other features effecting the scheduler's behavior, use the same method. If there is a more efficient way to implement the same mechanism I'd be glad to use that instead.3. There are no performance measurements *yet*.
On s390 the ideal conditions for this mechanism to be beneficial usually surface when the whole system is fully loaded and resource sharing between the logical partitions starts to get expensive. Creating such an environment requires time, therefore no benchmark results are available yet.---
base-commit:587858367581b9c55c3690f4e63382ad622719d4Mete Durlu (2):
kernel/sched: Introduce idle SMT priority
s390/topology: EnableSCHED_IDLE_SMT_PRIOarch/Kconfig | 14 +++++++++ arch/s390/Kconfig | 1 + arch/s390/include/asm/topology.h | 5 +++ arch/s390/kernel/topology.c | 9 ++++++ include/linux/sched/topology.h | 9 ++++++ kernel/sched/fair.c | 67 +++++++++++++++++++++++++++++----------- kernel/sched/sched.h | 10 ++++++ kernel/sched/topology.c | 17 ++++++++++ 8 files changed, 114 insertions(+), 18 deletions(-)
[..snip..]
Quoted 12 lines
Quoted 9 lines
Considerations and Open Questions
===========================================================================
The main goal for this series is adding a simple mechanism for architectures to switch between idle core and idle SMT priority while keeping the introduced footprint as small as possible. But there are some ideas and questions to consider;1. Should
arch_needs_idle_smt_prio()hook be removed?Hi Mete,
Quoted 8 lines
One assumption in the series should be made explicit, and I think it answers your question 1.
The idea only works if two CPUs that the guest sees as SMT siblings really run on the same physical core. "An idle sibling of a busy high-capacity core" is cheaper than a fully idle low-capacity core only because it uses a physical core the partition already has. That holds on an LPAR, where hypervisor dispatches whole cores.
True, the whole idea is based on this assumption and it is not mentioned. I'll add this.
Quoted 5 lines
It does not
hold in general for a guest whose hypervisor schedules vCPUs one at a time, such as a typical KVM guest with "threads=2". There the guest's sibling masks are just a description, and packing onto "siblings" gives no benefit.
Right, if the whole topology is virtual, the vCPUs are just separate independent entities from each other. I am not sure if there is a way to configure a KVM guest to reflect this and make the KVM hypervisor to schedule whole guest cores. Regardless, I agree that this has to be explicitly stated somewhere, probably in Kconfig's help text.
Quoted 20 lines
Nothing in the series checks this, and it is not documented:
- In patch 1, the default
arch_needs_idle_smt_prio()returns true, and theKconfighelp does not mention that siblings must share a physical core. Any arch that selectsARCH_SUPPORTS_SCHED_IDLE_SMT_PRIOtakes this on without being told.- In patch 2, the hook checks only the topology mode:
Review
Quoted 6 lines
(quoted diff) +6
-0+bool arch_needs_idle_smt_prio(void) +{ + if (topology_mode != TOPOLOGY_MODE_HW) + return false; + return true; +}Today s390 seems to be safe because sibling masks are only built in HW mode. It is the only place where this precondition can be enforced.
Quoted 8 lines
So I would keep the hook. It is the only place where this precondition can be enforced. Removing it and tying the feature to "
Kconfig+ asymmetric capacities" would drop the check entirely. Concretely:1) Document the contract in the
Kconfighelp and above the hook, for example: "Only select this if CPUs reported as SMT siblings are always dispatched on the same physical core."
Will do!
Quoted 6 lines
2) Make the s390 hook test the conditions from the cover letter,
something like: return machine_is_lpar() && topology_mode == TOPOLOGY_MODE_HW && smp_cpu_mtid;
Makes sense, as this won't help on systems with SMT disabled.
Thanks for the comments!
-Mete