Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

timers: Consider slack value in mod_timer()

There is an optimization which does not update the timer if the timer
was pending and the expiration time was unchanged.

Since commit 3bbb9ec9 ("timers: Introduce the concept of timer slack
for legacy timers") this optimization is no longer applied for timers
where the expiration time got extended due to the slack value. So we
need to check again after the expiration time might have been updated.

[ tglx: Made it a single check by applying slack first and sorting
out the slack = 0 value (all timeouts < 256 jiffies) early ]

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Link: http://lkml.kernel.org/r/20110521105828.GA29442@Chamillionaire.breakpoint.cc
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Sebastian Andrzej Siewior and committed by
Thomas Gleixner
1c3cc116 1b054b67

+7 -8
+7 -8
kernel/timer.c
··· 749 749 unsigned long expires_limit, mask; 750 750 int bit; 751 751 752 - expires_limit = expires; 753 - 754 752 if (timer->slack >= 0) { 755 753 expires_limit = expires + timer->slack; 756 754 } else { 757 - unsigned long now = jiffies; 755 + long delta = expires - jiffies; 758 756 759 - /* No slack, if already expired else auto slack 0.4% */ 760 - if (time_after(expires, now)) 761 - expires_limit = expires + (expires - now)/256; 757 + if (delta < 256) 758 + return expires; 759 + 760 + expires_limit = expires + delta / 256; 762 761 } 763 762 mask = expires ^ expires_limit; 764 763 if (mask == 0) ··· 794 795 */ 795 796 int mod_timer(struct timer_list *timer, unsigned long expires) 796 797 { 798 + expires = apply_slack(timer, expires); 799 + 797 800 /* 798 801 * This is a common optimization triggered by the 799 802 * networking code - if the timer is re-modified ··· 803 802 */ 804 803 if (timer_pending(timer) && timer->expires == expires) 805 804 return 1; 806 - 807 - expires = apply_slack(timer, expires); 808 805 809 806 return __mod_timer(timer, expires, false, TIMER_NOT_PINNED); 810 807 }