From: Eric Wong Subject: Re: [PATCH] epoll: fix sparse error on RCU assignment Date: Thu, 28 Mar 2013 19:34:12 +0000 Message-ID: <20130328193412.GA10116@dcvr.yhbt.net> References: <20130310113559.GA16551@dcvr.yhbt.net> <20130310182358.GA686@redhat.com> <20130314024559.GA19856@dcvr.yhbt.net> <20130315174240.GA1069@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Al Viro , Andrew Morton , Eric Dumazet , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Davide Libenzi , "Paul E. McKenney" To: Oleg Nesterov Return-path: Content-Disposition: inline In-Reply-To: <20130315174240.GA1069@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Oleg Nesterov wrote: > On 03/14, Eric Wong wrote: > > Oleg Nesterov wrote: > > > On 03/10, Eric Wong wrote: > > > > > > > > This fixes the following sparse error when using > > > > CONFIG_SPARSE_RCU_POINTER=3Dy and "make C=3D2 fs/eventpoll.o" > > > > > > > > fs/eventpoll.c:514:17: error: incompatible types in compariso= n expression (different address spaces) > > > > > > ep_remove_wait_queue() does rcu_dereference(pwq->whead) and > > > rcu_dereference_sparse(__rcu) complains, I guess. > > > > > > > --- a/fs/eventpoll.c > > > > +++ b/fs/eventpoll.c > > > > @@ -228,7 +228,7 @@ struct eppoll_entry { > > > > wait_queue_t wait; > > > > > > > > /* The wait queue head that linked the "wait" wait queue item= */ > > > > - wait_queue_head_t *whead; > > > > + wait_queue_head_t __rcu *whead; > > > > > > Well, perhaps this change is fine... but otoh this this a bit mis= leading. > > > It is not actually __rcu. The special case is sighand->signalfd_w= qh, and > > > the commemt in ep_remove_wait_queue() means: if ->whead is not st= able then > > > we can only race with signalfd_cleanup(), and rcu_read_lock() ens= ures this > > > memory can't go away. > > > > > > We do not even need smp_read_barrier_depends() here, ACCESS_ONCE(= ) should > > > be enough. > > > > > > Perhaps it would be better to simply shut up this warning somehow= =2E.. > > > > Hi, I've been hoping others would give a reply and offer a better > > solution than min. >=20 > Me too ;) >=20 > OK, probably we should use your patch, although personally I'd prefer > to simply shut up the warning, say >=20 > - whead =3D rcu_dereference(pwq->whead); > + whead =3D rcu_dereference((void __rcu*)pwq->whead); I just tried the above and it does not build: $ make C=3D2 fs/eventpoll.o make[1]: Nothing to be done for `all'. make[1]: Nothing to be done for `relocs'. CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h CALL scripts/checksyscalls.sh CHECK scripts/mod/empty.c CHECK fs/eventpoll.c fs/eventpoll.c:516:17: error: not addressable CC fs/eventpoll.o fs/eventpoll.c: In function =E2=80=98ep_remove_wait_queue=E2=80=99: fs/eventpoll.c:516: error: lvalue required as unary =E2=80=98&=E2=80=99= operand make[1]: *** [fs/eventpoll.o] Error 1 make: *** [fs/eventpoll.o] Error 2 > > Without my proposed patch, sparse _errors_ out on me, >=20 > it is only sparse... >=20 > But OK, I won't argue with you patch. Thanks. I think my patch is the best way to address the issue and help prevent myself from introducing new bugs while working on epoll. I will continue to wait for comments from others.