From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Axboe Subject: [PATCH 16/16] io_uring: add io_uring_event cache hit information Date: Mon, 14 Jan 2019 19:55:31 -0700 Message-ID: <20190115025531.13985-17-axboe@kernel.dk> References: <20190115025531.13985-1-axboe@kernel.dk> Cc: hch@lst.de, jmoyer@redhat.com, avi@scylladb.com, Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-block@vger.kernel.org, linux-arch@vger.kernel.org Return-path: In-Reply-To: <20190115025531.13985-1-axboe@kernel.dk> Sender: owner-linux-aio@kvack.org List-Id: linux-fsdevel.vger.kernel.org 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 fd89fcecd8e2..4a74a40cd134 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -546,11 +546,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_fill_event(req->ctx, req->user_data, res, 0); + + if (res > 0 && (req->flags & REQ_F_FORCE_NONBLOCK)) + ev_flags = IOCQE_FLAG_CACHEHIT; + + io_cqring_fill_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 3f367be56a9e..71e92026d26c 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 (1 << 0) /* IO did not hit media */ + /* * Magic offsets for the application to mmap the data it needs */ -- 2.17.1 -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to majordomo@kvack.org. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: aart@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3DF7C43444 for ; Tue, 15 Jan 2019 02:56:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3998206BA for ; Tue, 15 Jan 2019 02:56:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="d2A7qeDu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727981AbfAOC4L (ORCPT ); Mon, 14 Jan 2019 21:56:11 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39095 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727996AbfAOC4K (ORCPT ); Mon, 14 Jan 2019 21:56:10 -0500 Received: by mail-pl1-f195.google.com with SMTP id 101so573206pld.6 for ; Mon, 14 Jan 2019 18:56:09 -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=oEF+pnA/FRpVwgmNK0tM84y/kmrmPYkGmk6f6LS/rXc=; b=d2A7qeDud021+2iozRx0N/q/8ReDymLRkWQzsPs2hy/QXoid3tkzeKpeDJd4VQVRZj rNIdGYOeq2RNCxbS2mHxQwOQ+fR4PfEHY7/2tgbXuMq9fXS7IRzUykmBAWv6xsFOzkpf obz9jUK9LAsb4Qu5AAG+G+VySPVW0/OIuDHDXH753oQ2nSzBmInZOE6/zi2W66VuP3TC 1eetFGAEr1lmklToXas/Do1GmlCtKI/2+o0E2AAySd/HdCzUj1LvxLIUznhv/82nMtJ4 AE4vKclHCOes9VCLosyOYYRaCFcReNkeltmi7pGXxgjs8dQAyEtLuRVWhatLzpBVJeEg qOCQ== 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=oEF+pnA/FRpVwgmNK0tM84y/kmrmPYkGmk6f6LS/rXc=; b=j5qWkb+umET/Cy76lJJe6gy0+Btahj1CiGcM71cqKFnSaXjfwh22rNXoJ9tLl+OkHn P0Ek+2+CrEBJA6Io8gmZgz8s+fFAT21Z34/rHyqqdrePbwj90aT5YhaxKcJ6v/QQtoxB trxmazBZ5yTzrr1HUXMHoII5clkdrbUXsv1zZ9RuUvIwroGRASTgBVuQL2fMOW70hTR1 mWg/AqlOS8EJOfOVvA9MxMNtIYrQ0X/avwpjK5fRs/mndjMGGNDeDlbGRg1C3CfMZ7E0 pK+QrS2/jcY5Aogl5gXUtMOQaYmXoRXkmXrAcOJSBwtZBKwVTVhTUsBXOVd9jqcvb6cn vPxQ== X-Gm-Message-State: AJcUukdMedgE58zNPe5j3qyOXuuUOvWAUkIKtzXEPJFTj/12/PpV0dK+ +M4w5gs/fi0wokRS2pBGhHhTir89Po49kw== X-Google-Smtp-Source: ALg8bN6p06+HK1G/4eb6IS4ewUxvAznbrnqaLgr7X2e6Z7gocVAB+s6lDpe7GoAFgGozNwEHO0Tdrw== X-Received: by 2002:a17:902:59c8:: with SMTP id d8mr1788296plj.116.1547520968966; Mon, 14 Jan 2019 18:56:08 -0800 (PST) Received: from x1.localdomain (66.29.188.166.static.utbb.net. [66.29.188.166]) by smtp.gmail.com with ESMTPSA id c23sm2415544pfi.83.2019.01.14.18.56.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:56:08 -0800 (PST) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-block@vger.kernel.org, linux-arch@vger.kernel.org Cc: hch@lst.de, jmoyer@redhat.com, avi@scylladb.com, Jens Axboe Subject: [PATCH 16/16] io_uring: add io_uring_event cache hit information Date: Mon, 14 Jan 2019 19:55:31 -0700 Message-Id: <20190115025531.13985-17-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115025531.13985-1-axboe@kernel.dk> References: <20190115025531.13985-1-axboe@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Message-ID: <20190115025531.p24QpVCo3WZ_knm0EBNRmAKt_Nc1tbM1m3ii8NjSgKg@z> 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 fd89fcecd8e2..4a74a40cd134 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -546,11 +546,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_fill_event(req->ctx, req->user_data, res, 0); + + if (res > 0 && (req->flags & REQ_F_FORCE_NONBLOCK)) + ev_flags = IOCQE_FLAG_CACHEHIT; + + io_cqring_fill_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 3f367be56a9e..71e92026d26c 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 (1 << 0) /* IO did not hit media */ + /* * Magic offsets for the application to mmap the data it needs */ -- 2.17.1