Messages in this thread Patch in this message | | | Date | Tue, 25 May 2010 06:48:35 +0800 (SGT) | From | Jeff Chua <> | Subject | Re: Wireless IBSS on Linux-2.6.34 broken by commit 3bbb9ec946428b96657126768f65487a48dd090c |
| |
On Mon, May 24, 2010 at 10:57 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:> > On Mon, 24 May 2010, Jeff Chua wrote: >> + if (timer->slack > -1) >> + else if (time_after(expires, jiffies)) /* auto slack: use 0.4% */ >> expires_limit = expires + (expires - jiffies)/256; > > Please don't reload 'jiffies' twice. It's volatile, and the compiler will > do a crap job of it.
Linus,
Sorry, didn't know what a jiffies was before, so didn't know about the crap it caused. Now I learned something new.
> Also, '0' is a normal number, but '-1' is a rather odd value. Please just > test for non-negative by doing ">= 0" rather than "> -1"
Fixed.
Below is the patch to fix jiffies and checking for non-negative.
Thanks, Jeff
--- a/kernel/timer.c.org 2010-05-25 06:05:46.000000000 +0800 +++ a/kernel/timer.c 2010-05-25 06:17:44.000000000 +0800 @@ -748,14 +748,15 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires) { unsigned long expires_limit, mask; + unsigned long now = jiffies; int bit;
expires_limit = expires;
- if (timer->slack > -1) + if (timer->slack >= 0) expires_limit = expires + timer->slack; - else if (time_after(expires, jiffies)) /* auto slack: use 0.4% */ - expires_limit = expires + (expires - jiffies)/256; + else if (time_after(expires, now)) /* auto slack: use 0.4% */ + expires_limit = expires + (expires - now)/256;
mask = expires ^ expires_limit; if (mask == 0)
| |