Re: [PATCH] mce: fix RCU lockdep from mce_poll()

From: Davidlohr Bueso
Date: Wed Nov 10 2010 - 08:45:17 EST


On Mon, 2010-11-08 at 05:17 -0800, Paul E. McKenney wrote:
> On Mon, Nov 08, 2010 at 08:30:19AM -0300, Davidlohr Bueso wrote:
> > On Sun, 2010-11-07 at 05:39 -0800, Paul E. McKenney wrote:
> > > On Sat, Nov 06, 2010 at 07:53:50PM +0100, Andi Kleen wrote:
> > > > On Fri, Nov 05, 2010 at 06:44:59PM -0300, Davidlohr Bueso wrote:
> > > > > Hi,
> > > > >
> > > > > Please review this patch, I am not very familiar with MCE/RCU so I'm not sure that this is the correct fix (otherwise consider it a bug report :)).
> > > > > This does "fix" the message though and I can use MCE normally.
> > > >
> > > > The patch is certainly not correct. The variable needs to be read
> > > > independently of the mutex.
> > >
> > > This code is simply checking the value of the pointer, and therefore
> > > need not protect any actual dereferences. So why not replace the
> > > rcu_dereference_check_mce() with rcu_access_pointer()? If this is
> > > OK, please see the patch below.
> > >
> > > BTW, assigning the value returned by rcu_access_pointer() into a
> > > variable often indicates a bug. ;-)
> > >
> > > Thanx, Paul
> > >
> > > Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
> > >
> > > diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> > > index 7a35b72..4d29d50 100644
> > > --- a/arch/x86/kernel/cpu/mcheck/mce.c
> > > +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> > > @@ -1625,7 +1625,7 @@ out:
> > > static unsigned int mce_poll(struct file *file, poll_table *wait)
> > > {
> > > poll_wait(file, &mce_wait, wait);
> > > - if (rcu_dereference_check_mce(mcelog.next))
> > > + if (rcu_access_pointer(mcelog.next))
> >
> > this doesn't compile (mcelog.next is an index):
> >
> > arch/x86/kernel/cpu/mcheck/mce.c: In function âmce_pollâ:
> > arch/x86/kernel/cpu/mcheck/mce.c:1628: error: invalid type argument of
> > âunary *â (have âunsigned intâ)
> > arch/x86/kernel/cpu/mcheck/mce.c:1628: warning: type defaults to âintâ
> > in declaration of â_________p1â
> > arch/x86/kernel/cpu/mcheck/mce.c:1628: error: invalid type argument of
> > âunary *â (have âunsigned intâ)
> > arch/x86/kernel/cpu/mcheck/mce.c:1628: warning: type defaults to âintâ
> > in declaration of âtype nameâ
> > arch/x86/kernel/cpu/mcheck/mce.c:1628: warning: cast to pointer from
> > integer of different size
> > arch/x86/kernel/cpu/mcheck/mce.c:1628: error: invalid type argument of
> > âunary *â (have âunsigned intâ)
> > arch/x86/kernel/cpu/mcheck/mce.c:1628: warning: type defaults to âintâ
> > in declaration of âtype nameâ
> > make[4]: *** [arch/x86/kernel/cpu/mcheck/mce.o] Error 1
> >
> >
> > Since the mutex is independent, what about this patch?
>
> Looks good to me!
>
> Acked-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
>

Andi, any further thoughts?

Thanks,
Davidlohr

--
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/