From patchwork Fri Mar 15 14:59:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10854963 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 5B91F6C2 for ; Fri, 15 Mar 2019 14:59:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49FAA2A9CF for ; Fri, 15 Mar 2019 14:59:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E3302AA8F; Fri, 15 Mar 2019 14:59:50 +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 E8F4E2A9CF for ; Fri, 15 Mar 2019 14:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729325AbfCOO7t (ORCPT ); Fri, 15 Mar 2019 10:59:49 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33835 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729318AbfCOO7t (ORCPT ); Fri, 15 Mar 2019 10:59:49 -0400 Received: by mail-pg1-f194.google.com with SMTP id v12so6683687pgq.1 for ; Fri, 15 Mar 2019 07:59:48 -0700 (PDT) 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=iP0RIMIP0Dhv0Z3VwimEl1gZSo5mPCskMpjat/g+ZWI=; b=Q5B2XIA3o13t9GSzsQbK8sE651mnRmz0FDF04NOuh0sqpEH7gMaXegRLvfuDuulYDe mRKiRP+DEBaYzjjo3wArP3GZQ0bGCEuFChN4YEKgJQaU1WtFM2SQkJynmQWYD3Fzj8I8 gwR6ExlEVWAjvCmWBt6xDVHQtSA4SPYp6cunpok9yTdip8WhdAeB2W8PtyQc4BdZp3vC Inyun33YXY3iAbaem/JIHpqcLxekLGghmMYaADq2JV7EvZHhFXkUTOctlbbZ2tEwk6x3 GEj/h/Riz26DKvA30dmbr5VecNcorRCqqfYT69XsKkbPLidrw1uGLoHXdqRy71um9+BX ES3w== 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=iP0RIMIP0Dhv0Z3VwimEl1gZSo5mPCskMpjat/g+ZWI=; b=a5cuwiiS17ddfiCeqb+tSjzSJ+w2GU70AVI439vyyKrbmKMn8J8pWk8J/H151yRfIx e8CixEaZ0MbOss4yyz168QZwGWs9pPiJbsML05plEaGOHB8vj0INcOL7oZiqbLVnyOS4 iDw8k0jCdt1UzDeR86pv2yVvxb3FSXdfHGe0J8r6bRNl773pJ/WIjQf4Runj0mlKJxh/ JGQBEPiC5aBSGlrKnO0ERyxjAfJ3EnDdBR/HIkMJcsZcHOGiebEZnmgPIMCCtZuFJ/4/ zT7M5VUhwi3sj2GUMh5QHeE+S4FQ03Q4jO8en3OG4P9KXreW9PI44Dnvnj22jxNxDY6j 1wvQ== X-Gm-Message-State: APjAAAVLvuajTrS5Jd2e9YPB1fuMBJ6YCzvNkB+WYTEboCBA33erI/kV ly1YNTNMtXEN8aJ+KBFYa0OYhMnIpKN4dg== X-Google-Smtp-Source: APXvYqys/fbXqgURwR1PbWrDiThPOX1HA8pdaQ59Q3iqAm147y+KQTuhOCcF7kRmF6ppefgBEartMw== X-Received: by 2002:a62:1d8c:: with SMTP id d134mr4453958pfd.185.1552661987812; Fri, 15 Mar 2019 07:59:47 -0700 (PDT) Received: from x1.localdomain (66.29.188.166.static.utbb.net. [66.29.188.166]) by smtp.gmail.com with ESMTPSA id f28sm4287179pfh.178.2019.03.15.07.59.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Mar 2019 07:59:46 -0700 (PDT) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Cc: viro@ZenIV.linux.org.uk, Jens Axboe Subject: [PATCH 3/3] io_uring: add io_uring_event cache hit information Date: Fri, 15 Mar 2019 08:59:38 -0600 Message-Id: <20190315145938.21516-4-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190315145938.21516-1-axboe@kernel.dk> References: <20190315145938.21516-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 | 6 +++++- include/uapi/linux/io_uring.h | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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 */