From patchwork Tue Jun 14 14:36:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12881195 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 D8F27C43334 for ; Tue, 14 Jun 2022 14:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235379AbiFNOhT (ORCPT ); Tue, 14 Jun 2022 10:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbiFNOhS (ORCPT ); Tue, 14 Jun 2022 10:37:18 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B683BF92 for ; Tue, 14 Jun 2022 07:37:17 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id v14so11582821wra.5 for ; Tue, 14 Jun 2022 07:37:17 -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=FtwqEhPzT3nHMQBDGkRoV01F2A3n7O/yvr9Y5995Vdg=; b=iTTyD5Nmxt+1d3T4z8tihEM1OaXHSotP6JShSZd22MmXvL/p2NPhMW9OUoHbFyodAK xNfW2szfiZx04CMsc23KjH2NVPTJZYmul4yZKNh73uhQKu7k5e26z8iqMvmIUFnrgGxt HvAh1pTS16Sy7HSJxG0YuZGsjY2b99J+E55xPDLu4CGrIIqyBV2hW4FN7xsk6iO9SrtG EIUWn/MIRuACeoMJOjTZPGei+busDbtkCp7oTTVH605qZjP2WeFpg6JeXfY0daQcj3Dr pWLqqFyn7y/kZbJmLXqsSOQqRj/iZHCS+XgOu9AFEuWmN5FXWeKlie4Z8gyGW+Mkod8N B3Lw== 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=FtwqEhPzT3nHMQBDGkRoV01F2A3n7O/yvr9Y5995Vdg=; b=468uTKV7l6hunqx0dkyDapC+vYp/imrvcnN4VE49S+W1kQCbZLyR3Y387/r7tsKsJf kZLD8xK/z9S+5MqCpSHKuzU4k185NS+eM+wJthBG3i1apdVsw6nHntQfOfyQ4L3uzOkg iD1WsipvfFUsfW3dsu5zqnypelue1rBgFX3jyhfl+CxcOAvw70GzfYm/sTrrC3cNVenP kcZ0TYqV11nraKlpCg8cpoZ4UeAYtNUhneh8lsqH5piiPO9ABuzVY49yXmLSqqZ1dBKd n8hGuQQCu7noR0wthf9/W3ZgsE4iwvvqRWp/xAKqkUz8SSrRqaIh/12Q+NinqNL0Ktyl Q5/w== X-Gm-Message-State: AJIora9Js5PVFbdZfMzvfEsxIdH0izuZwu9XIGeNQNWQDyM8s8A3VCwu HOPuC2CO0NcdBZ4VPBPVPKbomvAF13AGkQ== X-Google-Smtp-Source: AGRyM1sTzDvV69HNnS87EyeucAc6VdBuzTZjGVqHpYV0MdBARPkmva8IKLHMFK9xklBjA917a0ci7A== X-Received: by 2002:a5d:6c62:0:b0:218:3e13:4b17 with SMTP id r2-20020a5d6c62000000b002183e134b17mr5129120wrz.673.1655217436120; Tue, 14 Jun 2022 07:37:16 -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 f14-20020a5d58ee000000b0020fc6590a12sm12169254wrd.41.2022.06.14.07.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 07:37:15 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 1/3] io_uring: update headers with IORING_SETUP_SINGLE_ISSUER Date: Tue, 14 Jun 2022 15:36:31 +0100 Message-Id: X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Signed-off-by: Pavel Begunkov --- src/include/liburing/io_uring.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h index 15d9fbd..ee6ccc9 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h @@ -137,9 +137,12 @@ enum { * IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN. */ #define IORING_SETUP_TASKRUN_FLAG (1U << 9) - #define IORING_SETUP_SQE128 (1U << 10) /* SQEs are 128 byte */ #define IORING_SETUP_CQE32 (1U << 11) /* CQEs are 32 byte */ +/* + * Only one task is allowed to submit requests + */ +#define IORING_SETUP_SINGLE_ISSUER (1U << 12) enum io_uring_op { IORING_OP_NOP, From patchwork Tue Jun 14 14:36:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12881196 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 21C3AC433EF for ; Tue, 14 Jun 2022 14:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236030AbiFNOhV (ORCPT ); Tue, 14 Jun 2022 10:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238290AbiFNOhU (ORCPT ); Tue, 14 Jun 2022 10:37:20 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08CF63BFA3 for ; Tue, 14 Jun 2022 07:37:19 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id a15so11585838wrh.2 for ; Tue, 14 Jun 2022 07:37:18 -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=Ku1tarHdwofw/iVUd3UyBPtuw43QQo8nV6tDR7LPbyE=; b=QKBPRWiwD/39llEnZbjzpe1D7TR3Ok14xD71H39dP26OqyeDNouAcoBpT3zcRPlX8k j2Bel7m138sL9fjNXIydnucNF4q7V9Of9lSPXk21CeOU1isHYgoZqJ9bSpuDx5AgGftD PgmAbf69d4AIiXGBybirYbHESU3c0C+YVStTsnyC0PoMZ69UtVKvB+l2U3AWqnEIl/0J JuowXcR9xebCxcelApberSHwEi3ZSVY3keE2qadXn+sEa/WLOYvbkbFut9z/6SmtVJ6d NsxXvRx4OanBUuHCYy99cLa5va7kiwrHD037EgDEkFvAIqiQHW2eofFCTz3nRkSwg0jl CTvA== 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=Ku1tarHdwofw/iVUd3UyBPtuw43QQo8nV6tDR7LPbyE=; b=QhoHXUm8Yjyvda+T0z8vzwTPjRdRsomhzEmEct+lbbnpLUrFBr3eUTima2AtBLdKtF YvZBY2oWodh7m3cIv2ogAd29qSct1AcyL+YjMqW2I6BbaAJbV1kqJHfhdv0pdJ8QknL3 cQKdJ21U7EJvmKzHeMB5evsecDpItbCAB13UkxD5C2uQafnr78mwZtTAqz/rjkHiLp+q 8V8AcWOAL38Py6SZWv6WI4jOV+dm4lbPbN3lTad1qVFSJRUxEYnrGLSCtd2o73TfUYpQ bWyXCn2nIH5lWHHJjtk1FfL+YzGeE6qYh3gq6HqEbm0p+4sKXmefvdXz4emLdj7tsgkt GZcA== X-Gm-Message-State: AJIora9bIqbyWVVfFBrFH8T8sNjxu0y1jlNrYwcGhrQrYepnzUIgG94z XUonKqDZNWK1eWvPgcGKwHPaVzweRjxf9w== X-Google-Smtp-Source: AGRyM1uykGDpEKU93TEnbm616luX4IgJZfAv58OQ7QWsf2OtJF0UQfihswMOV5GKOhRRnPknqNTWVg== X-Received: by 2002:a5d:4389:0:b0:213:1d58:1666 with SMTP id i9-20020a5d4389000000b002131d581666mr5152293wrq.294.1655217437249; Tue, 14 Jun 2022 07:37:17 -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 f14-20020a5d58ee000000b0020fc6590a12sm12169254wrd.41.2022.06.14.07.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 07:37:16 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 2/3] examples: add a simple single-shot poll benchmark Date: Tue, 14 Jun 2022 15:36:32 +0100 Message-Id: X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Signed-off-by: Pavel Begunkov --- examples/Makefile | 3 +- examples/poll-bench.c | 108 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 examples/poll-bench.c diff --git a/examples/Makefile b/examples/Makefile index 95a45f9..8e7067f 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -13,7 +13,8 @@ endif example_srcs := \ io_uring-cp.c \ io_uring-test.c \ - link-cp.c + link-cp.c \ + poll-bench.c all_targets := diff --git a/examples/poll-bench.c b/examples/poll-bench.c new file mode 100644 index 0000000..72ba8ef --- /dev/null +++ b/examples/poll-bench.c @@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Description: test io_uring poll handling + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "liburing.h" + +static char buf[4096]; +static unsigned long runtime_ms = 30000; + +static unsigned long gettimeofday_ms(void) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); +} + +int main(void) +{ + unsigned long tstop; + unsigned long nr_reqs = 0; + struct io_uring_cqe *cqe; + struct io_uring_sqe *sqe; + struct io_uring ring; + int pipe1[2]; + int ret, i, qd = 128; + + if (argc > 1) + return 0; + + if (pipe(pipe1) != 0) { + perror("pipe"); + return 1; + } + + ret = io_uring_queue_init(1024, &ring, IORING_SETUP_SINGLE_ISSUER); + if (ret == -EINVAL) { + fprintf(stderr, "can't single\n"); + ret = io_uring_queue_init(1024, &ring, 0); + } + if (ret) { + fprintf(stderr, "child: ring setup failed: %d\n", ret); + return 1; + } + + ret = io_uring_register_files(&ring, pipe1, 2); + if (ret < 0) { + fprintf(stderr, "io_uring_register_files failed\n"); + return 1; + } + + ret = io_uring_register_ring_fd(&ring); + if (ret < 0) { + fprintf(stderr, "io_uring_register_ring_fd failed\n"); + return 1; + } + + tstop = gettimeofday_ms() + runtime_ms; + do { + for (i = 0; i < qd; i++) { + sqe = io_uring_get_sqe(&ring); + io_uring_prep_poll_add(sqe, 0, POLLIN); + sqe->flags |= IOSQE_FIXED_FILE; + sqe->user_data = 1; + } + + ret = io_uring_submit(&ring); + if (ret != qd) { + fprintf(stderr, "child: sqe submit failed: %d\n", ret); + return 1; + } + + ret = write(pipe1[1], buf, 1); + if (ret != 1) { + fprintf(stderr, "write failed %i\n", errno); + return 1; + } + ret = read(pipe1[0], buf, 1); + if (ret != 1) { + fprintf(stderr, "read failed %i\n", errno); + return 1; + } + + for (i = 0; i < qd; i++) { + ret = io_uring_wait_cqe(&ring, &cqe); + if (ret < 0) { + fprintf(stderr, "child: wait completion %d\n", ret); + break; + } + io_uring_cqe_seen(&ring, cqe); + nr_reqs++; + } + } while (gettimeofday_ms() < tstop); + + fprintf(stderr, "requests/s: %lu\n", nr_reqs * 1000UL / runtime_ms); + return 0; +} From patchwork Tue Jun 14 14:36:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12881197 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 B74D1C43334 for ; Tue, 14 Jun 2022 14:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236679AbiFNOhW (ORCPT ); Tue, 14 Jun 2022 10:37:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbiFNOhV (ORCPT ); Tue, 14 Jun 2022 10:37:21 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AE5712625 for ; Tue, 14 Jun 2022 07:37:20 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id q15so11535329wrc.11 for ; Tue, 14 Jun 2022 07:37:20 -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=I/HN4gqc3ne5Wg/kirsMDgkzgQkt6tlEcJa4WcN66TU=; b=YDpvKfzk3DjJgnzscN6UpNvzkLSZRstZ9+qvgXxjb5W0+zcdYbb3axZUTngi6JKL0U L9nuD0mZqWwf6hFUyely+WT6dM/bi23Cn3Wcp/pl+tmPbH3s4tngxJuibmSi6NwGz2D9 qSDc1l3c3aTa09EuP515DF5UiUgTAHDk/3ylFQiZQN+6VbcxkUwlBIyhOlKn+cMIIVvC Liw03ia6Sj71xjgu9562/XGyaCZ2KjU9LbGV3JfHofys7DRJ6vSJIIOMcHp/3kretgWp 0dzNj9MAkPbuY+o/4/D6NDCoYMPzjLnm/kVvY5F32DxDOl2++ts5gg35wNIGKy5/Au09 zlFA== 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=I/HN4gqc3ne5Wg/kirsMDgkzgQkt6tlEcJa4WcN66TU=; b=zYCbRFfQzkSKtBEsM9xNe5sTH02AskNbpare5yHcALAmGkfhunwMS30Wb+DjRaAtYk fTCPthOy7+xstC/bJZZZfX31qXT+XeJpHhRlVisxRoHvgJzAHEzBZDBEHT/WY6ljLk/t qwYHu9A1NKYUK0F3QjxuKF3v7C4Y9akNIRLa2qRP5Jh/fY5HIB9FYxFSqaKPUpnrWFjf FllR2WU0yNEQNHYXyN42JQN+MfUxE/JsKSMHeJDbTWSiGadFDGmNlTTmIaZU8Y06XNyf efnhoZFo4/To5o1TTFfNqtbylWX/M6rWth4grOyWTjEij5oLSEKYcXjSmqTLUB26O8kT fpjA== X-Gm-Message-State: AJIora99G9TmgCF4FEteTo9BUXWRdi6sgA8DVBoy18sOGCJ/KoHAgQQD qo9fAZDsybZCwWASq3TzwpVK5XAkbhcfmA== X-Google-Smtp-Source: AGRyM1uobIULCYvD8qZ4jXGwTV7JxAsI3m5WVWKIgmOJ8QVXdHVxmIC0s4S/nXzIrlfzZOPTFOZOGA== X-Received: by 2002:a05:6000:1acf:b0:218:5a30:9067 with SMTP id i15-20020a0560001acf00b002185a309067mr5372967wry.48.1655217438527; Tue, 14 Jun 2022 07:37:18 -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 f14-20020a5d58ee000000b0020fc6590a12sm12169254wrd.41.2022.06.14.07.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 07:37:18 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 3/3] tests: test IORING_SETUP_SINGLE_ISSUER Date: Tue, 14 Jun 2022 15:36:33 +0100 Message-Id: <8d101e418097548d0d04de75c68996dfb6dabaa0.1655213733.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Signed-off-by: Pavel Begunkov --- test/Makefile | 1 + test/single-issuer.c | 173 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 test/single-issuer.c diff --git a/test/Makefile b/test/Makefile index ab031e0..0750996 100644 --- a/test/Makefile +++ b/test/Makefile @@ -169,6 +169,7 @@ test_srcs := \ wakeup-hang.c \ xattr.c \ skip-cqe.c \ + single-issuer.c \ # EOL diff --git a/test/single-issuer.c b/test/single-issuer.c new file mode 100644 index 0000000..6d1b917 --- /dev/null +++ b/test/single-issuer.c @@ -0,0 +1,173 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Description: run various nop tests + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "liburing.h" +#include "test.h" + +static pid_t pid; + +static pid_t fork_t(void) +{ + pid = fork(); + if (pid == -1) { + fprintf(stderr, "fork failed\n"); + exit(1); + } + return pid; +} + +static int wait_child_t(void) +{ + int wstatus; + + if (waitpid(pid, &wstatus, 0) == (pid_t)-1) { + perror("waitpid()"); + exit(1); + } + if (!WIFEXITED(wstatus)) { + fprintf(stderr, "child failed %i\n", WEXITSTATUS(wstatus)); + exit(1); + } + + return WEXITSTATUS(wstatus); +} + +static int try_submit(struct io_uring *ring) +{ + struct io_uring_cqe *cqe; + struct io_uring_sqe *sqe; + int ret; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_nop(sqe); + sqe->user_data = 42; + + ret = io_uring_submit(ring); + if (ret < 0) + return ret; + + if (ret != 1) + error(1, ret, "submit %i", ret); + ret = io_uring_wait_cqe(ring, &cqe); + if (ret) + error(1, ret, "wait fail %i", ret); + + if (cqe->res || cqe->user_data != 42) + error(1, ret, "invalid cqe"); + + io_uring_cqe_seen(ring, cqe); + return 0; +} + +int main(int argc, char *argv[]) +{ + struct io_uring ring; + int ret; + + if (argc > 1) + return 0; + + ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER); + if (ret == -EINVAL) { + fprintf(stderr, "SETUP_SINGLE_ISSUER is not supported, skip\n"); + return 0; + } else if (ret) { + error(1, ret, "ring init (1) %i", ret); + } + + /* test that the creator iw allowed to submit */ + ret = try_submit(&ring); + if (ret) { + fprintf(stderr, "the creater can't submit %i\n", ret); + return 1; + } + + /* test that a second submitter doesn't succeed */ + if (!fork_t()) { + ret = try_submit(&ring); + if (ret != -EEXIST) { + fprintf(stderr, "not owner child could submit %i\n", ret); + exit(1); + } + exit(0); + } else { + if (wait_child_t()) + return 1; + } + io_uring_queue_exit(&ring); + + + /* test that the first submitter but not creator can submit */ + ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER); + if (ret) + error(1, ret, "ring init (2) %i", ret); + + if (!fork_t()) { + ret = try_submit(&ring); + if (ret) { + fprintf(stderr, "not owner child could submit %i\n", ret); + exit(1); + } + exit(0); + } else { + if (wait_child_t()) + return 1; + } + io_uring_queue_exit(&ring); + + /* test that anyone can submit to a SQPOLL|SINGLE_ISSUER ring */ + ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_SQPOLL); + if (ret) + error(1, ret, "ring init (3) %i", ret); + + ret = try_submit(&ring); + if (ret) { + fprintf(stderr, "SQPOLL submit failed (creator) %i\n", ret); + exit(1); + } + + if (!fork_t()) { + ret = try_submit(&ring); + if (ret) { + fprintf(stderr, "SQPOLL submit failed (child) %i\n", ret); + exit(1); + } + exit(0); + } else { + if (wait_child_t()) + return 1; + } + io_uring_queue_exit(&ring); + + /* test that IORING_ENTER_REGISTERED_RING doesn't break anything */ + ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER); + if (ret) + error(1, ret, "ring init (4) %i", ret); + + if (!fork_t()) { + ret = try_submit(&ring); + if (ret) { + fprintf(stderr, "not owner child could submit %i\n", ret); + exit(1); + } + exit(0); + } else { + if (wait_child_t()) + return 1; + } + io_uring_queue_exit(&ring); + + return 0; +}