* netif_poll_enable() & barrier
@ 2006-12-20 3:44 Benjamin Herrenschmidt
2006-12-29 5:09 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2006-12-20 3:44 UTC (permalink / raw)
To: David S. Miller; +Cc: Linux Kernel list, netdev
Hi !
I stumbled accross what might be a bug on out of order architecture:
netif_poll_enable() only does a clear_bit(). However,
netif_poll_disable/enable pairs are often used as simili-spinlocks.
(netif_poll_enable() has pretty much spin_lock semantics except that it
schedules instead of looping).
Thus, shouldn't netif_poll_disable() do an smp_wmb(); before clearing
the bit to make sure that any stores done within the poll-disabled
section are properly visible to the rest of the system before clearing
the bit ?
Cheers,
Ben.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: netif_poll_enable() & barrier
2006-12-20 3:44 netif_poll_enable() & barrier Benjamin Herrenschmidt
@ 2006-12-29 5:09 ` David Miller
2006-12-29 5:45 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2006-12-29 5:09 UTC (permalink / raw)
To: benh; +Cc: netdev
From: Benjamin Herrenschmidt <benh@au1.ibm.com>
Date: Wed, 20 Dec 2006 14:44:12 +1100
> I stumbled accross what might be a bug on out of order architecture:
>
> netif_poll_enable() only does a clear_bit(). However,
> netif_poll_disable/enable pairs are often used as simili-spinlocks.
>
> (netif_poll_enable() has pretty much spin_lock semantics except that it
> schedules instead of looping).
>
> Thus, shouldn't netif_poll_disable() do an smp_wmb(); before clearing
> the bit to make sure that any stores done within the poll-disabled
> section are properly visible to the rest of the system before clearing
> the bit ?
Although I couldn't find a problematic case with any current
in-tree drivers, it's better to be safe than sorry :-)
So I'll add a smp_mb__before_clear_bit() to netif_poll_enable() :)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: netif_poll_enable() & barrier
2006-12-29 5:09 ` David Miller
@ 2006-12-29 5:45 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2006-12-29 5:45 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Thu, 2006-12-28 at 21:09 -0800, David Miller wrote:
> From: Benjamin Herrenschmidt <benh@au1.ibm.com>
> Date: Wed, 20 Dec 2006 14:44:12 +1100
>
> > I stumbled accross what might be a bug on out of order architecture:
> >
> > netif_poll_enable() only does a clear_bit(). However,
> > netif_poll_disable/enable pairs are often used as simili-spinlocks.
> >
> > (netif_poll_enable() has pretty much spin_lock semantics except that it
> > schedules instead of looping).
> >
> > Thus, shouldn't netif_poll_disable() do an smp_wmb(); before clearing
> > the bit to make sure that any stores done within the poll-disabled
> > section are properly visible to the rest of the system before clearing
> > the bit ?
>
> Although I couldn't find a problematic case with any current
> in-tree drivers, it's better to be safe than sorry :-)
>
> So I'll add a smp_mb__before_clear_bit() to netif_poll_enable() :)
Heh, thanks ! :-)
I haven't seen any problematic case neither, though if there was one, it
would result in weird problems very hard to track down, so as you said,
better safe than sorry (unless you see a flaw in my reasoning).
Cheers,
Oh, and happy new year too ! :-)
Ben.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-12-29 5:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-20 3:44 netif_poll_enable() & barrier Benjamin Herrenschmidt
2006-12-29 5:09 ` David Miller
2006-12-29 5:45 ` Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).