Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3647198imw; Thu, 7 Jul 2022 05:28:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t9yY7rp0cbp7FFUr91iJrcMZOUz1Q3dDGty5SKKtjFLlCJBdowkk7ehaOmj3IsGSDCFY5w X-Received: by 2002:a17:907:2889:b0:72a:f8a1:338c with SMTP id em9-20020a170907288900b0072af8a1338cmr8036268ejc.566.1657196903693; Thu, 07 Jul 2022 05:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657196903; cv=none; d=google.com; s=arc-20160816; b=wf+ctP6d3PZKc+goIj/tgYfNHBnLfcmhZSweypM+KVuY2QYaAVe5yZr3VyEeNEWFAP ovuyz8r+fipMdoIsx7ft07RDHNeD8dNMflOvB7jM5lxT7ZZh0CTNRf6cnImeGEMaUG3y dAynUDUWVHa1F6SD5N54zqnkd2Ejjm5LbRHsx1g292fQJNbed6nd1mAfH539ERz63WmN q/FpaC72DYo0909SvjEZF75jEcsKrMHfpRQ2MT2lGbd4VNgnmAZ6fuo7eneOm/fDvhpB bc8t99vuKmOZtLUPpbmgjbJlmwrm+KZU0v+PeEJAOFJm6G8wolD1sNDHCgZk4IbOQ/rD 0ICA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WVXTlEzEGbco4l2SuKTPybZhQRTUVdDBCHHo07YwDPw=; b=xQeaqDhXMXOhfR8T9j9Ux0ybZRW0QJNFEu2694/kneH694CWYxS50oPUFMvTJfAflS hpDfGX8/F05EtWydwT87YNU/6g+WpShQtiuz8z6EQVwb4qOB2hEr9M/b1oJ2bRKqF/uw 5r4XRhmGB82CE4WFivCH5CiM5pbFzLdchyOVDrfp9PKCE9aHfF0VUUeK7hnwOYnIO04+ 9OqPRb71ZLC8qObEeLR3D/MKXDW9v9+iKs6ZfC2jQcxlVRb58dEsipk9TZT7HXRk6AsN J+xOqt5iO8yQo67uAXQyJgh1gNkqZQwaul5lcEFXC7akIDiZ+OquKAdpMv5BX/sK+v55 u/2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PHD4hGtV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh39-20020a1709076ea700b00711ff36ad6bsi28871590ejc.498.2022.07.07.05.27.56; Thu, 07 Jul 2022 05:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PHD4hGtV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235597AbiGGLxg (ORCPT + 99 others); Thu, 7 Jul 2022 07:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235453AbiGGLwf (ORCPT ); Thu, 7 Jul 2022 07:52:35 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 395FC5722A; Thu, 7 Jul 2022 04:52:16 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id o16-20020a05600c379000b003a02eaea815so970614wmr.0; Thu, 07 Jul 2022 04:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WVXTlEzEGbco4l2SuKTPybZhQRTUVdDBCHHo07YwDPw=; b=PHD4hGtVKinSi2VEzrOqtMQcPXveAsfopjXXoh+/bET9mrNZz6XUNb5AE9eVCKMj4J 968c3dnP8ePBlOJR30F/OAkI+rnOF+yBVbGhqePiHA3k21fsLLzBniqN6+N6fASSBOPs va7A3XspOdLLDDqq5GsHgBplFRWLQplcy+2cYwLpIk8OXDD9s9eR5ZyXLce/M/0knooF SlbWxGdY7USmZ2a8a11yoXDutWIVb6MTocR6mlpBGneS7Vhzueda1cu1XGNmyVdiNL23 ny7+AaJcxBtm2wj4SQxLfNcJBKRfak/CCizQb74jR5iCgFSShP9GP6OSGGAWxBSTkXXW VcYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WVXTlEzEGbco4l2SuKTPybZhQRTUVdDBCHHo07YwDPw=; b=X2m+mYX+1xiPQ2PggYNhI8P2KWKg6yhLdWwVGAyy4tCB7U9WJPWjVTVxYToI29hI62 sFVMQa0hyOtmJe7rDp7/0+RqFeBNDSfGw11J6aJNwG2OgUPG+Ewk127/imF0fBE+pWoz ytTzR18O63hVOLwSxjEU8YnXetpSTpKvnUFlOBRBbrniKDhFZwoTAHhttf3mFTrNYO0O Mn4W1FOWGvdFtizYkLb2C+mJ/IlwvXxPAvSsIPjzIGXPOI47A2OV21tA9YCQjNfYV5eM OBNxQKMDvL8H1d2KQturXZZo1+Tp/HGu9/UgkIaDNrBuNM2zCydHE88108i2kEbkP22s Hqyg== X-Gm-Message-State: AJIora8RvBkLeGv17oSY08CMfZmC1DY57QzSrZ1YMHWU/zi9yzOJwubl U6+ADHzZVxvAggMEHuv8/kxoR6aour3GjliCxAA= X-Received: by 2002:a05:600c:3d11:b0:3a1:8c05:6e75 with SMTP id bh17-20020a05600c3d1100b003a18c056e75mr3949490wmb.203.1657194735504; Thu, 07 Jul 2022 04:52:15 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.125.106.threembb.co.uk. [188.28.125.106]) by smtp.gmail.com with ESMTPSA id u2-20020a5d5142000000b0021b966abc19sm37982131wrt.19.2022.07.07.04.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 04:52:15 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S . Miller" , Jakub Kicinski , Jonathan Lemon , Willem de Bruijn , Jens Axboe , David Ahern , kernel-team@fb.com, Pavel Begunkov Subject: [PATCH net-next v4 25/27] io_uring: add zc notification flush requests Date: Thu, 7 Jul 2022 12:49:56 +0100 Message-Id: X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Overlay notification control onto IORING_OP_RSRC_UPDATE (former IORING_OP_FILES_UPDATE). It allows to flush a range of zc notifications from slots with indexes [sqe->off, sqe->off+sqe->len). If sqe->arg is not zero, it also copies sqe->arg as a new tag for all flushed notifications. Note, it doesn't flush a notification of a slot if there was no requests attached to it (since last flush or registration). Signed-off-by: Pavel Begunkov --- include/uapi/linux/io_uring.h | 1 + io_uring/rsrc.c | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 9e325179a4f8..cbf9cfbe5fe7 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -294,6 +294,7 @@ enum io_uring_op { */ enum { IORING_RSRC_UPDATE_FILES, + IORING_RSRC_UPDATE_NOTIF, }; /* diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index 98ce8a93a816..088a2dc32e2c 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -15,6 +15,7 @@ #include "io_uring.h" #include "openclose.h" #include "rsrc.h" +#include "notif.h" struct io_rsrc_update { struct file *file; @@ -742,6 +743,41 @@ static int io_files_update(struct io_kiocb *req, unsigned int issue_flags) return IOU_OK; } +static int io_notif_update(struct io_kiocb *req, unsigned int issue_flags) +{ + struct io_rsrc_update *up = io_kiocb_to_cmd(req); + struct io_ring_ctx *ctx = req->ctx; + unsigned len = up->nr_args; + unsigned idx_end, idx = up->offset; + int ret = 0; + + io_ring_submit_lock(ctx, issue_flags); + if (unlikely(check_add_overflow(idx, len, &idx_end))) { + ret = -EOVERFLOW; + goto out; + } + if (unlikely(idx_end > ctx->nr_notif_slots)) { + ret = -EINVAL; + goto out; + } + + for (; idx < idx_end; idx++) { + struct io_notif_slot *slot = &ctx->notif_slots[idx]; + + if (!slot->notif) + continue; + if (up->arg) + slot->tag = up->arg; + io_notif_slot_flush_submit(slot, issue_flags); + } +out: + io_ring_submit_unlock(ctx, issue_flags); + if (ret < 0) + req_set_fail(req); + io_req_set_res(req, ret, 0); + return IOU_OK; +} + int io_rsrc_update(struct io_kiocb *req, unsigned int issue_flags) { struct io_rsrc_update *up = io_kiocb_to_cmd(req); @@ -749,6 +785,8 @@ int io_rsrc_update(struct io_kiocb *req, unsigned int issue_flags) switch (up->type) { case IORING_RSRC_UPDATE_FILES: return io_files_update(req, issue_flags); + case IORING_RSRC_UPDATE_NOTIF: + return io_notif_update(req, issue_flags); } return -EINVAL; } -- 2.36.1