From: Eric Wong Subject: [PATCH mm] epoll: lock ep->mtx in ep_free to silence lockdep Date: Thu, 14 Mar 2013 03:09:00 +0000 Message-ID: <20130314030900.GA30154@dcvr.yhbt.net> References: <20130307112639.GA25130@dcvr.yhbt.net> <20130308013027.GA31830@dcvr.yhbt.net> <20130308204944.GA27379@dcvr.yhbt.net> <20130309071037.GA13360@dcvr.yhbt.net> <20130310011136.GA4815@dcvr.yhbt.net> <1362891577.4051.21.camel@edumazet-glaptop> <20130310115028.GB16551@dcvr.yhbt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= , NeilBrown , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Davide Libenzi , Al Viro , linux-fsdevel@vger.kernel.org, Eric Dumazet To: Andrew Morton Return-path: Content-Disposition: inline In-Reply-To: <20130310115028.GB16551@dcvr.yhbt.net> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Technically we do not need to hold ep->mtx during ep_free since we are certain there are no other users of ep at that point. However, lockdep complains with a "suspicious rcu_dereference_check() usage!" message; so lock the mutex before ep_remove to silence the warning. Signed-off-by: Eric Wong Cc: Al Viro Cc: Andrew Morton Cc: Arve Hj=C3=B8nnev=C3=A5g Cc: Davide Libenzi Cc: Eric Dumazet Cc: NeilBrown , Cc: Rafael J. Wysocki --- I considered using lockdep_off()/lockdep_on(), but I figure that may hide other bugs... fs/eventpoll.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 633e69f..d71b754 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -745,11 +745,15 @@ static void ep_free(struct eventpoll *ep) * point we are sure no poll callbacks will be lingering around, and = also by * holding "epmutex" we can be sure that no file cleanup code will hi= t * us during this operation. So we can avoid the lock on "ep->lock". + * We do not need to lock ep->mtx, either, we only do it to prevent + * a lockdep warning. */ + mutex_lock(&ep->mtx); while ((rbp =3D rb_first(&ep->rbr)) !=3D NULL) { epi =3D rb_entry(rbp, struct epitem, rbn); ep_remove(ep, epi); } + mutex_unlock(&ep->mtx); =20 mutex_unlock(&epmutex); mutex_destroy(&ep->mtx); --=20 Eric Wong