Re: [PATCH] bug: Use xchg() to update WARN_ON_ONCE() static variable

2013-10-15 Thread Frederic Weisbecker
On Tue, Oct 15, 2013 at 04:36:22PM -0400, Steven Rostedt wrote: > On Tue, 15 Oct 2013 22:21:36 +0200 > Frederic Weisbecker wrote: > > > Oh, I have a pending patchset that I worked on a few weeks ago which does > > that. > > I did not post it because it made WARN_ONCE using the unlikely text > >

Re: [PATCH] bug: Use xchg() to update WARN_ON_ONCE() static variable

2013-10-15 Thread Frederic Weisbecker
On Tue, Oct 15, 2013 at 04:25:40PM -0400, Steven Rostedt wrote: > On Tue, 15 Oct 2013 22:18:48 +0200 > Frederic Weisbecker wrote: > > > > How about just updating __warned without a cmpxchg. It's not that critical > > if the update is not seen immediately to other CPUs. OTOH it's critical > > tha

Re: [PATCH] bug: Use xchg() to update WARN_ON_ONCE() static variable

2013-10-15 Thread Steven Rostedt
On Tue, 15 Oct 2013 13:12:59 -0700 Andrew Morton wrote: > Also, we're now incurring an atomic op for every "call". Presumably > these calls are rare, but not necessarily - one can envisage uses of a > generic ONCE() which are called at high frequency. Should we avoid > that with > > #define

Re: [PATCH] bug: Use xchg() to update WARN_ON_ONCE() static variable

2013-10-15 Thread Steven Rostedt
On Tue, 15 Oct 2013 22:21:36 +0200 Frederic Weisbecker wrote: > Oh, I have a pending patchset that I worked on a few weeks ago which does > that. > I did not post it because it made WARN_ONCE using the unlikely text section, > but > the diffstat was nice. > > I'm going to post that as RFC just

Re: [PATCH] bug: Use xchg() to update WARN_ON_ONCE() static variable

2013-10-15 Thread Steven Rostedt
On Tue, 15 Oct 2013 22:18:48 +0200 Frederic Weisbecker wrote: > How about just updating __warned without a cmpxchg. It's not that critical > if the update is not seen immediately to other CPUs. OTOH it's critical > that's it is visible immediately to the current CPU Well, I didn't use cmpxchg()

Re: [PATCH] bug: Use xchg() to update WARN_ON_ONCE() static variable

2013-10-15 Thread Frederic Weisbecker
On Tue, Oct 15, 2013 at 01:12:59PM -0700, Andrew Morton wrote: > On Tue, 15 Oct 2013 15:58:06 -0400 Steven Rostedt wrote: > > > The WARN_ON_ONCE() code is to trigger a waring only once when some > > condition happens. But due to the way it is written it is racy. > > > > if (unlikely(conditio

Re: [PATCH] bug: Use xchg() to update WARN_ON_ONCE() static variable

2013-10-15 Thread Frederic Weisbecker
On Tue, Oct 15, 2013 at 03:58:06PM -0400, Steven Rostedt wrote: > The WARN_ON_ONCE() code is to trigger a waring only once when some > condition happens. But due to the way it is written it is racy. > > if (unlikely(condition)) { > if (WARN(!__warned)) > _

Re: [PATCH] bug: Use xchg() to update WARN_ON_ONCE() static variable

2013-10-15 Thread Andrew Morton
On Tue, 15 Oct 2013 15:58:06 -0400 Steven Rostedt wrote: > The WARN_ON_ONCE() code is to trigger a waring only once when some > condition happens. But due to the way it is written it is racy. > > if (unlikely(condition)) { > if (WARN(!__warned)) > __warn

[PATCH] bug: Use xchg() to update WARN_ON_ONCE() static variable

2013-10-15 Thread Steven Rostedt
The WARN_ON_ONCE() code is to trigger a waring only once when some condition happens. But due to the way it is written it is racy. if (unlikely(condition)) { if (WARN(!__warned)) __warned = true; } The problem is that multiple CPUs could hit