From: Ingo Molnar <mingo@kernel.org>
To: Christoph Hellwig <hch@lst.de>, Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Jason Baron <jbaron@akamai.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] epoll: use the waitqueue lock to protect ep->wq
Date: Thu, 7 Dec 2017 01:49:15 +0100 [thread overview]
Message-ID: <20171207004914.lxu2dz6cmxgnrou3@gmail.com> (raw)
In-Reply-To: <20171206235230.19425-2-hch@lst.de>
* Christoph Hellwig <hch@lst.de> wrote:
> The eoll code currently always uses the unlocked waitqueue helpers for
s/eoll
/epoll
> ep->wq, but instead of holding the lock inside the waitqueue around these
> calls, as expected by the epoll code uses its own lock.
Hm, that reads a bit weirdly. How about:
The epoll code currently uses the unlocked waitqueue helpers for managing
ep->wq, but instead of holding the waitqueue lock around these calls, it
uses its own ep->lock spinlock.
> Given that the
> waitqueue is not exposed to the rest of the kernel this actually works
> ok at the moment, but prevents the epoll locking rules from being
> enforced using lockdep. Remove ep->lock and use the waitqueue lock
> to not only reduce the size of struct eventpoll but also make sure we
> can assert locking invariations in the waitqueue code.
s/but also make sure
but also to make sure
s/invariations
/invariants
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/eventpoll.c | 46 ++++++++++++++++++++++------------------------
> 1 file changed, 22 insertions(+), 24 deletions(-)
>
> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> index afd548ebc328..2b2c5ac80e26 100644
> --- a/fs/eventpoll.c
> +++ b/fs/eventpoll.c
> @@ -182,11 +182,10 @@ struct epitem {
> * This structure is stored inside the "private_data" member of the file
> * structure and represents the main data structure for the eventpoll
> * interface.
> + *
> + * Access to it is protected by the lock inside wq.
> */
> struct eventpoll {
> - /* Protect the access to this structure */
> - spinlock_t lock;
> -
> /*
> * This mutex is used to ensure that files are not removed
> * while epoll is using them. This is held during the event
> @@ -210,7 +209,7 @@ struct eventpoll {
> /*
> * This is a single linked list that chains all the "struct epitem" that
> * happened while transferring ready events to userspace w/out
> - * holding ->lock.
> + * holding ->wq.lock.
> */
Neat trick!
This exposes some waitqueue internals, but AFAICS the FUSE code already does a
similar trick with fiq->waitq.lock so there's precedent.
Peter, what do you think?
Thanks,
Ingo
next prev parent reply other threads:[~2017-12-07 0:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-06 23:52 waitqueue lockdep annotation Christoph Hellwig
2017-12-06 23:52 ` [PATCH 1/2] epoll: use the waitqueue lock to protect ep->wq Christoph Hellwig
2017-12-07 0:49 ` Ingo Molnar [this message]
2017-12-07 2:38 ` Andreas Dilger
2017-12-07 6:12 ` Ingo Molnar
2017-12-14 13:06 ` Christoph Hellwig
2017-12-07 16:09 ` Jason Baron
2017-12-14 13:05 ` Christoph Hellwig
2017-12-06 23:52 ` [PATCH 2/2] sched/wait: assert the wait_queue_head lock is held in __wake_up_common Christoph Hellwig
2017-12-07 0:50 ` Ingo Molnar
2017-12-14 13:08 ` Christoph Hellwig
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=20171207004914.lxu2dz6cmxgnrou3@gmail.com \
--to=mingo@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=jbaron@akamai.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--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;
as well as URLs for NNTP newsgroup(s).