From: Jens Axboe <axboe@kernel.dk>
To: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org
Cc: viro@ZenIV.linux.org.uk, Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 3/3] io_uring: add io_uring_event cache hit information
Date: Fri, 15 Mar 2019 10:27:29 -0600 [thread overview]
Message-ID: <aa0e7a3a-d7dc-2b6e-5a2c-adf99aab27a6@kernel.dk> (raw)
In-Reply-To: <20190315145938.21516-4-axboe@kernel.dk>
On 3/15/19 8:59 AM, Jens Axboe wrote:
> Add hint on whether a read was served out of the page cache, or if it
> hit media. This is useful for buffered async IO, O_DIRECT reads would
> never have this set (for obvious reasons).
>
> If the read hit page cache, cqe->flags will have IOCQE_FLAG_CACHEHIT
> set.
Linus, curious on your opinion on this one. I had this as part of the
original series, but removed it from the pull request due to the
mincore etc discussions.
Leaving the patch intact for you. This is part of a small series of
improvements, which sit on top of a series of fixes for this release.
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index f66a4a5daf35..513df722702e 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -635,10 +635,14 @@ static void kiocb_end_write(struct kiocb *kiocb)
> static void io_complete_rw(struct kiocb *kiocb, long res, long res2)
> {
> struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw);
> + unsigned ev_flags = 0;
>
> kiocb_end_write(kiocb);
>
> - io_cqring_add_event(req->ctx, req->user_data, res, 0);
> + if (res > 0 && (req->flags & REQ_F_FORCE_NONBLOCK))
> + ev_flags = IOCQE_FLAG_CACHEHIT;
> +
> + io_cqring_add_event(req->ctx, req->user_data, res, ev_flags);
> io_put_req(req);
> }
>
> diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
> index e23408692118..24906e99fdc7 100644
> --- a/include/uapi/linux/io_uring.h
> +++ b/include/uapi/linux/io_uring.h
> @@ -69,6 +69,11 @@ struct io_uring_cqe {
> __u32 flags;
> };
>
> +/*
> + * io_uring_event->flags
> + */
> +#define IOCQE_FLAG_CACHEHIT (1U << 0) /* IO did not hit media */
> +
> /*
> * Magic offsets for the application to mmap the data it needs
> */
>
--
Jens Axboe
next prev parent reply other threads:[~2019-03-15 16:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-15 14:59 [PATCHSET 0/3] io_uring improvements Jens Axboe
2019-03-15 14:59 ` [PATCH 1/3] iov_iter: add ITER_BVEC_FLAG_NO_REF flag Jens Axboe
2019-03-15 14:59 ` [PATCH 2/3] block: add BIO_NO_PAGE_REF flag Jens Axboe
2019-03-15 14:59 ` [PATCH 3/3] io_uring: add io_uring_event cache hit information Jens Axboe
2019-03-15 16:27 ` Jens Axboe [this message]
2019-03-16 1:34 ` Linus Torvalds
2019-03-16 16:27 ` Jens Axboe
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=aa0e7a3a-d7dc-2b6e-5a2c-adf99aab27a6@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@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).