[patch] shaper fix for timer SMP races [was Re: 2.2.2-pre2 hangs]

Andrea Arcangeli (andrea@e-mind.com)
Mon, 15 Feb 1999 20:21:44 +0100 (CET)


On Thu, 11 Feb 1999, Alex wrote:

>I had problems with dual Intel Pentium 120 ASUSTEK motherboard with
>kernel version 2.2.0 - 2.2.1 (machine fully died on reboot). This
>problems was fixed by Ingo's patch ([patch] SMP fixes #3, for
>pre-2.2.2-1), and later by 2.2.2-pre2. But this morning machine fully
>locked up twice! Current kernel version is 2.2.2-pre2, built with
>egcs-1.1.1.

With Alex help, I narrowed down the bug. It's a SMP race in the shaper
timer code. The shaper->timer get added two times and so the timer_bh
handler started an infinite loop.

Ah, and shaper_kick() was recalled two times from shaper_qframe(), I don't
think it's needed.

Here the patch against 2.2.{[01],2-pre2}. Alex could you try it out and
see if you can reproduce the machine lockup?

Index: drivers/net/shaper.c
===================================================================
RCS file: /var/cvs/linux/drivers/net/shaper.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 shaper.c
--- shaper.c 1999/01/18 01:35:18 1.1.2.1
+++ linux/drivers/net/shaper.c 1999/02/15 19:12:00
@@ -52,7 +52,8 @@
* PPP or SLIP therefore!
* This will be fixed in BETA4
*/
-
+
+/* bh_atomic() SMP races fixes, 1999 Andrea Arcangeli */

#include <linux/module.h>
#include <linux/kernel.h>
@@ -240,7 +241,6 @@
dev_kfree_skb(ptr);
}
shaper_unlock(shaper);
- shaper_kick(shaper);
return 0;
}

@@ -290,7 +290,9 @@
save_flags(flags);
cli();

+ start_bh_atomic();
del_timer(&shaper->timer);
+ end_bh_atomic();

/*
* Shaper unlock will kick
@@ -350,9 +352,9 @@

if(skb!=NULL)
{
- del_timer(&shaper->timer);
- shaper->timer.expires=skb->shapeclock;
- add_timer(&shaper->timer);
+ start_bh_atomic();
+ mod_timer(&shaper->timer, skb->shapeclock);
+ end_bh_atomic();
}

/*
@@ -405,7 +407,9 @@
{
struct shaper *shaper=dev->priv;
shaper_flush(shaper);
+ start_bh_atomic();
del_timer(&shaper->timer);
+ end_bh_atomic();
MOD_DEC_USE_COUNT;
return 0;
}

Andrea Arcangeli

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