s390/idle: CPU idle driver
Mete Durlu
maintainerv3 cover s390/idle: CPU idle driver
v2 -> v3:
* Link to v2: https://lore.kernel.org/r/[email protected]
* Remove any mentions of idle governor since the driver is not tied to
any specific governor. TEO is just the default pick for s390
(Christian Loehle)
* Add a comment to reflect how the values for idle driver tuneables are picked (Christian Loehle)
v1 -> v2:
* Add idle driver enteries to MAINTAINERS file (Christian Loehle)
* Remove extra line break left in drivers/cpuidle/Kconfig.s390 (Christian Loehle)
This patch series introduces a CPU idle driver for s390 architecture that leverages the existing cpu idle infrastructure and idle governor to optimize idle state selection based on timer events and interrupt patterns.
- Implementation Overview
-----------------------------------------------------------------------
The driver implements two idle states;
**Polling Idle (shallow state)**
- Busy-loop implementation that prevents SIE-exit during short idle periods
- Zero exit latency, optimized for latency-sensitive workloads
- Maintains CPU with the guest, improving response times
**Enabled Wait (deep state)**
- Traditional EW state that signals hypervisor availability
- Higher exit latency but more efficient for longer idle periods
The idle governor dynamically selects between these states by monitoring next timer interrupts and system interrupt frequency, choosing the most appropriate idle state for each situation.
- Performance Benefits
-----------------------------------------------------------------------
Benchmark results across LPAR, KVM, and z/VM guests demonstrate significant improvements for latency-sensitive and scheduler-intensive workloads:
``` Benchmark | LPAR | z/VM | KVM | ----------------------------------------- cyclictest | +45% | +50% | +30% | hackbench | +5% | +12% | - | pgbench | +2% | +15% | +2% | uperf | +50%* | +-5% | +-5% | ```
*Single-threaded uperf scenarios show 50-70% improvements on LPAR. Multi-threaded results show slight improvements overall.
Additionally, fio and ioping tests show latency distribution shifts toward lower values with reduced minimum and average latencies.
- Configuration
-----------------------------------------------------------------------
Target residency and exit latency values are benchmark estimates. Due to s390's virtualized architecture, these values are non-deterministic. Idle state parameters are tuned per hypervisor type after benchmarks:
**LPAR:**
- EW: 5us target residency, 5us exit latency
**KVM/z/VM:**
- EW: 1us target residency, 1us exit latency
---
Mete Durlu (5):
s390/tick: Remove CIF_NOHZ_DELAY flag
tick: Remove arch_needs_cpu
s390: Enable TIF_POLLING_NRFLAG
s390/idle: Introduce cpuidle for s390
s390/configs: Enable cpuidle driver on s390
MAINTAINERS | 8 +++ arch/s390/Kconfig | 5 ++ arch/s390/configs/debug_defconfig | 2 + arch/s390/configs/defconfig | 2 + arch/s390/include/asm/processor.h | 4 -- arch/s390/include/asm/thread_info.h | 1 + arch/s390/kernel/idle.c | 1 - arch/s390/kernel/irq.c | 4 -- arch/s390/kernel/smp.c | 1 - drivers/cpuidle/Kconfig | 5 ++ drivers/cpuidle/Kconfig.s390 | 11 ++++ drivers/cpuidle/Makefile | 4 ++ drivers/cpuidle/cpuidle-s390.c | 115 ++++++++++++++++++++++++++++++++++++ include/linux/tick.h | 3 - kernel/time/tick-sched.c | 7 +-- 15 files changed, 156 insertions(+), 17 deletions(-)
---
base-commit: 2d3090a8aeb596a26935db0955d46c9a5db5c6ce
change-id: 20260609-idledriver-217e2b2712a3
Best regards,
Signature · 1 line
Mete Durlu <[email protected]>
Mete Durlu
maintainerPATCH v3 1/5 s390/tick: Remove CIF_NOHZ_DELAY flag
Remove obsolete tick delay heuristic [1]. The upcoming cpuidle driver handles frequent sleep/wakeup cycles more effectively.
[1] https://lore.kernel.org/all/[email protected]/
--- arch/s390/include/asm/processor.h | 4 ---- arch/s390/kernel/idle.c | 1 - arch/s390/kernel/irq.c | 4 ---- arch/s390/kernel/smp.c | 1 - 4 files changed, 10 deletions(-)
arch/s390/include/asm/processor.h +0 -4
@@ -14,12 +14,10 @@#include <linux/bits.h> -#define CIF_NOHZ_DELAY 2/* delay HZ disable for a tick */ #define CIF_ENABLED_WAIT 5/* in enabled wait state */ #define CIF_MCCK_GUEST 6/* machine check happening in guest */ #define CIF_DEDICATED_CPU 7/* this CPU is dedicated */ -#define _CIF_NOHZ_DELAY BIT(CIF_NOHZ_DELAY)#define _CIF_ENABLED_WAIT BIT(CIF_ENABLED_WAIT)#define _CIF_MCCK_GUEST BIT(CIF_MCCK_GUEST)#define _CIF_DEDICATED_CPU BIT(CIF_DEDICATED_CPU)
@@ -96,8 +94,6 @@ static __always_inline bool test_cpu_flag_of(int flag, int cpu)return test_bit (flag, &per_cpu (pcpu_devices, cpu).flags); } -#define arch_needs_cpu () test_cpu_flag(CIF_NOHZ_DELAY) -static inline void get_cpu_id (struct cpuid *ptr) { asmvolatile ("stidp %0" :"=Q" (*ptr));
arch/s390/kernel/idle.c +0 -1
@@ -42,7 +42,6 @@ void noinstr arch_cpu_idle(void)/* Wait for external, I/O or machine check interrupt. */ psw_mask =PSW_KERNEL_BITS |PSW_MASK_WAIT |PSW_MASK_IO |PSW_MASK_EXT |PSW_MASK_MCHECK ; -clear_cpu_flag (CIF_NOHZ_DELAY );set_cpu_flag (CIF_ENABLED_WAIT );if (smp_cpu_mtid)stcctm (MT_DIAG , smp_cpu_mtid, (u64 *)&idle->mt_cycles_enter);
arch/s390/kernel/irq.c +0 -4
@@ -161,7 +161,6 @@ void noinstr do_io_irq(struct pt_regs *regs)if (from_idle)account_idle_time_irq (); -set_cpu_flag (CIF_NOHZ_DELAY ); do { regs->tpi_info = get_lowcore()->tpi_info; if (get_lowcore()->tpi_info.adapter_IO)
@@ -358,9 +357,6 @@ static irqreturn_t do_ext_interrupt(int irq, void *dummy)int index; ext_code.int_code = regs->int_code; -if (ext_code.code !=EXT_IRQ_CLK_COMP ) -set_cpu_flag (CIF_NOHZ_DELAY ); - index =ext_hash (ext_code.code);rcu_read_lock ();hlist_for_each_entry_rcu (p, &ext_int_hash[index], entry) {
arch/s390/kernel/smp.c +0 -1
@@ -910,7 +910,6 @@ int __cpu_disable(void) cregs[6 ].val &= ~0xff000000UL ;/* disable all I/O interrupts */ cregs[14 ].val &= ~0x1f000000UL ;/* disable most machine checks */ __local_ctl_load (0 ,15 , cregs); -clear_cpu_flag (CIF_NOHZ_DELAY );return 0 ; }
Signature · 1 line
2.54.0
Mete Durlu
maintainerPATCH v3 2/5 tick: Remove arch_needs_cpu
In reply to Mete DurluRemove unused arch_needs_cpu() hook. No architectures use it after s390 removed its use case.
--- include/linux/tick.h | 3 --- kernel/time/tick-sched.c | 7 +++---- 2 files changed, 3 insertions(+), 7 deletions(-)
include/linux/tick.h +0 -3
@@ -44,9 +44,6 @@ static inline void tick_unfreeze(void) { }#ifdef CONFIG_TICK_ONESHOT extern void tick_irq_enter (void ); -# ifndef arch_needs_cpu -# define arch_needs_cpu () (0) -# endif # else static inline void tick_irq_enter (void ) { }#endif
kernel/time/tick-sched.c +3 -4
@@ -943,8 +943,7 @@ static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu) ts->timer_expires_base = basemono;/* -* Keep the periodic tick, when RCU, architecture or irq_work -* requests it. +* Keep the periodic tick, when RCU or irq_work requests it. * Aside of that, check whether the local timer softirq is * pending. If so, its a bad idea to call get_next_timer_interrupt(), * because there is an already expired timer, so it will request
@@ -952,8 +951,8 @@ static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu)* minimal delta, which brings us back to this place * immediately. Lather, rinse and repeat... */ -if (rcu_needs_cpu () ||arch_needs_cpu () || -irq_work_needs_cpu () ||local_timer_softirq_pending ()) { +if (rcu_needs_cpu () ||irq_work_needs_cpu () || +local_timer_softirq_pending ()) { next_tick = basemono +TICK_NSEC ; }else {/*
Signature · 1 line
2.54.0
Mete Durlu
maintainerPATCH v3 4/5 s390/idle: Introduce cpuidle for s390
In reply to Mete DurluIntroduce generic cpuidle driver on s390. Use a two stage approach to handle idle scenarios and use idle governor for idle stage selection. Two stages are, from shallow to deep, idle polling and enabled wait.
--- MAINTAINERS | 8 +++ arch/s390/Kconfig | 5 ++ drivers/cpuidle/Kconfig | 5 ++ drivers/cpuidle/Kconfig.s390 | 11 ++++ drivers/cpuidle/Makefile | 4 ++ drivers/cpuidle/cpuidle-s390.c | 115 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+)
MAINTAINERS +8 -0
@@ -6766,6 +6766,13 @@ L: [email protected] S: Maintained F: drivers/cpuidle/cpuidle-riscv-sbi.c +CPUIDLE DRIVER - S390 +M: Mete Durlu <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: drivers/cpuidle/cpuidle-s390.c + CPUMASK API [RUST] M: Viresh Kumar <[email protected]> R: Yury Norov <[email protected]>
@@ -23497,6 +23504,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git F: Documentation/driver-api/s390-drivers.rst F: Documentation/arch/s390/ F: arch/s390/ +F: drivers/cpuidle/cpuidle-s390.c F: drivers/s390/ F: drivers/watchdog/diag288_wdt.c
arch/s390/Kconfig +5 -0
@@ -20,6 +20,9 @@ config ARCH_HAS_ILOG2_U64 config ARCH_PROC_KCORE_TEXT def_bool y +config ARCH_HAS_CPU_RELAX + def_bool y + config GENERIC_HWEIGHT def_bool !HAVE_MARCH_Z196_FEATURES
@@ -708,6 +711,8 @@ config KERNEL_IMAGE_BASE endmenu +source "drivers/cpuidle/Kconfig" + menu "Memory setup" config ARCH_SPARSEMEM_ENABLE
drivers/cpuidle/Kconfig +5 -0
@@ -71,6 +71,11 @@ depends on RISCV source "drivers/cpuidle/Kconfig.riscv" endmenu +menu "S390 CPU Idle Drivers" +depends on S390 +source "drivers/cpuidle/Kconfig.s390" +endmenu + config HALTPOLL_CPUIDLE tristate "Halt poll cpuidle driver" depends on X86 && KVM_GUEST
drivers/cpuidle/Kconfig.s390 new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# S390 CPU Idle drivers +# + +config S390_CPUIDLE + bool "S390 CPU idle driver" + default y + help + Select this option to enable processor idle state management + through cpuidle subsystem.
drivers/cpuidle/Makefile +4 -0
@@ -42,3 +42,7 @@ obj-$(CONFIG_POWERNV_CPUIDLE) += cpuidle-powernv.o ############################################################################### # RISC-V drivers obj-$(CONFIG_RISCV_SBI_CPUIDLE) += cpuidle-riscv-sbi.o + +############################################################################### +# S390 drivers +obj-$(CONFIG_S390_CPUIDLE) += cpuidle-s390.o
drivers/cpuidle/cpuidle-s390.c new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.54.0
Mete Durlu
maintainerPATCH v3 3/5 s390: Enable TIF_POLLING_NRFLAG
In reply to Mete DurluEnable TIF_POLLING_NRFLAG to support idle polling state in the upcoming cpuidle driver.
--- arch/s390/include/asm/thread_info.h | 1 + 1 file changed, 1 insertion(+)
arch/s390/include/asm/thread_info.h +1 -0
@@ -61,6 +61,7 @@ void arch_setup_new_exec(void);*/ #define HAVE_TIF_NEED_RESCHED_LAZY #define HAVE_TIF_RESTORE_SIGMASK +#define HAVE_TIF_POLLING_NRFLAG #include <asm-generic/thread_info_tif.h>
Signature · 1 line
2.54.0
Mete Durlu
maintainerPATCH v3 5/5 s390/configs: Enable cpuidle driver on s390
In reply to Mete DurluEnable cpuidle infrastructure, idle governor and s390 cpuidle driver by default. They can be disabled via config options before compile or via setting cpuidle.off kernel commandline option. When cpuidle.off=1 set, given architecture's specific implementation is used as a fallback without any governor or idle state support.
During runtime individual states of cpuidle driver can also be disabled via sysfs attributes.
Ex:
echo 1 > /sys/devices/system/cpu<N>/cpuidle/state<M>/disable
--- arch/s390/configs/debug_defconfig | 2 ++ arch/s390/configs/defconfig | 2 ++ 2 files changed, 4 insertions(+)
arch/s390/configs/debug_defconfig +2 -0
@@ -29,6 +29,8 @@ CONFIG_CGROUP_PIDS=y CONFIG_CGROUP_RDMA=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_HUGETLB=y +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_TEO=y CONFIG_CPUSETS=y CONFIG_CGROUP_DEVICE=y CONFIG_CGROUP_CPUACCT=y
arch/s390/configs/defconfig +2 -0
@@ -27,6 +27,8 @@ CONFIG_CGROUP_PIDS=y CONFIG_CGROUP_RDMA=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_HUGETLB=y +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_TEO=y CONFIG_CPUSETS=y CONFIG_CGROUP_DEVICE=y CONFIG_CGROUP_CPUACCT=y
Signature · 1 line
2.54.0
Re: [PATCH v3 5/5] s390/configs: Enable cpuidle driver on s390
Am 18.06.26 um 14:00 schrieb Mete Durlu:
Quoted 6 lines
Enable cpuidle infrastructure, idle governor and s390 cpuidle driver by default. They can be disabled via config options before compile or via setting cpuidle.off kernel commandline option. When cpuidle.off=1 set, given architecture's specific implementation is used as a fallback without any governor or idle state support.
Quoted 8 lines
During runtime individual states of cpuidle driver can also be disabled via sysfs attributes.
Ex:
echo 1 > /sys/devices/system/cpu<N>/cpuidle/state<M>/disableSigned-off-by Mete Durlu <[email protected]>Reviewed-by Heiko Carstens <[email protected]>
Christian Loehle
reviewerRe: [PATCH v3 4/5] s390/idle: Introduce cpuidle for s390
In reply to Mete DurluQuoted 161 lines · Mete Durlu
Introduce generic cpuidle driver on s390. Use a two stage approach to handle idle scenarios and use idle governor for idle stage selection. Two stages are, from shallow to deep, idle polling and enabled wait.
Suggested-by Christian Borntraeger <[email protected]>Suggested-by Heiko Carstens <[email protected]>Signed-off-by Mete Durlu <[email protected]>--- MAINTAINERS | 8 +++ arch/s390/Kconfig | 5 ++ drivers/cpuidle/Kconfig | 5 ++ drivers/cpuidle/Kconfig.s390 | 11 ++++ drivers/cpuidle/Makefile | 4 ++ drivers/cpuidle/cpuidle-s390.c | 115 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+)MAINTAINERS +8
-0@@ -6766,6 +6766,13 @@ L: [email protected] S: Maintained F: drivers/cpuidle/cpuidle-riscv-sbi.c +CPUIDLE DRIVER - S390 +M: Mete Durlu <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: drivers/cpuidle/cpuidle-s390.c + CPUMASK API [RUST] M: Viresh Kumar <[email protected]> R: Yury Norov <[email protected]>@@ -23497,6 +23504,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git F: Documentation/driver-api/s390-drivers.rst F: Documentation/arch/s390/ F: arch/s390/ +F: drivers/cpuidle/cpuidle-s390.c F: drivers/s390/ F: drivers/watchdog/diag288_wdt.carch/s390/Kconfig +5
-0@@ -20,6 +20,9 @@ config ARCH_HAS_ILOG2_U64 config ARCH_PROC_KCORE_TEXT def_bool y +config ARCH_HAS_CPU_RELAX + def_bool y + config GENERIC_HWEIGHT def_bool !HAVE_MARCH_Z196_FEATURES@@ -708,6 +711,8 @@ config KERNEL_IMAGE_BASE endmenu +source "drivers/cpuidle/Kconfig" + menu "Memory setup" config ARCH_SPARSEMEM_ENABLEdrivers/cpuidle/Kconfig +5
-0@@ -71,6 +71,11 @@ depends on RISCV source "drivers/cpuidle/Kconfig.riscv" endmenu +menu "S390 CPU Idle Drivers" +depends on S390 +source "drivers/cpuidle/Kconfig.s390" +endmenu + config HALTPOLL_CPUIDLE tristate "Halt poll cpuidle driver" depends on X86 && KVM_GUESTdrivers/cpuidle/Kconfig.s390 new file +11
-0@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# S390 CPU Idle drivers +# + +config S390_CPUIDLE + bool "S390 CPU idle driver" + default y + help + Select this option to enable processor idle state management + through cpuidle subsystem.drivers/cpuidle/Makefile +4
-0@@ -42,3 +42,7 @@ obj-$(CONFIG_POWERNV_CPUIDLE) += cpuidle-powernv.o ############################################################################### # RISC-V drivers obj-$(CONFIG_RISCV_SBI_CPUIDLE) += cpuidle-riscv-sbi.o + +############################################################################### +# S390 drivers +obj-$(CONFIG_S390_CPUIDLE) += cpuidle-s390.odrivers/cpuidle/cpuidle-s390.c new file +45
-0@@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* s390 generic CPU idle driver. +* +* Copyright IBM Corp. 2026 +*/ + +#define pr_fmt (fmt) "CPUidle s390: " fmt + +#include <linux/init.h> +#include <linux/cpuidle.h> +#include <linux/cpu.h> +#include <linux/sched/clock.h> + +static __cpuidle int s390_enter_idle(struct cpuidle_device *dev, +struct cpuidle_driver *drv, +int index) +{ +arch_cpu_idle (); +return index; +} + +static struct cpuidle_driver s390_cpuidle_driver = { + .cpumask = (struct cpumask *)cpu_present_mask, + .name ="s390-idle" , + .states = { + {/* entry 0 is for polling */ }, + { + .enter = s390_enter_idle, + .name ="IDLE" , + .desc ="ENABLED WAIT" , + }, + }, + .safe_state_index =0 , + .state_count =2 , +}; + +static int s390_cpuidle_cpu_online (unsigned int cpu) +{ +struct cpuidle_device *dev = &per_cpu (cpuidle_dev, cpu); +int rc; + +if (dev->registered) { +cpuidle_pause_and_lock (); + rc =cpuidle_enable_device (dev);
drivers/cpuidle/cpuidle-s390.c line 55
Quoted 10 lines
drivers/cpuidle/cpuidle-s390.c new file +10
-0+cpuidle_resume_and_unlock (); +if (rc) +pr_err ("Failed to enable cpuidle device on cpu %u\n" , cpu); + }else { + dev->cpu = cpu; + rc =cpuidle_register_device (dev); +if (rc) +pr_err ("Failed to register cpuidle driver on cpu %u\n" , cpu); + } +return rc;
Most other drivers allow for hotplug cpu_online to succeed even if cpuidle doesn't, is this intentionally done otherwise here?
Quoted 1 line
[snip]
Mete Durlu
maintainerRe: [PATCH v3 4/5] s390/idle: Introduce cpuidle for s390
Quoted 9 lines · Christian Loehle
Quoted 8 lines · Mete Durlu
Introduce generic cpuidle driver on s390. Use a two stage approach to handle idle scenarios and use idle governor for idle stage selection. Two stages are, from shallow to deep, idle polling and enabled wait.
Suggested-by Christian Borntraeger <[email protected]>Suggested-by Heiko Carstens <[email protected]>Signed-off-by Mete Durlu <[email protected]>---
[..snip..]
Quoted 13 lines
Quoted 13 lines
drivers/cpuidle/cpuidle-s390.c new file +13
-0+static int s390_cpuidle_cpu_online (unsigned int cpu) +{ +struct cpuidle_device *dev = &per_cpu (cpuidle_dev, cpu); +int rc; + +if (dev->registered) { +cpuidle_pause_and_lock (); + rc =cpuidle_enable_device (dev); +cpuidle_resume_and_unlock (); +if (rc) +pr_err ("Failed to enable cpuidle device on cpu %u\n" , cpu); + }else { + dev->cpu = cpu;
Quoted 8 lines
drivers/cpuidle/cpuidle-s390.c line 55
Quoted 5 lines
drivers/cpuidle/cpuidle-s390.c new file +5
-0+ rc =cpuidle_register_device (dev); +if (rc) +pr_err ("Failed to register cpuidle driver on cpu %u\n" , cpu); + } +return rc;Most other drivers allow for hotplug
cpu_onlineto succeed even if cpuidle doesn't, is this intentionally done otherwise here?
Yes it is by design. Users would not be aware that something went wrong if we don't fail here (unless they check dmesg regularly which we don't expect). By failing here driver communicates that there is a problem and allows users to resolve that instead of letting a cpu run with degraded performance.
Re: [PATCH v3 4/5] s390/idle: Introduce cpuidle for s390
Quoted 36 lines · Mete Durlu
Quoted 9 lines · Christian Loehle
Quoted 8 lines · Mete Durlu
Introduce generic cpuidle driver on s390. Use a two stage approach to handle idle scenarios and use idle governor for idle stage selection. Two stages are, from shallow to deep, idle polling and enabled wait.
Suggested-by Christian Borntraeger <[email protected]>Suggested-by Heiko Carstens <[email protected]>Signed-off-by Mete Durlu <[email protected]>---
[..snip..]
Quoted 13 lines
Quoted 13 lines
drivers/cpuidle/cpuidle-s390.c new file +13
-0+static int s390_cpuidle_cpu_online (unsigned int cpu) +{ + struct cpuidle_device *dev = &per_cpu(cpuidle_dev, cpu); + int rc; + + if (dev->registered) { + cpuidle_pause_and_lock(); + rc = cpuidle_enable_device(dev); + cpuidle_resume_and_unlock(); + if (rc) + pr_err("Failed to enable cpuidle device on cpu %u\n", cpu); + } else { + dev->cpu = cpu;Quoted 8 lines
Quoted 5 lines
+ rc =
cpuidle_register_device(dev);
+ if (rc)
+pr_err("Failed to register cpuidle driver on cpu %u\n", cpu); + }
+ return rc;Most other drivers allow for hotplug
cpu_onlineto succeed even if cpuidle doesn't, is this intentionally done otherwise here?
Quoted 6 lines
Yes it is by design. Users would not be aware that something went wrong if we don't fail here (unless they check dmesg regularly which we don't expect). By failing here driver communicates that there is a problem and allows users to resolve that instead of letting a cpu run with degraded performance.
Okay, thanks!
So FWIW this looks reasonable to me now, can't really comment much on the s390 specifics, in particular as a guest, but from a purely cpuidle perspective this looks okay, so good to see that this seems to be working for you!
Re: [PATCH v3 4/5] s390/idle: Introduce cpuidle for s390
In reply to Mete DurluQuoted 15 lines · Mete Durlu
Introduce generic cpuidle driver on s390. Use a two stage approach to handle idle scenarios and use idle governor for idle stage selection. Two stages are, from shallow to deep, idle polling and enabled wait.
Suggested-by Christian Borntraeger <[email protected]>Suggested-by Heiko Carstens <[email protected]>Signed-off-by Mete Durlu <[email protected]>--- MAINTAINERS | 8 +++ arch/s390/Kconfig | 5 ++ drivers/cpuidle/Kconfig | 5 ++ drivers/cpuidle/Kconfig.s390 | 11 ++++ drivers/cpuidle/Makefile | 4 ++ drivers/cpuidle/cpuidle-s390.c | 115 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+)
...
drivers/cpuidle/cpuidle-s390.c line 93
Quoted 12 lines
drivers/cpuidle/cpuidle-s390.c new file +12
-0+static void __init s390_cpuidle_ew_tune (void ) +{ +struct cpuidle_state *state = &s390_cpuidle_driver.states[1 ]; + +if (machine_is_lpar ()) { + state->target_residency =5 ; + state->exit_latency =5 ; + }else { + state->target_residency =1 ; + state->exit_latency =1 ; + } +}
My Reviewed-by from the previous version still stands. However minor thing is that this function should be renamed to something like s390_cpuidle_ew_init() or s390_cpuidle_ew_setup().
But that's something Alexander can do when applying. Or it stays like it is. Not too important.
Anyway:
On Thu, Jun 18, 2026 at 02:00:14PM +0200, Mete Durlu wrote:
...
Quoted 81 lines
This patch series introduces a CPU idle driver for s390 architecture that leverages the existing cpu idle infrastructure and idle governor to optimize idle state selection based on timer events and interrupt patterns.
- Implementation Overview
-----------------------------------------------------------------------The driver implements two idle states;
**Polling Idle (shallow state)**
- Busy-loop implementation that prevents SIE-exit during short idle periods
- Zero exit latency, optimized for latency-sensitive workloads
- Maintains CPU with the guest, improving response times**Enabled Wait (deep state)**
- Traditional EW state that signals hypervisor availability
- Higher exit latency but more efficient for longer idle periodsThe idle governor dynamically selects between these states by monitoring next timer interrupts and system interrupt frequency, choosing the most appropriate idle state for each situation.
- Performance Benefits
-----------------------------------------------------------------------Benchmark results across LPAR, KVM, and z/VM guests demonstrate significant improvements for latency-sensitive and scheduler-intensive workloads:
``` Benchmark | LPAR | z/VM | KVM | ----------------------------------------- cyclictest | +45% | +50% | +30% | hackbench | +5% | +12% | - | pgbench | +2% | +15% | +2% | uperf | +50%* | +-5% | +-5% | ```*Single-threaded uperf scenarios show 50-70% improvements on LPAR. Multi-threaded results show slight improvements overall.
Additionally, fio and ioping tests show latency distribution shifts toward lower values with reduced minimum and average latencies.
- Configuration
-----------------------------------------------------------------------Target residency and exit latency values are benchmark estimates. Due to s390's virtualized architecture, these values are non-deterministic. Idle state parameters are tuned per hypervisor type after benchmarks:
**LPAR:**
- EW: 5us target residency, 5us exit latency**KVM/z/VM:**
- EW: 1us target residency, 1us exit latency---
Mete Durlu (5):
s390/tick: RemoveCIF_NOHZ_DELAYflag
tick: Removearch_needs_cpu
s390: EnableTIF_POLLING_NRFLAG
s390/idle: Introduce cpuidle for s390
s390/configs: Enable cpuidle driver on s390MAINTAINERS | 8 +++ arch/s390/Kconfig | 5 ++ arch/s390/configs/debug_defconfig | 2 + arch/s390/configs/defconfig | 2 + arch/s390/include/asm/processor.h | 4 -- arch/s390/include/asm/thread_info.h | 1 + arch/s390/kernel/idle.c | 1 - arch/s390/kernel/irq.c | 4 -- arch/s390/kernel/smp.c | 1 - drivers/cpuidle/Kconfig | 5 ++ drivers/cpuidle/Kconfig.s390 | 11 ++++ drivers/cpuidle/Makefile | 4 ++ drivers/cpuidle/cpuidle-s390.c | 115 ++++++++++++++++++++++++++++++++++++ include/linux/tick.h | 3 - kernel/time/tick-sched.c | 7 +-- 15 files changed, 156 insertions(+), 17 deletions(-)
Quoted 7 lines
---
base-commit:2d3090a8aeb596a26935db0955d46c9a5db5c6ce
change-id: 20260609-idledriver-217e2b2712a3Best regards,
Signature · 1 line
Mete Durlu <[email protected]>
Applied, thanks!
Christian Loehle
reviewerQuoted 87 lines · Alexander Gordeev
On Thu, Jun 18, 2026 at 02:00:14PM +0200, Mete Durlu wrote:
...Quoted 85 lines
This patch series introduces a CPU idle driver for s390 architecture that leverages the existing cpu idle infrastructure and idle governor to optimize idle state selection based on timer events and interrupt patterns.
- Implementation Overview
-----------------------------------------------------------------------The driver implements two idle states;
**Polling Idle (shallow state)**
- Busy-loop implementation that prevents SIE-exit during short idle periods
- Zero exit latency, optimized for latency-sensitive workloads
- Maintains CPU with the guest, improving response times**Enabled Wait (deep state)**
- Traditional EW state that signals hypervisor availability
- Higher exit latency but more efficient for longer idle periodsThe idle governor dynamically selects between these states by monitoring next timer interrupts and system interrupt frequency, choosing the most appropriate idle state for each situation.
- Performance Benefits
-----------------------------------------------------------------------Benchmark results across LPAR, KVM, and z/VM guests demonstrate significant improvements for latency-sensitive and scheduler-intensive workloads:
``` Benchmark | LPAR | z/VM | KVM | ----------------------------------------- cyclictest | +45% | +50% | +30% | hackbench | +5% | +12% | - | pgbench | +2% | +15% | +2% | uperf | +50%* | +-5% | +-5% | ```*Single-threaded uperf scenarios show 50-70% improvements on LPAR. Multi-threaded results show slight improvements overall.
Additionally, fio and ioping tests show latency distribution shifts toward lower values with reduced minimum and average latencies.
- Configuration
-----------------------------------------------------------------------Target residency and exit latency values are benchmark estimates. Due to s390's virtualized architecture, these values are non-deterministic. Idle state parameters are tuned per hypervisor type after benchmarks:
**LPAR:**
- EW: 5us target residency, 5us exit latency**KVM/z/VM:**
- EW: 1us target residency, 1us exit latency---
Mete Durlu (5):
s390/tick: RemoveCIF_NOHZ_DELAYflag
tick: Removearch_needs_cpu
s390: EnableTIF_POLLING_NRFLAG
s390/idle: Introduce cpuidle for s390
s390/configs: Enable cpuidle driver on s390MAINTAINERS | 8 +++ arch/s390/Kconfig | 5 ++ arch/s390/configs/debug_defconfig | 2 + arch/s390/configs/defconfig | 2 + arch/s390/include/asm/processor.h | 4 -- arch/s390/include/asm/thread_info.h | 1 + arch/s390/kernel/idle.c | 1 - arch/s390/kernel/irq.c | 4 -- arch/s390/kernel/smp.c | 1 - drivers/cpuidle/Kconfig | 5 ++ drivers/cpuidle/Kconfig.s390 | 11 ++++ drivers/cpuidle/Makefile | 4 ++ drivers/cpuidle/cpuidle-s390.c | 115 ++++++++++++++++++++++++++++++++++++ include/linux/tick.h | 3 - kernel/time/tick-sched.c | 7 +-- 15 files changed, 156 insertions(+), 17 deletions(-)---
base-commit:2d3090a8aeb596a26935db0955d46c9a5db5c6ce
change-id: 20260609-idledriver-217e2b2712a3
Quoted 5 lines
Quoted 3 lines
Best regards,
Signature · 1 line
Mete Durlu <[email protected]>Applied, thanks!
All of it? Rafael should probably at least ack drivers/cpuidle/* things...
Alexander Gordeev
maintainerQuoted 3 lines · Christian Loehle
Quoted 1 line
Applied, thanks!
All of it? Rafael should probably at least ack
drivers/cpuidle/*things...
I assumed your R-b is enough, but I will hold this series until Rafael or Daniel have a look then.
Thanks!
Quoted 8 lines · Alexander Gordeev
Quoted 3 lines · Christian Loehle
Quoted 1 line
Applied, thanks!
All of it? Rafael should probably at least ack
drivers/cpuidle/*things...I assumed your R-b is enough, but I will hold this series until Rafael or Daniel have a look then.
So please feel free to add
to this series and route it as you see fit.
But yes, Christian is a cpuidle reviewer officially now as per MAINTAINERS, so his R-by is sufficient in cases like this one at least IMV.