Re: Wireless IBSS on Linux-2.6.34 broken by commit3bbb9ec946428b96657126768f65487a48dd090c

From: Jeff Chua
Date: Mon May 24 2010 - 18:48:46 EST




On Mon, May 24, 2010 at 10:57 PM, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> 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)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/