From patchwork Fri May 15 16:38:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 11552531 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39707739 for ; Fri, 15 May 2020 16:38:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E71020787 for ; Fri, 15 May 2020 16:38:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WBNncdt1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbgEOQiO (ORCPT ); Fri, 15 May 2020 12:38:14 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:45511 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726226AbgEOQiN (ORCPT ); Fri, 15 May 2020 12:38:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589560691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6gZ5R0zPx7v8Q5QUl+dC4PL1yY2tt7RqoIbj3l8sE74=; b=WBNncdt1WHG7GWcgKVRt8rt2N13DCbiK6q+AhKuFHyxo8eYJoWkD3WfJe9AhscTQZZ1c8N v3G6VXSanEy6EWYyKsyKani4y+JKU7MEtNG9LEXFRSk3jaDt9PdVlpJeHDi9brC8qCHLeZ pFOftlHi3VNgaeNNoDPULGVZxFLpLRs= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-eTjirXGAPGCL3FkQGzQiVg-1; Fri, 15 May 2020 12:38:10 -0400 X-MC-Unique: eTjirXGAPGCL3FkQGzQiVg-1 Received: by mail-wm1-f71.google.com with SMTP id l26so1236237wmh.3 for ; Fri, 15 May 2020 09:38:09 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=6gZ5R0zPx7v8Q5QUl+dC4PL1yY2tt7RqoIbj3l8sE74=; b=Wj6W0WdNxTljPc/ozAqcpJB6AvOFg8vT6Ib2pO5kW4ZzLEMdUZlnYbVnKWZ2eGvSIC Cvd7keNHmzT0Byx/cz5m5Cj9daGFKgpHK+rdJyGGYGaD1KH7NZiJ0uVwokKnoI7hl5J+ DhIIVl4nTiXD/PPYwDkWvJkcD6vYlDve1TVpqpJOiRiqeR4B36uNCIQaMGDsnUW5m405 S6XNJJvi837DQ5720hENEw0l1iZy5bpGqHGMDl4Tc+ZHu55ulBsPR8VLH9n5VEUIYhV4 NriVeJFq76qaThknzusTgVxfa6+txtbCVSVnlV9RhdTCDUCTIILvmAT2ejq4hQHFAtin rPEg== X-Gm-Message-State: AOAM531kS27gcV/N65OXTzmn7HbGRI0ryuHOJSQysMZbOG7OZ4+Z7BLT cdh6wZwakiADBVUdAk1fX9I47IV/IbJELyDfEHK9xO34CaSFJVqLj1ABhxAeLlj+U5zJ2sjeTxK KbUicmDgVfYVnCLdYTU8HCrjakA== X-Received: by 2002:adf:dc0f:: with SMTP id t15mr5068324wri.165.1589560688994; Fri, 15 May 2020 09:38:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF+hp4GbO5uog6iIPuueL5jjs4PZEKrB1UaoTN20cj9bx0TDVFE81Yzd2+7qty/BxbZXjrMA== X-Received: by 2002:adf:dc0f:: with SMTP id t15mr5068296wri.165.1589560688701; Fri, 15 May 2020 09:38:08 -0700 (PDT) Received: from steredhat.redhat.com ([79.49.207.108]) by smtp.gmail.com with ESMTPSA id b145sm4680274wme.41.2020.05.15.09.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 09:38:08 -0700 (PDT) From: Stefano Garzarella To: Jens Axboe Cc: linux-kernel@vger.kernel.org, Alexander Viro , io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 1/2] io_uring: add 'cq_flags' field for the CQ ring Date: Fri, 15 May 2020 18:38:04 +0200 Message-Id: <20200515163805.235098-2-sgarzare@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200515163805.235098-1-sgarzare@redhat.com> References: <20200515163805.235098-1-sgarzare@redhat.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This patch adds the new 'cq_flags' field that should be written by the application and read by the kernel. This new field is available to the userspace application through 'cq_off.flags'. We are using 4-bytes previously reserved and set to zero. This means that if the application finds this field to zero, then the new functionality is not supported. In the next patch we will introduce the first flag available. Signed-off-by: Stefano Garzarella --- fs/io_uring.c | 10 +++++++++- include/uapi/linux/io_uring.h | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 979d9f977409..6e8158269f3c 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -142,7 +142,7 @@ struct io_rings { */ u32 sq_dropped; /* - * Runtime flags + * Runtime SQ flags * * Written by the kernel, shouldn't be modified by the * application. @@ -151,6 +151,13 @@ struct io_rings { * for IORING_SQ_NEED_WAKEUP after updating the sq tail. */ u32 sq_flags; + /* + * Runtime CQ flags + * + * Written by the application, shouldn't be modified by the + * kernel. + */ + u32 cq_flags; /* * Number of completion events lost because the queue was full; * this should be avoided by the application by making sure @@ -7834,6 +7841,7 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p, p->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries); p->cq_off.overflow = offsetof(struct io_rings, cq_overflow); p->cq_off.cqes = offsetof(struct io_rings, cqes); + p->cq_off.flags = offsetof(struct io_rings, cq_flags); p->features = IORING_FEAT_SINGLE_MMAP | IORING_FEAT_NODROP | IORING_FEAT_SUBMIT_STABLE | IORING_FEAT_RW_CUR_POS | diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index e48d746b8e2a..602bb0ece607 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -204,7 +204,9 @@ struct io_cqring_offsets { __u32 ring_entries; __u32 overflow; __u32 cqes; - __u64 resv[2]; + __u32 flags; + __u32 resv1; + __u64 resv2; }; /* From patchwork Fri May 15 16:38:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 11552533 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E42FF739 for ; Fri, 15 May 2020 16:38:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD8F92076A for ; Fri, 15 May 2020 16:38:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XIjfRydh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726233AbgEOQiP (ORCPT ); Fri, 15 May 2020 12:38:15 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:30428 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726294AbgEOQiO (ORCPT ); Fri, 15 May 2020 12:38:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589560693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YZmrRZSpZSImU0ZWw6sQoh3piuQw6gdHG9URSW684/o=; b=XIjfRydhU0zefeOxzx4Cq1p9jYq3vcNMShDMZAOeCjJuOCEtGOWhHalu+s9UGULUdM9Uo8 pJ29HaSuQ3h4zQjarTffc6cdVpPxeUZvoaBKdCvLmm4tI1WAsG8UbezBuH3xhZcTGdSc3e AbBr8RlM4beXYACQzMZDjQ83kiamabM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-284-fKT5OynBMg25p2NPVNr1Ow-1; Fri, 15 May 2020 12:38:11 -0400 X-MC-Unique: fKT5OynBMg25p2NPVNr1Ow-1 Received: by mail-wr1-f69.google.com with SMTP id e14so1434967wrv.11 for ; Fri, 15 May 2020 09:38:11 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=YZmrRZSpZSImU0ZWw6sQoh3piuQw6gdHG9URSW684/o=; b=FhFh1+DSFPs9ST5IB6+gm3a+0WZ9PwXB4kNtre+H124KId++dTg8U5cVPzbpnZmb5j 8yDx1wYb7KlqO+fgk5juJFtdeweEhCnjFWjhbOP3/A0kEDBbdnOoc4EZ1bM1CF84AowP DTzSFaZ1JKQ+2+cKqjPNqNVAr9fmV7x07qaRCkjAONTDSmDfE34DzTSp0RPA4EcR3oPA jZl8MCUocLlINiLb7bejjbP0NbrhktUAbDLnFG3asYl7DCHcj3KH+fs/QVgObxxv/0I7 pDBBq94JQkeiShDqmAcRD8Er3SMWVhqai7pZcB/ggWpsDXBJZ6c68IsocIU07pZ/CELC kf4g== X-Gm-Message-State: AOAM531NGtJctSmcRDcZNCWFDYjxE7adsDjfvDEuUdmuj8eQSEwvKCNK TN++sy9jogtdiViZ+6TlmHcZ/QgcXX3Y0ExKGj6OCE0llO5QkOWGBzXmS/R60TiTWJMAlYHcuxy gHVDOABOmDVYP0K4RmyQiUKiGaA== X-Received: by 2002:adf:ed82:: with SMTP id c2mr5379928wro.255.1589560690177; Fri, 15 May 2020 09:38:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHkK+pYRdkGRoBHu7DvxKUQxjk5W5DN2qukBf2VTAqpWYC92WZ6RC31kIRR64YG+MD9jnxcw== X-Received: by 2002:adf:ed82:: with SMTP id c2mr5379900wro.255.1589560689927; Fri, 15 May 2020 09:38:09 -0700 (PDT) Received: from steredhat.redhat.com ([79.49.207.108]) by smtp.gmail.com with ESMTPSA id b145sm4680274wme.41.2020.05.15.09.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 09:38:09 -0700 (PDT) From: Stefano Garzarella To: Jens Axboe Cc: linux-kernel@vger.kernel.org, Alexander Viro , io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 2/2] io_uring: add IORING_CQ_EVENTFD_DISABLED to the CQ ring flags Date: Fri, 15 May 2020 18:38:05 +0200 Message-Id: <20200515163805.235098-3-sgarzare@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200515163805.235098-1-sgarzare@redhat.com> References: <20200515163805.235098-1-sgarzare@redhat.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This new flag should be set/clear from the application to disable/enable eventfd notifications when a request is completed and queued to the CQ ring. Before this patch, notifications were always sent if an eventfd is registered, so IORING_CQ_EVENTFD_DISABLED is not set during the initialization. It will be up to the application to set the flag after initialization if no notifications are required at the beginning. Signed-off-by: Stefano Garzarella --- v1 -> v2: - changed the flag name and behaviour from IORING_CQ_NEED_EVENT to IORING_CQ_EVENTFD_DISABLED [Jens] --- fs/io_uring.c | 2 ++ include/uapi/linux/io_uring.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index 6e8158269f3c..a9b194e9b5bd 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1152,6 +1152,8 @@ static inline bool io_should_trigger_evfd(struct io_ring_ctx *ctx) { if (!ctx->cq_ev_fd) return false; + if (READ_ONCE(ctx->rings->cq_flags) & IORING_CQ_EVENTFD_DISABLED) + return false; if (!ctx->eventfd_async) return true; return io_wq_current_is_worker(); diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 602bb0ece607..8c5775df08b8 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -209,6 +209,13 @@ struct io_cqring_offsets { __u64 resv2; }; +/* + * cq_ring->flags + */ + +/* disable eventfd notifications */ +#define IORING_CQ_EVENTFD_DISABLED (1U << 0) + /* * io_uring_enter(2) flags */