From patchwork Tue Jan 24 01:21:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13113251 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 0EE36C25B50 for ; Tue, 24 Jan 2023 01:24:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232357AbjAXBYV (ORCPT ); Mon, 23 Jan 2023 20:24:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232549AbjAXBYR (ORCPT ); Mon, 23 Jan 2023 20:24:17 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60AAEA5C1 for ; Mon, 23 Jan 2023 17:23:50 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id y1so7966440wru.2 for ; Mon, 23 Jan 2023 17:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KcbXSoJyVOwwyi4rwKO5FmJttg2V1r5VL9ydicqAb1k=; b=Xb5Mw4DU99AjpgZJgxkowaMadQ7seNzfeKu3WHPjYv/IaW0lgDpMMpkuEccgE5oKYj 7MZEDpygC0CQCeTJT652ukHZaP2dPepBz0RM2obvbJ/yYXuVHbiytciXdTV6ybmUuaJ/ 9WidVdIbm81pRZmV0M3thTUAdZ9VPnq3TRAAHWG65dTQHZWtONN3zCBKYVhTm1uy1jpI 1CmUfz3Afhw+T6cj9Ez3FTfjiAaxGN6eRweWBliOkx+xY1/adern4EpIVKBFVhYnuCX+ u7Wf6QIDv0x8zfMyx110k9Q5k/HvBAqHn4PPrGpJx4ugLOVcUcUZbh5PDtVtA4KC0/G3 SnpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KcbXSoJyVOwwyi4rwKO5FmJttg2V1r5VL9ydicqAb1k=; b=okdGP17082S9Jq5aaIfxLz6RKxmpEgEjvtaz/HfCJAgWpVTN5qbPiIjJ2B0U62sAgA ltJBgJ7jJXUBFnZx3++/7UIolCFS7MlXEzWdeMjvG7v/6LJOZcM0b04/XqX1Hm5U+7ty N6tXIaO7SML8pcXb1BJdcBN7AEQCQsS41zu2SPejjcm9k39JxHe8mzsfJsPotWiBIeAU KhvxXeZyrbqjqsQ3dnM9c7TBnBcdzrT89L3sinV63eKL5zg84y3YiZTcHztMVMfudMTE IhybAN7UEVmimeh0GdZXXdDYYofdtaril+9t+axs2XMF2MIUvOZHTPIQBmd7ot1J5//t fH1Q== X-Gm-Message-State: AFqh2kqI6zbX4GNJ0mUhh6LcgfVOctmYWn1rJLRJtsHbeAwel/RScrqR 4gYP9hJCz/84VQG9OkzO8CuMv9bA5mQ= X-Google-Smtp-Source: AMrXdXvJYcAaeUKWHkGpvtzDWHnWqkBhFhW8WQUMXOqEUfszAdv4CmjFANXaP5O3g45eqKm2onnfwQ== X-Received: by 2002:a5d:5a8f:0:b0:2be:53cc:ca5c with SMTP id bp15-20020a5d5a8f000000b002be53ccca5cmr14467149wrb.15.1674523425702; Mon, 23 Jan 2023 17:23:45 -0800 (PST) Received: from 127.0.0.1localhost (92.41.37.76.threembb.co.uk. [92.41.37.76]) by smtp.gmail.com with ESMTPSA id t20-20020adfa2d4000000b002bdcce37d31sm712912wra.99.2023.01.23.17.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:23:45 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 1/5] tests/msg_ring: use correct exit codes Date: Tue, 24 Jan 2023 01:21:45 +0000 Message-Id: <8e94289f8cff49740b5adaeb981fe58551d4f490.1674523156.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.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/msg-ring.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/msg-ring.c b/test/msg-ring.c index a825bf9..afe3192 100644 --- a/test/msg-ring.c +++ b/test/msg-ring.c @@ -220,27 +220,27 @@ int main(int argc, char *argv[]) ret = test_own(&ring); if (ret) { fprintf(stderr, "test_own failed\n"); - return ret; + return T_EXIT_FAIL; } if (no_msg) return T_EXIT_SKIP; ret = test_own(&pring); if (ret) { fprintf(stderr, "test_own iopoll failed\n"); - return ret; + return T_EXIT_FAIL; } ret = test_invalid(&ring, 0); if (ret) { fprintf(stderr, "test_invalid failed\n"); - return ret; + return T_EXIT_FAIL; } for (i = 0; i < 2; i++) { ret = test_invalid(&ring, 1); if (ret) { fprintf(stderr, "test_invalid fixed failed\n"); - return ret; + return T_EXIT_FAIL; } } @@ -249,7 +249,7 @@ int main(int argc, char *argv[]) ret = test_remote(&ring, &ring2); if (ret) { fprintf(stderr, "test_remote failed\n"); - return ret; + return T_EXIT_FAIL; } pthread_join(thread, &tret); From patchwork Tue Jan 24 01:21:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13113249 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 89152C54EB4 for ; Tue, 24 Jan 2023 01:24:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232549AbjAXBYV (ORCPT ); Mon, 23 Jan 2023 20:24:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232592AbjAXBYS (ORCPT ); Mon, 23 Jan 2023 20:24:18 -0500 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 85BE412F26 for ; Mon, 23 Jan 2023 17:23:50 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso9849645wmq.5 for ; Mon, 23 Jan 2023 17:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mOPjpicl2vBI6DRcLC573pKl2JN9yi/WB4p89oS7TOo=; b=m5n5fHStvP/ActV2KaB9srZOXrgMwkQeOp52wlWW5xtsJ0tXztmsm5sxhcT8aA4GG9 /SWw3Ck2Vp5upqbFJKTDH7dVQXo/Eh9BSElHC5uhMTC54ySWVKI1xx0CQfiwjldnI1GZ NT5ap2H0RE2zk8/pS0rhysqOrTrfVEm/Cfpqzuc2kBHlI50t1IDsSEUMlvJJRGtSCRkG 2XtnCQKdULmg0B1iQYa6sLzKfRbxkLc2Bs0GNwgLVSbt0vKrhlb940jlHUFYWkLwM3IX xLeti6OE207INXZ0z2IyX1HeKy7ZNKkzvKB3s9dck8kSQlwbGXHoPOw+0PVUSd19uWZd m3FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mOPjpicl2vBI6DRcLC573pKl2JN9yi/WB4p89oS7TOo=; b=XpG8ga+tr6ncvmawP6QMnI4tOZNRzs3gnk4ROd5WY/Q0ePfVps+Nys/aHCEu/C1mDc OwaoLjgwL5FTvnsHwDgzhWoSCDe28J4wzVCTXCa4keZdrQnmZ2OG33Paz4uPRhaHdlmT qgLvEVdJrBSoZIjHJlaGZHdwHYjyFoStO3tBATXlICu9cEHqIP04hXlcTxhfvxvtJg0Q XEp0uJ/ePVZW/xoRghtf519A+FWklnM+tZxHyhAeRAy+C61eOHWb4d3F6qDsLuBPev+7 sf98ZL+njpLK4N9byLC+I1M3SBQ50CtiIoXqArp1v2js5cHhIGKs5vnYPhjjoK5oK7qp tU/g== X-Gm-Message-State: AFqh2kpRbxg9UUWVGBZWuOKSvEJlLOSI4PG46b3xKRlJQ0Me6Ubi6QxG uvSMgfsp/3U25RlYGEID/feyfiRxLfc= X-Google-Smtp-Source: AMrXdXuCRDdFC6vH2+okfZxok6bTAX0uGIf+JWTUT2fZlYKFzZEKHVH50DuhyQBgMGOhQdfK3ng6yw== X-Received: by 2002:a05:600c:684:b0:3cf:5d41:b748 with SMTP id a4-20020a05600c068400b003cf5d41b748mr33860945wmn.36.1674523426677; Mon, 23 Jan 2023 17:23:46 -0800 (PST) Received: from 127.0.0.1localhost (92.41.37.76.threembb.co.uk. [92.41.37.76]) by smtp.gmail.com with ESMTPSA id t20-20020adfa2d4000000b002bdcce37d31sm712912wra.99.2023.01.23.17.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:23:46 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 2/5] tests/msg_ring: test msg_ring with deferred tw Date: Tue, 24 Jan 2023 01:21:46 +0000 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Extend msg_ring.c to test IORING_SETUP_DEFER_TASKRUN rings Signed-off-by: Pavel Begunkov --- test/msg-ring.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/msg-ring.c b/test/msg-ring.c index afe3192..6db7680 100644 --- a/test/msg-ring.c +++ b/test/msg-ring.c @@ -254,5 +254,33 @@ int main(int argc, char *argv[]) pthread_join(thread, &tret); + io_uring_queue_exit(&ring); + io_uring_queue_exit(&ring2); + io_uring_queue_exit(&pring); + + if (t_probe_defer_taskrun()) { + ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER | + IORING_SETUP_DEFER_TASKRUN); + if (ret) { + fprintf(stderr, "deferred ring setup failed: %d\n", ret); + return T_EXIT_FAIL; + } + + ret = test_own(&ring); + if (ret) { + fprintf(stderr, "test_own deferred failed\n"); + return T_EXIT_FAIL; + } + + for (i = 0; i < 2; i++) { + ret = test_invalid(&ring, i); + if (ret) { + fprintf(stderr, "test_invalid(0) deferred failed\n"); + return T_EXIT_FAIL; + } + } + io_uring_queue_exit(&ring); + } + return T_EXIT_PASS; } From patchwork Tue Jan 24 01:21:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13113250 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 62FD4C61D97 for ; Tue, 24 Jan 2023 01:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbjAXBYW (ORCPT ); Mon, 23 Jan 2023 20:24:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbjAXBYS (ORCPT ); Mon, 23 Jan 2023 20:24:18 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E51298C1 for ; Mon, 23 Jan 2023 17:23:51 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id e3so12435869wru.13 for ; Mon, 23 Jan 2023 17:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jVF3aoUddvtQic7EorccPZRhLLN8BUyKR0CFCSNtguY=; b=eb4LYoxo2fOZICyV8pqZbKqIiu8/LM4isRvczc/B1/qFsbGbzEsdde+DSONuv1l/ja D36T7Sl/F5XW+bxDtCsBN0TZdCL3xFG6sgsM2YlMz1g4pEZp4wP6XIfSjTGdlw6nwZDS BUFz/It+j5DQ3i14eKqSrsQjBEVx7P4g7/0vwwwIQ7xlA7TuYRKeSGPNuCPrmoiitdy3 qgI2VlzV+g0P3PflEuWMIJPMaAc9sxwM5vJH2cNHuMauH/oZcDC1qPL6aYa55EUsLk/1 IF4Fm9gc3BleqbRruu555F5hqnNR1OsMjXQGfHTjuotjdKmrq1LrKBh/o2Sw9KO5HJ3e v9UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jVF3aoUddvtQic7EorccPZRhLLN8BUyKR0CFCSNtguY=; b=ajX70J+t/1kH5CKqw/0lQ+1ag4tc8qwNpwe8+yotL3W0k9HVDUJTU9Kp93AESzBNrs 4vIceHGL/51K6LGDxMYbD4NjpIfOYpSqyO7DRXr8e6W6yF0K/Em1S0pID3RX646zCxqX 638tJSJHpakpsFABQwrBs1WNCR2HPV7rzr3bQtBsvdsvUgS4ThrsIoId+5WW8Nz9J+qV ari6MnDoITDvSwFHAkSmN17uzZ2075RtC5XE4me5l/KVXheG016u7nII9obb/Mh+S7j0 /6XpAYY59DRsX/AQc75VJKhaRc6SfTRJvThRMxSPenulFvW6L3+qXw7eMAvEtXTpkAYI 31Lw== X-Gm-Message-State: AFqh2krj88WFJ0MWGMloCZJof9yX0TDWR2Dispcq9kj2/M+qRo3BJSMH nzcPDLpdeR42xpCSW6WFO5jaNFlXQ1M= X-Google-Smtp-Source: AMrXdXuKGNq7VjoQFO9KxXG/SBSP/Cf1yqPdKYEjA8+v9nQmthkfoq2KleAj/QEzOjEuFjEZg4u3Zg== X-Received: by 2002:a05:6000:1f81:b0:2b5:dc24:e08e with SMTP id bw1-20020a0560001f8100b002b5dc24e08emr22028229wrb.69.1674523427786; Mon, 23 Jan 2023 17:23:47 -0800 (PST) Received: from 127.0.0.1localhost (92.41.37.76.threembb.co.uk. [92.41.37.76]) by smtp.gmail.com with ESMTPSA id t20-20020adfa2d4000000b002bdcce37d31sm712912wra.99.2023.01.23.17.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:23:47 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 3/5] test/msg_ring: test msg_ring to a disabled ring Date: Tue, 24 Jan 2023 01:21:47 +0000 Message-Id: <30b4fae32616f4241f209fd35e397d4990d9df76.1674523156.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org A regression test trying to message IORING_SETUP_R_DISABLED rings. Signed-off-by: Pavel Begunkov --- test/msg-ring.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/msg-ring.c b/test/msg-ring.c index 6db7680..66c60b3 100644 --- a/test/msg-ring.c +++ b/test/msg-ring.c @@ -191,6 +191,49 @@ err: return 1; } +static int test_disabled_ring(struct io_uring *ring, int flags) +{ + struct io_uring_cqe *cqe; + struct io_uring_sqe *sqe; + struct io_uring disabled_ring; + int ret; + + flags |= IORING_SETUP_R_DISABLED; + ret = io_uring_queue_init(8, &disabled_ring, flags); + if (ret) { + fprintf(stderr, "ring setup failed: %d\n", ret); + return 1; + } + + sqe = io_uring_get_sqe(ring); + io_uring_prep_msg_ring(sqe, disabled_ring.ring_fd, 0x10, 0x1234, 0); + sqe->user_data = 1; + + ret = io_uring_submit(ring); + if (ret != 1) { + fprintf(stderr, "sqe submit failed: %d\n", ret); + return 1; + } + + ret = io_uring_wait_cqe(ring, &cqe); + if (ret < 0) { + fprintf(stderr, "wait completion %d\n", ret); + return 1; + } + if (cqe->res != 0 && cqe->res != -EBADFD) { + fprintf(stderr, "cqe res %d\n", cqe->res); + return 1; + } + if (cqe->user_data != 1) { + fprintf(stderr, "user_data %llx\n", (long long) cqe->user_data); + return 1; + } + + io_uring_cqe_seen(ring, cqe); + io_uring_queue_exit(&disabled_ring); + return 0; +} + int main(int argc, char *argv[]) { struct io_uring ring, ring2, pring; @@ -280,6 +323,18 @@ int main(int argc, char *argv[]) } } io_uring_queue_exit(&ring); + + if (test_disabled_ring(&ring2, 0)) { + fprintf(stderr, "test_disabled_ring failed\n"); + return T_EXIT_FAIL; + } + + if (test_disabled_ring(&ring2, IORING_SETUP_SINGLE_ISSUER | + IORING_SETUP_DEFER_TASKRUN)) { + fprintf(stderr, "test_disabled_ring defer failed\n"); + return T_EXIT_FAIL; + } + } return T_EXIT_PASS; From patchwork Tue Jan 24 01:21:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13113252 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 05D0DC54E94 for ; Tue, 24 Jan 2023 01:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232592AbjAXBYW (ORCPT ); Mon, 23 Jan 2023 20:24:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232600AbjAXBYS (ORCPT ); Mon, 23 Jan 2023 20:24:18 -0500 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 09A98303C9 for ; Mon, 23 Jan 2023 17:23:51 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id r9so12459756wrw.4 for ; Mon, 23 Jan 2023 17:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0CyeNHO+wApPujQwvE0G8Yf0/otNiaiqcYQlH4gdJd8=; b=Mb0nryN79iteZrLNPnmJi5cbW21RoIg3tQNrRpR6O7MSQWtKJRQdYxDU0bQtEUfCv+ 0X2cmiDHUkmejngf2r2TQZT0IYBeYD6LpyPB5BdrC/CpVF/9YxK5NUMiUFjeziExo/kp Q1iJJeBsl8jJBS/oPSCsVKXtTjqi+3NrKlATy56JD3BnJxjl3sVY/A4In40JvGkbxWYM hx7G8ocscu/6TPtozBYAnbKehyWb7rPyK9eOc9ZXs54v77kIZsP4toT0CpWOSwp+kTD8 wuIcB2r8sY8TRwelKJYZraXOzHMzxCUw3UddjXG6Rr+0GVIJUSezq3gM4wsfQBLes8rU 3jFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0CyeNHO+wApPujQwvE0G8Yf0/otNiaiqcYQlH4gdJd8=; b=Qqp/s5DL4Anqahq+HMgiGaN/FDhDnOsor+LXPZollL56qDWshCngKAEKc9ez6LYVZm iQUKG0jmOmeh3rrEeq/vaS/DMcdEcBhlO4o1pSkWwc8JTk3QvnP6OWxuhpwd0ZVF0m4v BlHr/+IDFlcxr+MR2TtoSoZlKmoVBL/zavvqd7p9mrP2Pna9uP/F89L+rsXxgovrk+w0 6gEgXHVESN9xJ7MBnfznOspRb455IIFn49UlL2Bj8XmTWByYtzF6VfFGjRdGsWQd7b30 3WPVFHBrrJmfXkuegqHm0jSUSmilBGRlBAF+5Og27SRYembHP9pDteBb7kSD3zoQdSdR P/bw== X-Gm-Message-State: AFqh2kr3jsn6htMruLpFLiNB4m88FOQfVbj0tXUkzIT1HvultYEIzp8a yJ7GYpc9n98XHXbrywadwbJHFW3296A= X-Google-Smtp-Source: AMrXdXtb4XTi0LHBJDZx8HNDC/uH48kAQDnPa3Y+GMOTADVZeQUbPutrCO0FyUG6oUvFJCBkZqs5pw== X-Received: by 2002:adf:cd8f:0:b0:2bd:d4bd:5829 with SMTP id q15-20020adfcd8f000000b002bdd4bd5829mr24533890wrj.19.1674523428619; Mon, 23 Jan 2023 17:23:48 -0800 (PST) Received: from 127.0.0.1localhost (92.41.37.76.threembb.co.uk. [92.41.37.76]) by smtp.gmail.com with ESMTPSA id t20-20020adfa2d4000000b002bdcce37d31sm712912wra.99.2023.01.23.17.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:23:48 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 4/5] tests/msg_ring: refactor test_remote Date: Tue, 24 Jan 2023 01:21:48 +0000 Message-Id: <1c0e97492c0010a65c5c5f42450350b37c1a3809.1674523156.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Refactor test_remote() by folding all pthread accounting inside of it Signed-off-by: Pavel Begunkov --- test/msg-ring.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/msg-ring.c b/test/msg-ring.c index 66c60b3..495c127 100644 --- a/test/msg-ring.c +++ b/test/msg-ring.c @@ -93,17 +93,23 @@ static void *wait_cqe_fn(void *data) goto err; } + io_uring_cqe_seen(ring, cqe); return NULL; err: + io_uring_cqe_seen(ring, cqe); return (void *) (unsigned long) 1; } static int test_remote(struct io_uring *ring, struct io_uring *target) { + pthread_t thread; + void *tret; struct io_uring_cqe *cqe; struct io_uring_sqe *sqe; int ret; + pthread_create(&thread, NULL, wait_cqe_fn, target); + sqe = io_uring_get_sqe(ring); if (!sqe) { fprintf(stderr, "get sqe failed\n"); @@ -134,6 +140,7 @@ static int test_remote(struct io_uring *ring, struct io_uring *target) } io_uring_cqe_seen(ring, cqe); + pthread_join(thread, &tret); return 0; err: return 1; @@ -237,8 +244,6 @@ static int test_disabled_ring(struct io_uring *ring, int flags) int main(int argc, char *argv[]) { struct io_uring ring, ring2, pring; - pthread_t thread; - void *tret; int ret, i; if (argc > 1) @@ -287,18 +292,13 @@ int main(int argc, char *argv[]) } } - pthread_create(&thread, NULL, wait_cqe_fn, &ring2); - ret = test_remote(&ring, &ring2); if (ret) { fprintf(stderr, "test_remote failed\n"); return T_EXIT_FAIL; } - pthread_join(thread, &tret); - io_uring_queue_exit(&ring); - io_uring_queue_exit(&ring2); io_uring_queue_exit(&pring); if (t_probe_defer_taskrun()) { @@ -337,5 +337,6 @@ int main(int argc, char *argv[]) } + io_uring_queue_exit(&ring2); return T_EXIT_PASS; } From patchwork Tue Jan 24 01:21:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13113253 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 60AFCC05027 for ; Tue, 24 Jan 2023 01:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbjAXBYX (ORCPT ); Mon, 23 Jan 2023 20:24:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232771AbjAXBYS (ORCPT ); Mon, 23 Jan 2023 20:24:18 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F398303EC for ; Mon, 23 Jan 2023 17:23:51 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id f19-20020a1c6a13000000b003db0ef4dedcso11796955wmc.4 for ; Mon, 23 Jan 2023 17:23:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nxb+pwONt2jMb670XY68A29QyjdzIGjK2DG7ZXaNHME=; b=Mp9YptAM6Cwnaug2lNqRwx1eMzrBM+LQ947lLo3MIRkjDsBHLeuPYk3xiv6acHFj1c s5tSVbSALRtZJ7D7PvV/dv4+TQ9FOtrYyyVU/owIu+GoWxYgSOlycRlXInOifp3AOGH7 CS8LjcdprZITcdAxC6rncM8gaoWpFlw2K8+EpQHM/7LNWpynEbRpJXIms/OkNVReQFtY 9lNfYblSPrYvV+aos0OvWjKl77/ktUt5mctSZZZ9Bt3hH3sTgm8rF2qN89fHJ4HpQ032 McwogEQVqf7wyJvCpFgCPWqD08tvp9csbiw8Wa2LMk6StBzlo+BGQtCdAX4O4U0DZFk9 bs8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nxb+pwONt2jMb670XY68A29QyjdzIGjK2DG7ZXaNHME=; b=jaOL9oC16eZbxa3eaa/+cDhzbKCmus5UW9kMNPI3xBvfERLT2sWc3pvT4eKaQnUnD7 dtJLbgbBbys4D6NjSYG5qK96/cpf+pYNwvQQMdBsxjWwPBPR6zUPPmv0r1ehZ0pl7gSI /AjsEzXXj4kJpT+P2m4H2Fds12jYb/32SHYpDcaF7N5ifuqNTLYrY4EUpMZVWRrGmH9s srXEyUToCSj3g9ffGL+ljK38aNP/TSS7NDWr7lVOPzymTtGVi10lnRghwtJOXMsV8ull k/uFoSoKZDr9uKo6rillvEep8a2CsZKeoyqRPAiF8b0GT0zTTq5fMEzrm5QPA7FwQ9B6 E4QA== X-Gm-Message-State: AFqh2kqiXHfZ+SoR/QODW0q9upaa1nbmy+bfPHAO/EZKA+95rLgHFmjF JIdJZqOUtOqcv3IsBdEJyPWt7+Mvjs8= X-Google-Smtp-Source: AMrXdXuA6d9rlpM5uMJLpxCIJ7fMGCCYG23yhbENE8IvK+g5j9w6ITOyF792FImbZhp3UTaWySRFmw== X-Received: by 2002:a05:600c:4928:b0:3d9:a5a2:65fa with SMTP id f40-20020a05600c492800b003d9a5a265famr25850099wmp.7.1674523429574; Mon, 23 Jan 2023 17:23:49 -0800 (PST) Received: from 127.0.0.1localhost (92.41.37.76.threembb.co.uk. [92.41.37.76]) by smtp.gmail.com with ESMTPSA id t20-20020adfa2d4000000b002bdcce37d31sm712912wra.99.2023.01.23.17.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 17:23:49 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 5/5] tests/msg_ring: remote submit to a deferred tw ring Date: Tue, 24 Jan 2023 01:21:49 +0000 Message-Id: <6aabba6058e0029104174379c4c3135d6af835f5.1674523156.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Test sending messages to a deferred ring from another task Signed-off-by: Pavel Begunkov --- test/msg-ring.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/test/msg-ring.c b/test/msg-ring.c index 495c127..cb6687f 100644 --- a/test/msg-ring.c +++ b/test/msg-ring.c @@ -146,6 +146,79 @@ err: return 1; } +static void *remote_submit_fn(void *data) +{ + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + struct io_uring *target = data; + struct io_uring ring; + int ret; + + ret = io_uring_queue_init(8, &ring, 0); + if (ret) { + fprintf(stderr, "thread ring setup failed: %d\n", ret); + goto err; + } + sqe = io_uring_get_sqe(&ring); + if (!sqe) { + fprintf(stderr, "get sqe failed\n"); + goto err; + } + + io_uring_prep_msg_ring(sqe, target->ring_fd, 0x20, 0x5aa5, 0); + sqe->user_data = 1; + + ret = io_uring_submit(&ring); + if (ret <= 0) { + fprintf(stderr, "sqe submit failed: %d\n", ret); + goto err; + } + + ret = io_uring_wait_cqe(&ring, &cqe); + if (ret < 0) { + fprintf(stderr, "wait completion %d\n", ret); + goto err; + } + if (cqe->res != 0 || cqe->user_data != 1) { + fprintf(stderr, "invalid cqe\n"); + goto err; + } + io_uring_cqe_seen(&ring, cqe); + io_uring_queue_exit(&ring); + return NULL; +err: + return (void *) (unsigned long) 1; +} + +static int test_remote_submit(struct io_uring *target) +{ + struct io_uring_cqe *cqe; + pthread_t thread; + void *tret; + int ret; + + pthread_create(&thread, NULL, remote_submit_fn, target); + + ret = io_uring_wait_cqe(target, &cqe); + if (ret < 0) { + fprintf(stderr, "wait completion %d\n", ret); + goto err; + } + if (cqe->res != 0x20) { + fprintf(stderr, "cqe res %d\n", cqe->res); + return -1; + } + if (cqe->user_data != 0x5aa5) { + fprintf(stderr, "user_data %llx\n", (long long) cqe->user_data); + return -1; + } + io_uring_cqe_seen(target, cqe); + pthread_join(thread, &tret); + return 0; +err: + return 1; +} + static int test_invalid(struct io_uring *ring, bool fixed) { struct io_uring_cqe *cqe; @@ -322,6 +395,12 @@ int main(int argc, char *argv[]) return T_EXIT_FAIL; } } + + ret = test_remote_submit(&ring); + if (ret) { + fprintf(stderr, "test_remote_submit failed\n"); + return T_EXIT_FAIL; + } io_uring_queue_exit(&ring); if (test_disabled_ring(&ring2, 0)) { @@ -334,7 +413,6 @@ int main(int argc, char *argv[]) fprintf(stderr, "test_disabled_ring defer failed\n"); return T_EXIT_FAIL; } - } io_uring_queue_exit(&ring2);