s390 (9/9): no timer interrupts in idle.
Subsystems (4)
PATCH 1/1 s390 (9/9): no timer interrupts in idle.
[PATCH] s390: no timer interrupts in idle.
From: Martin Schwidefsky <[email protected]>
This patch add a system control that allows to switch off the jiffies timer interrupts while a cpu sleeps in idle. This is useful for a system running with virtual cpus under z/VM.
diffstat:
arch/s390/Kconfig | 19 +++++ arch/s390/defconfig | 1 arch/s390/kernel/process.c | 10 +- arch/s390/kernel/time.c | 158 ++++++++++++++++++++++++++++++++++++++------- arch/s390/kernel/traps.c | 4 - include/linux/rcupdate.h | 28 +++++++ include/linux/sysctl.h | 1 include/linux/timer.h | 4 + kernel/rcupdate.c | 2 kernel/sysctl.c | 14 +++ kernel/timer.c | 69 +++++++++++++++++++ 11 files changed, 281 insertions(+), 29 deletions(-)
arch/s390/Kconfig +19 -0
@@ -333,6 +333,25 @@ This can also be compiled as a module, which will be called appldata_net_sum.o. +config NO_IDLE_HZ + bool "No HZ timer ticks in idle" + help + Switches the regular HZ timer off when the system is going idle. + This helps z/VM to detect that the Linux system is idle. VM can + then "swap-out" this guest which reduces memory usage. It also + reduces the overhead of idle systems. + + The HZ timer can be switched on/off via /proc/sys/kernel/hz_timer. + hz_timer=0 means HZ timer is disabled. hz_timer=1 means HZ + timer is active. + +config NO_IDLE_HZ_INIT + bool "HZ timer in idle off by default" + depends on NO_IDLE_HZ + help + The HZ timer is switched off in idle by default. That means the + HZ timer is already disabled at boot time. + endmenu config PCMCIA
arch/s390/defconfig +1 -0
@@ -83,6 +83,7 @@ # CONFIG_SHARED_KERNEL is not set # CONFIG_CMM is not set # CONFIG_VIRT_TIMER is not set +# CONFIG_NO_IDLE_HZ is not set # CONFIG_PCMCIA is not set #
arch/s390/kernel/process.c +7 -3
@@ -40,7 +40,7 @@#include <asm/io.h> #include <asm/processor.h> #include <asm/irq.h> -#ifdef CONFIG_VIRT_TIMER +#if defined(CONFIG_VIRT_TIMER ) || defined (CONFIG_NO_IDLE_HZ )#include <asm/timer.h> #endif
@@ -75,17 +75,21 @@psw_t wait_psw;unsigned long reg; +local_irq_disable ();if (need_resched ()) { +local_irq_enable ();schedule ();return ; } -#ifdef CONFIG_VIRT_TIMER +#if defined(CONFIG_VIRT_TIMER ) || defined (CONFIG_NO_IDLE_HZ )/* * hook to stop timers that should not tick while CPU is idle */ -if (stop_timers ()) +if (stop_timers ()) { +local_irq_enable ();return ; + }#endif /*
arch/s390/kernel/time.c +135 -23
170 lines not on this page · raw message
arch/s390/kernel/traps.c +2 -2
@@ -64,7 +64,7 @@extern void pfault_interrupt (struct pt_regs *regs,__u16 error_code);static ext_int_info_t ext_int_pfault;#endif -#ifdef CONFIG_VIRT_TIMER +#if defined(CONFIG_NO_IDLE_HZ ) || defined(CONFIG_VIRT_TIMER )extern pgm_check_handler_t do_monitor_call;#endif
@@ -631,7 +631,7 @@#endif /* CONFIG_ARCH_S390X */ pgm_check_table[0x15 ] = &operand_exception; pgm_check_table[0x1C ] = &privileged_op; -#ifdef CONFIG_VIRT_TIMER +#if defined(CONFIG_VIRT_TIMER ) || defined(CONFIG_NO_IDLE_HZ ) pgm_check_table[0x40 ] = &do_monitor_call;#endif if (MACHINE_IS_VM ) {
include/linux/rcupdate.h +28 -0
@@ -121,6 +121,34 @@return 0 ; } +#ifdef CONFIG_NO_IDLE_HZ + +extern cpumask_t idle_cpu_mask; + +/* +* RCU is build for ticking systems. Without the HZ timer +* we have not enought state changes which may result in a +* never finished RCU request. +* In a tickless system we don't want to wake idle CPUs just +* to finish the RCU request. That is possible because the +* idle CPUs satisfy the quiescilant RCU condition anyway. +*/ +static inline void rcu_set_active_cpu_map (cpumask_t *mask) +{ +cpumask_t active = idle_cpu_mask; +cpus_complement (active); +cpus_and (*mask, cpu_online_map, active); +} + +#else + +static inline void rcu_set_active_cpu_map (cpumask_t *mask) +{ + *mask = cpu_online_map; +} + +#endif +#define rcu_read_lock () preempt_disable()#define rcu_read_unlock () preempt_enable()
include/linux/sysctl.h +1 -0
@@ -132,6 +132,7 @@KERN_PTY =62 ,/* dir: pty driver */ KERN_NGROUPS_MAX =63 ,/* int: NGROUPS_MAX */ KERN_SPARC_SCONS_PWROFF =64 ,/* int: serial console power-off halt */ + KERN_S390_HZ_TIMER=64, /* int: hz timer on or off */ };
include/linux/timer.h +4 -0
@@ -65,6 +65,10 @@extern int __mod_timer (struct timer_list *timer,unsigned long expires);extern int mod_timer (struct timer_list *timer,unsigned long expires); +#ifdef CONFIG_NO_IDLE_HZ +extern unsigned long next_timer_interrupt (void ); +#endif +/*** * add_timer - start a timer * @timer: the timer to be added
kernel/rcupdate.c +1 -1
@@ -111,7 +111,7 @@return ; }/* Can't change, since spin lock held. */ - rcu_ctrlblk.rcu_cpu_mask = cpu_online_map; +rcu_set_active_cpu_map (&rcu_ctrlblk.rcu_cpu_mask); }/*
kernel/sysctl.c +14 -0
@@ -108,6 +108,10 @@extern int sysctl_userprocess_debug;#endif +#ifdef CONFIG_NO_IDLE_HZ +extern int sysctl_hz_timer; +#endif +#if defined(CONFIG_PPC32 ) && defined(CONFIG_6xx)extern unsigned long powersave_nap; int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
@@ -573,6 +577,16 @@ .mode = 0644, .proc_handler = &proc_dointvec, }, +#endif +#ifdef CONFIG_NO_IDLE_HZ + { + .ctl_name = KERN_S390_HZ_TIMER, + .procname = "hz_timer", + .data = &sysctl_hz_timer, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, #endif { .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
kernel/timer.c +69 -0
75 lines not on this page · raw message
Quoted 22 lines
+++
linux-2.6-s390/include/linux/rcupdate.hWed Apr 21 16:29:41 2004include/linux/rcupdate.h +17
-0@@ -121,6 +121,34 @@return 0 ; } +#ifdef CONFIG_NO_IDLE_HZ + +extern cpumask_t idle_cpu_mask; + +/* +* RCU is build for ticking systems. Without the HZ timer +* we have not enought state changes which may result in a +* never finished RCU request. +* In a tickless system we don't want to wake idle CPUs just +* to finish the RCU request. That is possible because the +* idle CPUs satisfy the quiescilant RCU condition anyway. +*/ +static inline void rcu_set_active_cpu_map (cpumask_t *mask) +{ +cpumask_t active = idle_cpu_mask; +cpus_complement (active); +cpus_and (*mask, cpu_online_map, active);
include/linux/rcupdate.h line 150
Quoted 10 lines
include/linux/rcupdate.h +10
-0+} + +#else + +static inline void rcu_set_active_cpu_map (cpumask_t *mask) +{ + *mask = cpu_online_map; +} + +#endif
This is a bit ugly. What about inlining the CONFIG_NO_IDLE_HZ case of this function in it's only caller and define idle_cpu_mask to an empty cpu mask for all other arches?
include/linux/sysctl.h line 135
Quoted 7 lines
include/linux/sysctl.h +1
-0@@ -132,6 +132,7 @@KERN_PTY =62 ,/* dir: pty driver */ KERN_NGROUPS_MAX =63 ,/* int: NGROUPS_MAX */ KERN_SPARC_SCONS_PWROFF =64 ,/* int: serial console power-off halt */ + KERN_S390_HZ_TIMER=64, /* int: hz timer on or off */
Kill the S390, this seems usefull for a bunch of other architectures.
include/linux/timer.h line 70
Quoted 9 lines
include/linux/timer.h +3
-0@@ -65,6 +65,10 @@extern int __mod_timer (struct timer_list *timer,unsigned long expires);extern int mod_timer (struct timer_list *timer,unsigned long expires); +#ifdef CONFIG_NO_IDLE_HZ +extern unsigned long next_timer_interrupt (void ); +#endif
kill the ifdef. externs don't need to be cpp'ed away.
kernel/sysctl.c line 112
Quoted 8 lines
kernel/sysctl.c +2
-0@@ -108,6 +108,10 @@extern int sysctl_userprocess_debug;#endif +#ifdef CONFIG_NO_IDLE_HZ +extern int sysctl_hz_timer;
dito.
Quoted 7 lines · Martin Schwidefsky
[PATCH] s390: no timer interrupts in idle.
From: Martin Schwidefsky <[email protected]>
This patch add a system control that allows to switch off the jiffies timer interrupts while a cpu sleeps in idle. This is useful for a system running with virtual cpus under z/VM.
is this generally useful, eg can all architectures use the infrastructure you propose ? I seriously hope so; s390 isn't the only one who would benefit, I'd love to see a generic thing for this.