s390 (9/9): no timer interrupts in idle.
Hi Dipankar,
here is my newest version of the timer patch. I picked up your suggestion to add idle_cpu_mask to sched.c. Anything else ?
blue skies,
Martin.
---
[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 | 156 ++++++++++++++++++++++++++++++++++++++------- arch/s390/kernel/traps.c | 4 - include/linux/sched.h | 2 include/linux/sysctl.h | 1 include/linux/timer.h | 2 kernel/rcupdate.c | 6 + kernel/sched.c | 9 ++ kernel/sysctl.c | 12 +++ kernel/timer.c | 69 +++++++++++++++++++ 12 files changed, 262 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 +133 -23
168 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/sched.h +2 -0
@@ -149,6 +149,8 @@extern void sched_init (void );extern void init_idle (task_t *idle,int cpu); +extern cpumask_t idle_cpu_mask; +extern void show_state (void );extern void show_regs (struct pt_regs *);extern void show_trace_task (task_t *tsk);
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_HZ_TIMER=65, /* int: hz timer on or off */ };
include/linux/timer.h +2 -0
@@ -65,6 +65,8 @@extern int __mod_timer (struct timer_list *timer,unsigned long expires);extern int mod_timer (struct timer_list *timer,unsigned long expires); +extern unsigned long next_timer_interrupt (void ); +/*** * add_timer - start a timer * @timer: the timer to be added
kernel/rcupdate.c +5 -1
@@ -103,6 +103,8 @@*/ static void rcu_start_batch (long newbatch) { +cpumask_t active; +if (rcu_batch_before (rcu_ctrlblk.maxbatch, newbatch)) { rcu_ctrlblk.maxbatch = newbatch; }
@@ -111,7 +113,9 @@return ; }/* Can't change, since spin lock held. */ - rcu_ctrlblk.rcu_cpu_mask = cpu_online_map; + active = idle_cpu_mask; +cpus_complement (active); +cpus_and (rcu_ctrlblk.rcu_cpu_mask, cpu_online_map, active); }/*
kernel/sched.c +9 -0
@@ -2684,6 +2684,15 @@#endif } +/* +* In a system that switches off the HZ timer idle_cpu_mask +* indicates which cpus entered this state. This is used +* in the rcu update to wait only for active cpus. For system +* which do not switch off the HZ timer idle_cpu_mask should +* always be CPU_MASK_NONE. +*/ +cpumask_t idle_cpu_mask =CPU_MASK_NONE ; +#ifdef CONFIG_SMP /* * This is how migration works:
kernel/sysctl.c +12 -0
@@ -108,6 +108,8 @@extern int sysctl_userprocess_debug;#endif +extern int sysctl_hz_timer; +#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 +575,16 @@ .mode = 0644, .proc_handler = &proc_dointvec, }, +#endif +#ifdef CONFIG_NO_IDLE_HZ + { + .ctl_name = KERN_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 3 lines · Martin Schwidefsky
Hi Dipankar,
here is my newest version of the timer patch. I picked up your suggestion to addidle_cpu_masktosched.c. Anything else ?
Looks good except that I am wondering if idle_cpu_mask should really be called nohz_cpu_mask. That is what it is, after all.
Thanks
Dipankar