From: Andrew Morton <akpm@linux-foundation.org>
To: Christoph Hellwig <hch@lst.de>
Cc: viro@zeniv.linux.org.uk, Avi Kivity <avi@scylladb.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-aio@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] aio: allow direct aio poll comletions for keyed wakeups
Date: Mon, 6 Aug 2018 15:27:05 -0700 [thread overview]
Message-ID: <20180806152705.37809e16c02543cc24626607@linux-foundation.org> (raw)
In-Reply-To: <20180806083058.14724-5-hch@lst.de>
On Mon, 6 Aug 2018 10:30:58 +0200 Christoph Hellwig <hch@lst.de> wrote:
> If we get a keyed wakeup for a aio poll waitqueue and wake can acquire the
> ctx_lock without spinning we can just complete the iocb straight from the
> wakeup callback to avoid a context switch.
Why do we try to avoid spinning on the lock?
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -1672,13 +1672,26 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
> void *key)
> {
> struct poll_iocb *req = container_of(wait, struct poll_iocb, wait);
> + struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll);
> __poll_t mask = key_to_poll(key);
>
> req->woken = true;
>
> /* for instances that support it check for an event match first: */
> - if (mask && !(mask & req->events))
> - return 0;
> + if (mask) {
> + if (!(mask & req->events))
> + return 0;
> +
> + /* try to complete the iocb inline if we can: */
ie, this comment explains 'what" but not "why".
(There's a typo in Subject:, btw)
> + if (spin_trylock(&iocb->ki_ctx->ctx_lock)) {
> + list_del(&iocb->ki_list);
> + spin_unlock(&iocb->ki_ctx->ctx_lock);
> +
> + list_del_init(&req->wait.entry);
> + aio_poll_complete(iocb, mask);
> + return 1;
> + }
> + }
>
> list_del_init(&req->wait.entry);
> schedule_work(&req->work);
next prev parent reply other threads:[~2018-08-06 22:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-06 8:30 aio poll V22 (aka 2.0) Christoph Hellwig
2018-08-06 8:30 ` [PATCH 1/4] timerfd: add support for keyed wakeups Christoph Hellwig
2018-08-06 8:30 ` [PATCH 2/4] aio: add a iocb refcount Christoph Hellwig
2018-08-06 8:30 ` [PATCH 3/4] aio: implement IOCB_CMD_POLL Christoph Hellwig
2018-08-06 8:30 ` [PATCH 4/4] aio: allow direct aio poll comletions for keyed wakeups Christoph Hellwig
2018-08-06 22:27 ` Andrew Morton [this message]
2018-08-07 7:25 ` Christoph Hellwig
2018-08-07 16:04 ` Andrew Morton
2018-08-08 9:57 ` Christoph Hellwig
2018-08-07 11:44 ` [PATCH 4/4 v2] " Christoph Hellwig
2018-08-06 16:49 ` aio poll V22 (aka 2.0) Linus Torvalds
2018-08-07 7:27 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2018-07-30 7:15 aio poll and a new in-kernel poll API V21 " Christoph Hellwig
2018-07-30 7:15 ` [PATCH 4/4] aio: allow direct aio poll comletions for keyed wakeups Christoph Hellwig
2018-07-26 8:28 aio poll and a new in-kernel poll API V20 (aka 2.0) Christoph Hellwig
2018-07-26 8:29 ` [PATCH 4/4] aio: allow direct aio poll comletions for keyed wakeups 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=20180806152705.37809e16c02543cc24626607@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=avi@scylladb.com \
--cc=hch@lst.de \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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).