From: Eric Wong <normalperson@yhbt.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Arve Hjønnevåg" <arve@android.com>, NeilBrown <neilb@suse.de>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
linux-kernel@vger.kernel.org,
"Davide Libenzi" <davidel@xmailserver.org>,
"Al Viro" <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org,
"Eric Dumazet" <eric.dumazet@gmail.com>
Subject: [PATCH mm] epoll: lock ep->mtx in ep_free to silence lockdep
Date: Thu, 14 Mar 2013 03:09:00 +0000 [thread overview]
Message-ID: <20130314030900.GA30154@dcvr.yhbt.net> (raw)
In-Reply-To: <20130310115028.GB16551@dcvr.yhbt.net>
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 <normalperson@yhbt.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Davide Libenzi <davidel@xmailserver.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: NeilBrown <neilb@suse.de>,
Cc: Rafael J. Wysocki <rjw@sisk.pl>
---
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 hit
* 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 = rb_first(&ep->rbr)) != NULL) {
epi = rb_entry(rbp, struct epitem, rbn);
ep_remove(ep, epi);
}
+ mutex_unlock(&ep->mtx);
mutex_unlock(&epmutex);
mutex_destroy(&ep->mtx);
--
Eric Wong
next prev parent reply other threads:[~2013-03-14 3:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 11:26 epoll: possible bug from wakeup_source activation Eric Wong
2013-03-08 1:30 ` Eric Wong
2013-03-08 4:56 ` Arve Hjønnevåg
2013-03-08 20:49 ` Eric Wong
2013-03-09 4:09 ` Arve Hjønnevåg
2013-03-09 7:10 ` Eric Wong
2013-03-10 1:11 ` Eric Wong
2013-03-10 4:59 ` Eric Dumazet
2013-03-10 11:50 ` [PATCH] epoll: use RCU protect wakeup_source in epitem Eric Wong
2013-03-14 3:09 ` Eric Wong [this message]
2013-03-11 23:37 ` epoll: possible bug from wakeup_source activation Arve Hjønnevåg
2013-03-12 0:17 ` Eric Wong
2013-03-12 0:29 ` Arve Hjønnevåg
2013-03-12 0:44 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130314030900.GA30154@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=akpm@linux-foundation.org \
--cc=arve@android.com \
--cc=davidel@xmailserver.org \
--cc=eric.dumazet@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.de \
--cc=rjw@sisk.pl \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox