From patchwork Mon Sep 26 15:14:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12989063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90B43C32771 for ; Mon, 26 Sep 2022 16:25:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234850AbiIZQZd (ORCPT ); Mon, 26 Sep 2022 12:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234920AbiIZQZF (ORCPT ); Mon, 26 Sep 2022 12:25:05 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ACF415A23 for ; Mon, 26 Sep 2022 08:14:23 -0700 (PDT) Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28QEkvah030359 for ; Mon, 26 Sep 2022 08:14:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=U1X2deYCznWfYeH2ELATLj6Mttpb2cNoeV62gmKj8SA=; b=GNp8huoOr2H9UzoOGsOqINEuiwTy//scsJc2vNV9bZzpbUMOl2UhHnA9l22foHtmzcfg qlyLlhHmVCLRmKfYUSX/htGgILt8hzajdi6wNml9fvUM1zAFjFO6rdDZdb4hu8xr9nAO yjhtxu24U9vUb2YWY6b+EiICgPU6B6govng= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3jsyn03h06-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 26 Sep 2022 08:14:23 -0700 Received: from twshared14494.08.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::d) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 26 Sep 2022 08:14:22 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id ABA976AF7F4A; Mon, 26 Sep 2022 08:14:17 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov CC: , , Dylan Yudaken Subject: [PATCH liburing 1/2] handle single issuer task registration at ring creation Date: Mon, 26 Sep 2022 08:14:11 -0700 Message-ID: <20220926151412.2515493-2-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220926151412.2515493-1-dylany@fb.com> References: <20220926151412.2515493-1-dylany@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: uUYUnd8sndoS0O14WmDlYgAN5SghXAYG X-Proofpoint-ORIG-GUID: uUYUnd8sndoS0O14WmDlYgAN5SghXAYG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-26_08,2022-09-22_02,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org IORING_SETUP_SINGLE_ISSUER now registers the task at ring creation, so update the tests and documentation to reflect this. Signed-off-by: Dylan Yudaken --- man/io_uring_setup.2 | 8 ++++---- test/defer-taskrun.c | 12 ++++-------- test/single-issuer.c | 14 +++++++------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/man/io_uring_setup.2 b/man/io_uring_setup.2 index fb1f90dc2ebc..afeee858c458 100644 --- a/man/io_uring_setup.2 +++ b/man/io_uring_setup.2 @@ -241,14 +241,14 @@ only the passthrough command for NVMe passthrough needs this. Available since 5.19. .TP .B IORING_SETUP_SINGLE_ISSUER -A hint to the kernel that only a single task can submit requests, which is used -for internal optimisations. The kernel enforces the rule, which only affects +A hint to the kernel that only a single task (or thread) will submit requests, which is +used for internal optimisations. This task must be the one that created the ring, and +the kernel enforces this rule. This only affects .I io_uring_enter(2) calls submitting requests and will fail them with .B -EEXIST if the restriction is violated. -The submitter task may differ from the task that created the ring. Note that when .B IORING_SETUP_SQPOLL is set it is considered that the polling task is doing all submissions @@ -256,7 +256,7 @@ on behalf of the userspace and so it always complies with the rule disregarding how many userspace tasks do .I io_uring_enter(2). -Available since 5.20. +Available since 6.0. .TP .B IORING_SETUP_DEFER_TASKRUN By default, io_uring will process all outstanding work at the end of any system diff --git a/test/defer-taskrun.c b/test/defer-taskrun.c index c6e0ea0d6c99..2c4ed6df37d3 100644 --- a/test/defer-taskrun.c +++ b/test/defer-taskrun.c @@ -123,6 +123,9 @@ void *thread(void *t) { struct thread_data *td = t; + assert(io_uring_queue_init(8, &td->ring, IORING_SETUP_SINGLE_ISSUER | + IORING_SETUP_DEFER_TASKRUN) == 0); + io_uring_prep_read(io_uring_get_sqe(&td->ring), td->efd, td->buff, sizeof(td->buff), 0); io_uring_submit(&td->ring); @@ -132,23 +135,16 @@ void *thread(void *t) static int test_thread_shutdown(void) { pthread_t t1; - int ret; struct thread_data td; struct io_uring_cqe *cqe; uint64_t val = 1; - ret = io_uring_queue_init(8, &td.ring, IORING_SETUP_SINGLE_ISSUER | - IORING_SETUP_DEFER_TASKRUN); - if (ret) - return ret; - - CHECK(io_uring_get_events(&td.ring) == -EEXIST); - td.efd = eventfd(0, 0); CHECK(td.efd >= 0); CHECK(pthread_create(&t1, NULL, thread, &td) == 0); CHECK(pthread_join(t1, NULL) == 0); + CHECK(io_uring_get_events(&td.ring) == -EEXIST); CHECK(write(td.efd, &val, sizeof(val)) == sizeof(val)); CHECK(io_uring_wait_cqe(&td.ring, &cqe) == -EEXIST); diff --git a/test/single-issuer.c b/test/single-issuer.c index 29830f1af998..55af98f300aa 100644 --- a/test/single-issuer.c +++ b/test/single-issuer.c @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) if (!fork_t()) { ret = try_submit(&ring); if (ret != -EEXIST) - fprintf(stderr, "not owner child could submit %i\n", ret); + fprintf(stderr, "1: not owner child could submit %i\n", ret); return ret != -EEXIST; } wait_child_t(); @@ -109,9 +109,9 @@ int main(int argc, char *argv[]) if (!fork_t()) { ret = try_submit(&ring); - if (ret) - fprintf(stderr, "not owner child could submit %i\n", ret); - return !!ret; + if (ret != -EEXIST) + fprintf(stderr, "2: not owner child could submit %i\n", ret); + return ret != -EEXIST; } wait_child_t(); io_uring_queue_exit(&ring); @@ -143,9 +143,9 @@ int main(int argc, char *argv[]) if (!fork_t()) { ret = try_submit(&ring); - if (ret) - fprintf(stderr, "not owner child could submit %i\n", ret); - return !!ret; + if (ret != -EEXIST) + fprintf(stderr, "3: not owner child could submit %i\n", ret); + return ret != -EEXIST; } wait_child_t(); io_uring_queue_exit(&ring); From patchwork Mon Sep 26 15:14:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12989061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 033E1C32771 for ; Mon, 26 Sep 2022 16:25:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236346AbiIZQZb (ORCPT ); Mon, 26 Sep 2022 12:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234858AbiIZQZE (ORCPT ); Mon, 26 Sep 2022 12:25:04 -0400 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F359815729 for ; Mon, 26 Sep 2022 08:14:23 -0700 (PDT) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 28QD7aqG013837 for ; Mon, 26 Sep 2022 08:14:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=1e9vWCAVJyP0v5XEjApMCq1DhjsimJ8I74uggNCiJHk=; b=K3assWhcBQMtDuNWj+iiS026j69UTEua2PUyAd+AueVVsMylaWALCaJtamwK239cawS0 uz84QLq2aMqbiIzAa5b1ROiLLiWnQzO7GZEg2BZGIoUI4iF4XMVQmVmVtpS3Xkn9CqDH 1YNwT14Akg4oDAi/Avun0FyM01PulVy3Xcs= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 3jswd7uvnr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 26 Sep 2022 08:14:23 -0700 Received: from twshared14494.08.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 26 Sep 2022 08:14:22 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 1930F6AF7F50; Mon, 26 Sep 2022 08:14:18 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov CC: , , Dylan Yudaken Subject: [PATCH liburing 2/2] update documentation to reflect no 5.20 kernel Date: Mon, 26 Sep 2022 08:14:12 -0700 Message-ID: <20220926151412.2515493-3-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220926151412.2515493-1-dylany@fb.com> References: <20220926151412.2515493-1-dylany@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: OmFRMqoSgMp6XWLp97CoSrk_WM-1Vz7B X-Proofpoint-GUID: OmFRMqoSgMp6XWLp97CoSrk_WM-1Vz7B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-26_08,2022-09-22_02,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org The documentation referenced the wrong kernel version. Signed-off-by: Dylan Yudaken --- man/io_uring_prep_recv.3 | 2 +- man/io_uring_prep_recvmsg.3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/io_uring_prep_recv.3 b/man/io_uring_prep_recv.3 index 60a77fc241b5..b3862369affa 100644 --- a/man/io_uring_prep_recv.3 +++ b/man/io_uring_prep_recv.3 @@ -55,7 +55,7 @@ If a posted CQE does not have the .B IORING_CQE_F_MORE flag set then the multishot receive will be done and the application should issue a new request. -Multishot variants are available since kernel 5.20. +Multishot variants are available since kernel 6.0. After calling this function, additional io_uring internal modifier flags diff --git a/man/io_uring_prep_recvmsg.3 b/man/io_uring_prep_recvmsg.3 index 07096ee4826c..65f324dfef9b 100644 --- a/man/io_uring_prep_recvmsg.3 +++ b/man/io_uring_prep_recvmsg.3 @@ -65,7 +65,7 @@ submitted with the request. See .B io_uring_recvmsg_out (3) for more information on accessing the data. -Multishot variants are available since kernel 5.20. +Multishot variants are available since kernel 6.0. After calling this function, additional io_uring internal modifier flags may be set in the SQE