timers: migration for power saving
Subsystems (7)
Linus,
Please pull the latest timers-for-linus-migration git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git timers-for-linus-migration
The migration support for power saving touches a few timer unrelated files to mark timers which are not allowed to be migrated. Acked by the relevant maintainers.
Thanks,
tglx
------------------>
Arun R Bharadwaj (4):
timers: Framework for identifying pinned timers
timers: Identifying the existing pinned timers
timers: /proc/sys sysctl hook to enable timer migration
timers: Logic to move non pinned timers
Jon Hunter (1):
timers: allow deferrable timers for intervals tv2-tv5 to be deferred
arch/x86/kernel/apic/x2apic_uv_x.c | 2 +- include/linux/clockchips.h | 9 +++++ include/linux/hrtimer.h | 7 +++- include/linux/sched.h | 13 ++++++++ include/linux/timer.h | 3 ++ kernel/hrtimer.c | 58 ++++++++++++++++++++++++++++++++--- kernel/sched.c | 11 +++++- kernel/sysctl.c | 8 +++++ kernel/time/clockevents.c | 12 +++++++ kernel/time/tick-sched.c | 7 ++-- kernel/timer.c | 51 +++++++++++++++++++++++++++---- kernel/trace/trace_sysprof.c | 3 +- 12 files changed, 163 insertions(+), 21 deletions(-)
arch/x86/kernel/apic/x2apic_uv_x.c +1 -1
@@ -463,7 +463,7 @@ static void uv_heartbeat(unsigned long ignored)uv_set_scir_bits (bits);/* enable next timer period */ -mod_timer (timer, jiffies +SCIR_CPU_HB_INTERVAL ); +mod_timer_pinned (timer, jiffies +SCIR_CPU_HB_INTERVAL ); }static void __cpuinit uv_heartbeat_enable (int cpu)
include/linux/clockchips.h +9 -0
@@ -143,3 +143,12 @@ extern void clockevents_notify(unsigned long reason, void *arg);#endif #endif + +#ifdef CONFIG_GENERIC_CLOCKEVENTS +extern ktime_t clockevents_get_next_event (int cpu); +#else +static inline ktime_t clockevents_get_next_event (int cpu) +{ +return (ktime_t ) { .tv64 =KTIME_MAX }; +} +#endif
include/linux/hrtimer.h +5 -2
@@ -30,8 +30,11 @@ struct hrtimer_cpu_base;* Mode arguments of xxx_hrtimer functions: */ enum hrtimer_mode { -HRTIMER_MODE_ABS ,/* Time value is absolute */ -HRTIMER_MODE_REL ,/* Time value is relative to now */ +HRTIMER_MODE_ABS =0x0 ,/* Time value is absolute */ +HRTIMER_MODE_REL =0x1 ,/* Time value is relative to now */ +HRTIMER_MODE_PINNED =0x02 ,/* Timer is bound to CPU */ +HRTIMER_MODE_ABS_PINNED =0x02 , +HRTIMER_MODE_REL_PINNED =0x03 , };/*
include/linux/sched.h +13 -0
@@ -257,6 +257,7 @@ extern void task_rq_unlock_wait(struct task_struct *p);extern cpumask_var_t nohz_cpu_mask;#if defined(CONFIG_SMP ) && defined(CONFIG_NO_HZ )extern int select_nohz_load_balancer (int cpu); +extern int get_nohz_load_balancer (void );#else static inline int select_nohz_load_balancer (int cpu) {
@@ -1766,11 +1767,23 @@ extern unsigned int sysctl_sched_child_runs_first;extern unsigned int sysctl_sched_features;extern unsigned int sysctl_sched_migration_cost;extern unsigned int sysctl_sched_nr_migrate; +extern unsigned int sysctl_timer_migration;int sched_nr_latency_handler (struct ctl_table *table,int write,struct file *file,void __user *buffer,size_t *length,loff_t *ppos);#endif +#ifdef CONFIG_SCHED_DEBUG +static inline unsigned int get_sysctl_timer_migration (void ) +{ +return sysctl_timer_migration; +} +#else +static inline unsigned int get_sysctl_timer_migration (void ) +{ +return 1 ; +} +#endif extern unsigned int sysctl_sched_rt_period;extern int sysctl_sched_rt_runtime;
include/linux/timer.h +3 -0
@@ -163,7 +163,10 @@ extern void add_timer_on(struct timer_list *timer, int cpu);extern int del_timer (struct timer_list * timer);extern int mod_timer (struct timer_list *timer,unsigned long expires);extern int mod_timer_pending (struct timer_list *timer,unsigned long expires); +extern int mod_timer_pinned (struct timer_list *timer,unsigned long expires); +#define TIMER_NOT_PINNED 0 +#define TIMER_PINNED 1/* * The jiffies value which is added to now, when there is no timer * in the timer wheel:
kernel/hrtimer.c +53 -5
93 lines not on this page · raw message
kernel/sched.c +9 -2
@@ -244,7 +244,7 @@ static void start_rt_bandwidth(struct rt_bandwidth *rt_b) hard =hrtimer_get_expires (&rt_b->rt_period_timer); delta =ktime_to_ns (ktime_sub (hard, soft));__hrtimer_start_range_ns (&rt_b->rt_period_timer, soft, delta, -HRTIMER_MODE_ABS ,0 ); +HRTIMER_MODE_ABS_PINNED ,0 ); }spin_unlock (&rt_b->rt_runtime_lock); }
@@ -1154,7 +1154,7 @@ static __init void init_hrtick(void)static void hrtick_start (struct rq *rq,u64 delay) {__hrtimer_start_range_ns (&rq->hrtick_timer,ns_to_ktime (delay),0 , -HRTIMER_MODE_REL ,0 ); +HRTIMER_MODE_REL_PINNED ,0 ); }static inline void init_hrtick (void )
@@ -4244,6 +4244,11 @@ static struct { .load_balancer = ATOMIC_INIT(-1), }; +int get_nohz_load_balancer (void ) +{ +return atomic_read (&nohz.load_balancer); +} +/* * This routine will try to nominate the ilb (idle load balancing) * owner among the cpus whose ticks are stopped. ilb owner will do the idle
@@ -8731,6 +8736,8 @@ void __init sched_init_smp(void) }#endif /* CONFIG_SMP */ +const_debug unsigned int sysctl_timer_migration = 1; +int in_sched_functions (unsigned long addr) { return in_lock_functions(addr) ||
kernel/sysctl.c +8 -0
@@ -324,6 +324,14 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "timer_migration", + .data = &sysctl_timer_migration, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = &proc_dointvec, + },#endif { .ctl_name = CTL_UNNUMBERED,
kernel/time/clockevents.c +12 -0
@@ -18,6 +18,7 @@#include <linux/notifier.h> #include <linux/smp.h> #include <linux/sysdev.h> +#include <linux/tick.h> /* The registered clock event devices */ static LIST_HEAD (clockevent_devices);
@@ -251,4 +252,15 @@ void clockevents_notify(unsigned long reason, void *arg) spin_unlock(&clockevents_lock); }EXPORT_SYMBOL_GPL (clockevents_notify); + +ktime_t clockevents_get_next_event (int cpu) +{ +struct tick_device *td; +struct clock_event_device *dev; + + td = &per_cpu (tick_cpu_device, cpu); + dev = td->evtdev; + +return dev->next_event; +}#endif
kernel/time/tick-sched.c +4 -3
@@ -349,7 +349,7 @@ void tick_nohz_stop_sched_tick(int inidle)if (ts->nohz_mode ==NOHZ_MODE_HIGHRES ) {hrtimer_start (&ts->sched_timer, expires, -HRTIMER_MODE_ABS ); +HRTIMER_MODE_ABS_PINNED );/* Check, if the timer was already in the past */ if (hrtimer_active (&ts->sched_timer)) goto out;
@@ -395,7 +395,7 @@ static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)if (ts->nohz_mode ==NOHZ_MODE_HIGHRES ) {hrtimer_start_expires (&ts->sched_timer, -HRTIMER_MODE_ABS ); +HRTIMER_MODE_ABS_PINNED );/* Check, if the timer was already in the past */ if (hrtimer_active (&ts->sched_timer))break ;
@@ -698,7 +698,8 @@ void tick_setup_sched_timer(void)for (;;) {hrtimer_forward (&ts->sched_timer, now, tick_period); -hrtimer_start_expires (&ts->sched_timer,HRTIMER_MODE_ABS ); +hrtimer_start_expires (&ts->sched_timer, +HRTIMER_MODE_ABS_PINNED );/* Check, if the timer was already in the past */ if (hrtimer_active (&ts->sched_timer))break ;
kernel/timer.c +44 -7
100 lines not on this page · raw message
kernel/trace/trace_sysprof.c +2 -1
@@ -203,7 +203,8 @@ static void start_stack_timer(void *unused)hrtimer_init (hrtimer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); hrtimer->function = stack_trace_timer_fn; -hrtimer_start (hrtimer,ns_to_ktime (sample_period),HRTIMER_MODE_REL ); +hrtimer_start (hrtimer,ns_to_ktime (sample_period), +HRTIMER_MODE_REL_PINNED ); }static void start_stack_timers (void )