From patchwork Wed Jan 23 15:35:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10777509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A277614E5 for ; Wed, 23 Jan 2019 15:36:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 938372CAF8 for ; Wed, 23 Jan 2019 15:36:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87DF02CF1D; Wed, 23 Jan 2019 15:36:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F8832CAF8 for ; Wed, 23 Jan 2019 15:36:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726362AbfAWPgc (ORCPT ); Wed, 23 Jan 2019 10:36:32 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39996 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbfAWPgb (ORCPT ); Wed, 23 Jan 2019 10:36:31 -0500 Received: by mail-pf1-f193.google.com with SMTP id i12so1347967pfo.7 for ; Wed, 23 Jan 2019 07:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=je9ei4LMcX4NnvUJXJVHh3/Mgly0/gzwZl7hkm7tlLw=; b=lQ6tTm1zy5EeN8Q9LBYq4S4aeEoyTvjdLv/yJogl6NsS12JhtF07avdso0t6otYqJF 5qCnmsIzN2Pbb96Ib1WYVxzddaciv/XKN07XJ4BraxyfGixY8rwGs1XIrCjz0q2SIxfB f/cWcKyoKuSGqn8kYnoiMW2YWUFOXPR5S9tJN1WFz2KmUKpeClR6w3BEs6OraiTiYlnd bG8kf62OQuk4a6x9Xs9XoTDOcrhDsnP6iimrOHYF52NN2OLiGT4WpVcc8WuXpfopOW3E 5bzI22avdEtjEmUPMqtEcXusEqmgdR2AfUi88X61btikNypAKls1h3nV32mjL+5JuTfx 8cmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=je9ei4LMcX4NnvUJXJVHh3/Mgly0/gzwZl7hkm7tlLw=; b=QaFkp+ODdyJyoYQJulQFq6JoHh4zqYKsZmQkWfdwOPsOL2QDnWwDPrebol7GxDlREj oC08z5Y02iQ5jR6VdvPl+LSqLHf5CPseezXYevKKP9y5i2v/4Hzwny6AnmqUQL4PzYn/ EOjpYpukhBjWEubNDgG92jzQ+z7igtgatX1gd6Osm89n51iXinNLTNDQ31EiFfNOeyGP 8wiit8IugYZrYv+YruwB6v+CPJD7sQ9eMsjQRiaobqjO2REOerewSqv2lNLReOz5bfdl 2os/t2C37wsvv5qt1obms5fuIoV+/cZg2ZhDPriSaJjQFWgCCEmvPx3DvtOcZqg4B4SJ UM+Q== X-Gm-Message-State: AJcUukeKeOGtfGaBbBKwYWp3OTXH0NTu8wA8JE/hn3C0kh5O7aS5NliP p/QQ4vbIs1oG9zY1dSnR39ZgWywLBa7VAw== X-Google-Smtp-Source: ALg8bN5lSKl5bbQk3oUVv1HTyx1w6zfvE1ajZX+fD2mZzs7XeNZYzT7DktZT6nTX98XlBZ1hp5o6WA== X-Received: by 2002:a63:f006:: with SMTP id k6mr2328528pgh.259.1548257790424; Wed, 23 Jan 2019 07:36:30 -0800 (PST) Received: from x1.localdomain (66.29.188.166.static.utbb.net. [66.29.188.166]) by smtp.gmail.com with ESMTPSA id u8sm30731715pfl.16.2019.01.23.07.36.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 07:36:29 -0800 (PST) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-block@vger.kernel.org Cc: hch@lst.de, jmoyer@redhat.com, avi@scylladb.com, Jens Axboe Subject: [PATCH 18/18] io_uring: add io_uring_event cache hit information Date: Wed, 23 Jan 2019 08:35:36 -0700 Message-Id: <20190123153536.7081-26-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190123153536.7081-1-axboe@kernel.dk> References: <20190123153536.7081-1-axboe@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Jens Axboe --- fs/io_uring.c | 7 ++++++- include/uapi/linux/io_uring.h | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index aa903fa902d5..a40b1af356e0 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -561,11 +561,16 @@ static void io_fput(struct io_kiocb *req) 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_fput(req); - 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_free_req(req); } diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 60b52c551c87..3b8d623031ad 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -71,6 +71,11 @@ struct io_uring_cqe { __u32 flags; }; +/* + * io_uring_event->flags + */ +#define IOCQE_FLAG_CACHEHIT (1 << 0) /* IO did not hit media */ + /* * Magic offsets for the application to mmap the data it needs */