From patchwork Thu Mar 14 20:44:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10853583 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 5069A1874 for ; Thu, 14 Mar 2019 20:44:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41F1C2A650 for ; Thu, 14 Mar 2019 20:44:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 369152A654; Thu, 14 Mar 2019 20:44:58 +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 E17152A650 for ; Thu, 14 Mar 2019 20:44:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727941AbfCNUo4 (ORCPT ); Thu, 14 Mar 2019 16:44:56 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:37518 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727931AbfCNUo4 (ORCPT ); Thu, 14 Mar 2019 16:44:56 -0400 Received: by mail-it1-f195.google.com with SMTP id z124so7346547itc.2 for ; Thu, 14 Mar 2019 13:44:56 -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=aGFJ5HGPoz/ktnKoEe1M9JMfYCh1Xl63PfrPUdXe2mU=; b=dpwVwuZfEY46gyqEya30pK4loHBgwJ0o32ppkgOurjxCt0x7yxUa2cqsjEp6bM1Wgc pwtsDuM9qi5q5+Uz1umiQB1BIH27t0EgOhEi9k9mxgK3BMLIjvM4lUtkROhx12B00WW8 /Q8Hub2ikfHdg7QglxI9rH1zz/EHz009umbnKy0jx+0FDtys9SI1oy9Kbs4HD66g20Bz 5VMDhsC/xEBwNZgTja/UJ/EiaSb2LbdNO/wKAOiFiAmZOausj39K9QJ0HW2/Wr61FRnb 0HevPn3k2XnqykEyyTxCcIKguy8buPvmimMeVoxLLVg6qYUPyyziZN6MbjYHlk2IjPjI +80Q== 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=aGFJ5HGPoz/ktnKoEe1M9JMfYCh1Xl63PfrPUdXe2mU=; b=tkkKUIybnoZJw8vriYaRNILYKkDOLLIg1rJt/w7XoLgPDBwQFbqYPuKolO0sCyP5b+ OmGeApYhm1y9JJMqvS5FlBzwKe0n2ypKPODjnIL9dthiltnEwRYiU3zF2bYdsmk8QZUW g9auHDPqc99/sbaHnnOUa1wd3mC67zVR6LlmYnJJPHe5LxHnZR9T8agBpIIR5mJXbyDH A2TS82QBwMF9H1ViN3yDvgceiW2nNEpHK50zUnn2Rpb9FTguCdtlO4cORKvFLKoZASe8 0G9zfODW3Uiby4YV6iyOGuoqhrVQa8cOvO6N2n47M7Jqu4UqyGQPyBgsb2y3B0+IXMkK axDQ== X-Gm-Message-State: APjAAAXwKD+NitwNHVulWLbEap6T1jWvEIVBOKjL2rLe/O2tDu8MbnTm zEPF8mO+FV+YeclveTFuQrEdXXkKgdFOIw== X-Google-Smtp-Source: APXvYqzh7OViW2aFBiKTuBennqWW2dDjWk3E5qSf4Y4qA51RoR1yywPEuiY+bO7OMV06pEVMtOo5RQ== X-Received: by 2002:a02:a903:: with SMTP id n3mr148847jam.3.1552596295243; Thu, 14 Mar 2019 13:44:55 -0700 (PDT) Received: from x1.thefacebook.com ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id w19sm1820538ita.33.2019.03.14.13.44.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 13:44:54 -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 8/8] io_uring: add io_uring_event cache hit information Date: Thu, 14 Mar 2019 14:44:35 -0600 Message-Id: <20190314204435.7692-9-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190314204435.7692-1-axboe@kernel.dk> References: <20190314204435.7692-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 b89f91ab6e32..3437f538b377 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -625,10 +625,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 */