Re: [PATCH] 8139too: fix a TX timeout watchdog thread against NAPIsoftirq race

From: Andrew Morton
Date: Tue Jan 31 2006 - 20:04:05 EST


Francois Romieu <romieu@xxxxxxxxxxxxx> wrote:
>
> + unsigned int watchdog_fired : 1;
> unsigned int default_port : 4; /* Last dev->if_port value. */
> unsigned int have_thread : 1;

Bear in mind that the compiler will put these three fields into the same
word and will use non-atomic RMWs when they are modified.

In this particualr case it's hard to see how an SMP or IRQ race can occur,
but it's a trap. Which won't show up on x86.


struct x {
unsigned int a:1;
unsigned int b:1;
};

void foo(struct x *a)
{
a->a = 1;
}

void bar(struct x *a)
{
a->b = 1;
}


On ppc:


foo:
lwz 0,0(3)
oris 0,0,0x8000
stw 0,0(3)
blr
.size foo, .-foo
.align 2
.globl bar
.type bar, @function
bar:
lwz 0,0(3)
oris 0,0,0x4000
stw 0,0(3)
blr
-
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/