Commit ecff4fcc authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'timers-fixes-for-linus' of...

Merge branch 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  timers: Consider slack value in mod_timer()
  clockevents: Handle empty cpumask gracefully
parents 58a9a36b 1c3cc116
...@@ -182,7 +182,10 @@ void clockevents_register_device(struct clock_event_device *dev) ...@@ -182,7 +182,10 @@ void clockevents_register_device(struct clock_event_device *dev)
unsigned long flags; unsigned long flags;
BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
BUG_ON(!dev->cpumask); if (!dev->cpumask) {
WARN_ON(num_possible_cpus() > 1);
dev->cpumask = cpumask_of(smp_processor_id());
}
raw_spin_lock_irqsave(&clockevents_lock, flags); raw_spin_lock_irqsave(&clockevents_lock, flags);
......
...@@ -749,16 +749,15 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires) ...@@ -749,16 +749,15 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires)
unsigned long expires_limit, mask; unsigned long expires_limit, mask;
int bit; int bit;
expires_limit = expires;
if (timer->slack >= 0) { if (timer->slack >= 0) {
expires_limit = expires + timer->slack; expires_limit = expires + timer->slack;
} else { } else {
unsigned long now = jiffies; long delta = expires - jiffies;
if (delta < 256)
return expires;
/* No slack, if already expired else auto slack 0.4% */ expires_limit = expires + delta / 256;
if (time_after(expires, now))
expires_limit = expires + (expires - now)/256;
} }
mask = expires ^ expires_limit; mask = expires ^ expires_limit;
if (mask == 0) if (mask == 0)
...@@ -795,6 +794,8 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires) ...@@ -795,6 +794,8 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires)
*/ */
int mod_timer(struct timer_list *timer, unsigned long expires) int mod_timer(struct timer_list *timer, unsigned long expires)
{ {
expires = apply_slack(timer, expires);
/* /*
* This is a common optimization triggered by the * This is a common optimization triggered by the
* networking code - if the timer is re-modified * networking code - if the timer is re-modified
...@@ -803,8 +804,6 @@ int mod_timer(struct timer_list *timer, unsigned long expires) ...@@ -803,8 +804,6 @@ int mod_timer(struct timer_list *timer, unsigned long expires)
if (timer_pending(timer) && timer->expires == expires) if (timer_pending(timer) && timer->expires == expires)
return 1; return 1;
expires = apply_slack(timer, expires);
return __mod_timer(timer, expires, false, TIMER_NOT_PINNED); return __mod_timer(timer, expires, false, TIMER_NOT_PINNED);
} }
EXPORT_SYMBOL(mod_timer); EXPORT_SYMBOL(mod_timer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment