Messages in this thread | | | Date | Wed, 15 Jan 2014 18:03:10 +0100 | From | Oleg Nesterov <> | Subject | Re: [PATCH tip/core/timers 2/4] timers: Reduce __run_timers() latency for empty list |
| |
On 01/14, Paul E. McKenney wrote: > > The __run_timers() function currently steps through the list one jiffy at > a time
And this is very suboptimal if jiffies - timer_jiffies is huge. Looks like, we should rework base->tv* structures, or (perhaps) optimize the "cascade" logic so that __run_timers() can increment timer_jiffies and move all the expired timers into work_list at one step. And the ->next_timer logic is obviously very suboptimal.
But this is almost off-topic, I agree that in the short term these changes make sense.
> +static bool catchup_timer_jiffies(struct tvec_base *base) > +{ > +#ifdef CONFIG_NO_HZ_FULL > + if (!base->all_timers) { > + base->timer_jiffies = jiffies; > + return 1; > + } > +#endif /* #ifdef CONFIG_NO_HZ_FULL */ > + return 0; > +} > + > static void > __internal_add_timer(struct tvec_base *base, struct timer_list *timer) > { > @@ -1150,6 +1161,10 @@ static inline void __run_timers(struct tvec_base *base) > struct timer_list *timer; > > spin_lock_irq(&base->lock); > + if (catchup_timer_jiffies(base)) { > + spin_unlock_irq(&base->lock); > + return; > + }
This is really minor, but perhaps it would be better to modify run_timer_softirq() to call catchup_timer_jiffies() lockless along with another fast-path time_after_eq() check.
Better yet, it would be nice to avoid raise_softirq(TIMER_SOFTIRQ), but this is not simple due to hrtimer_run_pending().
Oleg.
| |