highres/dyntick: prevent xtime lock contention
PATCH 1/1 highres/dyntick: prevent xtime lock contention
While the !highres/!dyntick code assigns the duty of the do_timer() call to one specific CPU, this was dropped in the highres/dyntick part during development.
Steven Rostedt discovered the xtime lock contention on highres/dyntick due to several CPUs trying to update jiffies.
Add the single CPU assignement back. In the dyntick case this needs to be handled carefully, as the CPU which has the do_timer() duty must drop the assignement and let it be grabbed by another CPU, which is active. Otherwise the do_timer() calls would not happen during the long sleep.
Signed-off-by Thomas Gleixner <[email protected]>
Acked-by Ingo Molnar <[email protected]>
kernel/time/tick-common.c +7 -1
@@ -31,7 +31,7 @@ DEFINE_PER_CPU(struct tick_device, tick_cpu_device);*/ ktime_t tick_next_period;ktime_t tick_period; -static int tick_do_timer_cpu =-1 ; +int tick_do_timer_cpu__read_mostly =-1 ;DEFINE_SPINLOCK (tick_device_lock);/*
@@ -295,6 +295,12 @@ static void tick_shutdown(unsigned int *cpup)clockevents_exchange_device (dev,NULL ); td->evtdev =NULL ; } +/* Transfer the do_timer job away from this cpu */ +if (*cpup == tick_do_timer_cpu) { +int cpu =first_cpu (cpu_online_map); + + tick_do_timer_cpu = (cpu !=NR_CPUS ) ? cpu :-1 ; + }spin_unlock_irqrestore (&tick_device_lock, flags); }
kernel/time/tick-internal.h +1 -0
@@ -5,6 +5,7 @@ DECLARE_PER_CPU(struct tick_device, tick_cpu_device);extern spinlock_t tick_device_lock;extern ktime_t tick_next_period;extern ktime_t tick_period; +extern int tick_do_timer_cpu__read_mostly ;extern void tick_setup_periodic (struct clock_event_device *dev,int broadcast);extern void tick_handle_periodic (struct clock_event_device *dev);
kernel/time/tick-sched.c +40 -2
67 lines not on this page · raw message