From patchwork Wed Jan 23 15:35:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10777489 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 A79721399 for ; Wed, 23 Jan 2019 15:36:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9993D2CB00 for ; Wed, 23 Jan 2019 15:36:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DD732CF1D; Wed, 23 Jan 2019 15:36:25 +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 43A402CAF8 for ; Wed, 23 Jan 2019 15:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726322AbfAWPgX (ORCPT ); Wed, 23 Jan 2019 10:36:23 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45648 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbfAWPgW (ORCPT ); Wed, 23 Jan 2019 10:36:22 -0500 Received: by mail-pl1-f194.google.com with SMTP id a14so1336622plm.12 for ; Wed, 23 Jan 2019 07:36:21 -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=RaXomNCoJ2Yswo9TBWYMkyKPjvvsMDJOZREfqq7unTabt1u2o3szwOk2Td6rKuN3Km vzmiQYpKVRrHeLZIvtdT3mTmrYhT3dM2Z3zGdWV+lRwcVE0Vl1qKtuVpfCRJ6q2SDitI aGZHRhmYcjRGLHkO94EKdw1O3Vkn8yw0Vk0axVKA8rqRZobpJ5YFZwvFcU2Kt1IwhC1n cbaHxgQrsZ84tgUXEf6T+kS7618IGmnNdClbv6OHkcX/9BTw5shZVi4fyQ9AqKpbrpoe yU0HXuHFFbDF+SoZfl2HHdmAUQBoOxET/xfQYKoZL+DzHhxbrZYkCY8K0AO0g/Ruvc7C bWzQ== 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=Ez60zomVlHzns4TqSHLGXPULnaKblA1EpfmsBSeo8VV15fRlEGkkRA0W21W91LbmJL pDD6+PL4JHDwD9XChCntE5JO5zWqM2Yoz4aFlsoenmUI146ugWqmcU8orBdIyqoQZ14L hdUDZ3XDmnEsccUlP+/XUx8XZXp2pkIex04ZxS0kAZVnMm1ccWVKl9iQ6+YyVnECwRR9 4v+Lo73NpD8/Ehg2DkNGdEeUmATX/Q/yKr2asv8aanO3gARqIh7totDKfNdR0FKnJrYO 5L0DvrwTbuWMmTKemogdaln3k9fPCgpEC9I6fRsRyT7VyOuHxuI7XHe0ajr24ZGSucEH LYrw== X-Gm-Message-State: AJcUukdzK29Nu2zjKfOAuyG54vYokKdSO1s/NGJ+lIWgDugzpMFP8Pmb W5OqJ8qaG+6Cis/pydJrMftGw1VkKngb6Q== X-Google-Smtp-Source: ALg8bN7fc7e2N+fGx8Q7cnK25F/hMvwpE2AOSXbVYiO0iPLQ+txWWPis8xfMADwESfuG4K/UfK+THQ== X-Received: by 2002:a17:902:6683:: with SMTP id e3mr2518543plk.93.1548257781238; Wed, 23 Jan 2019 07:36:21 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 07:36:20 -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 13/13] io_uring: add io_uring_event cache hit information Date: Wed, 23 Jan 2019 08:35:31 -0700 Message-Id: <20190123153536.7081-21-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 */