From: Christoph Hellwig <hch@lst.de>
To: viro@zeniv.linux.org.uk
Cc: Avi Kivity <avi@scylladb.com>,
linux-aio@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] aio: allow direct aio poll comletions for keyed wakeups
Date: Mon, 30 Jul 2018 09:15:44 +0200 [thread overview]
Message-ID: <20180730071544.23998-5-hch@lst.de> (raw)
In-Reply-To: <20180730071544.23998-1-hch@lst.de>
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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/aio.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/fs/aio.c b/fs/aio.c
index 6993684d0665..158c5e41b17c 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1674,11 +1674,25 @@ 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);
/* 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: */
+ if (spin_trylock(&iocb->ki_ctx->ctx_lock)) {
+ req->done = true;
+ 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);
--
2.18.0
next prev parent reply other threads:[~2018-07-30 7:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 7:15 aio poll and a new in-kernel poll API V21 (aka 2.0) Christoph Hellwig
2018-07-30 7:15 ` [PATCH 1/4] timerfd: add support for keyed wakeups Christoph Hellwig
2018-07-30 7:15 ` [PATCH 2/4] aio: add a iocb refcount Christoph Hellwig
2018-08-01 23:19 ` Al Viro
2018-08-02 8:59 ` Christoph Hellwig
2018-07-30 7:15 ` [PATCH 3/4] aio: implement IOCB_CMD_POLL Christoph Hellwig
2018-08-01 23:54 ` Al Viro
2018-08-02 9:00 ` Christoph Hellwig
2018-08-02 0:21 ` Al Viro
2018-08-02 9:22 ` Christoph Hellwig
2018-08-02 16:00 ` Al Viro
2018-08-02 16:08 ` Christoph Hellwig
2018-08-02 16:08 ` Al Viro
2018-08-02 16:16 ` Christoph Hellwig
2018-08-02 21:48 ` Al Viro
2018-07-30 7:15 ` Christoph Hellwig [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-08-06 8:30 aio poll V22 (aka 2.0) 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
2018-08-07 7:25 ` Christoph Hellwig
2018-08-07 16:04 ` Andrew Morton
2018-08-08 9:57 ` 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=20180730071544.23998-5-hch@lst.de \
--to=hch@lst.de \
--cc=avi@scylladb.com \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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).