Re: [PATCH] sched: Make ASYM_PACKING compile-time arch config

From: Shrikanth Hegde
Date: Fri Oct 18 2024 - 10:23:01 EST




On 10/18/24 03:16, Christian Loehle wrote:
Only x86 and Power7 set SD_ASYM_PACKING at boot-time depending on the

Power10 on Shared Processor LPAR also enables that.

system. All other platforms don't make use of asym-packing anyway,
so introduce auxiliary ARCH_HAS_SCHED_ASYM_PACKING and guard all the
related logic behind that so it isn't compiled when not needed.

On arm64 this reduces
size kernel/sched/fair.o
text data bss dec hex filename
74120 4097 88 78305 131e1 kernel/sched/fair.o
to
size kernel/sched/fair.o
text data bss dec hex filename
72896 4065 88 77049 12cf9 kernel/sched/fair.o

Most of that is on the load-balance hot-path, in particular
need_active_balance() reduces from 141 to 84 instructions.

This patch sprinkes #ifdef across the code. IMHO it makes the code difficult to read. Its possible to do slight such reductions for other group types as well, such as group_misfit_task(which allows right load balancing when SD_ASYM_CPUCAPACITY is on, except for a case when capacity is reduced due to side activity).

sd->flags should be cache hot and its a percpu variable. Hence the access to it shouldn't be costly. the branch predictors should do a good
job since it doesn't change often. Correct me if i am wrong.


hackbench -pTl 20000 on a rk3399 goes from
58.4664 to 57.6056 (-1.5%), mean over 20 iterations.

Signed-off-by: Christian Loehle <christian.loehle@xxxxxxx>
---
arch/Kconfig | 3 ++
arch/powerpc/Kconfig | 1 +
arch/x86/Kconfig | 1 +
kernel/sched/fair.c | 86 ++++++++++++++++++++++++++++++--------------
kernel/sched/sched.h | 8 ++++-
5 files changed, 71 insertions(+), 28 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 8af374ea1adc..9f6ec10723a3 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1684,4 +1684,7 @@ config CC_HAS_SANE_FUNCTION_ALIGNMENT
config ARCH_NEED_CMPXCHG_1_EMU
bool
...