From patchwork Fri Jun 17 08:42:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12885336 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 36CEBCCA47C for ; Fri, 17 Jun 2022 08:45:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381358AbiFQIpz (ORCPT ); Fri, 17 Jun 2022 04:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381355AbiFQIpi (ORCPT ); Fri, 17 Jun 2022 04:45:38 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E47B6A043 for ; Fri, 17 Jun 2022 01:45:27 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id h23so7427002ejj.12 for ; Fri, 17 Jun 2022 01:45:27 -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=ZsHDX8iN8foHq5m87WYXjazf1UiVTKwybYm2YnxPwQY=; b=IjLRrokUYrQYnwO51g06YUbmjNe4gdHQE8wKWKTjlzD4JvsX/eU6o3JiTrcrXXs87H 02atB8s5ePIr9Xj27moDg48jjPha/ByDI4g09luGD2aZn6JmbCUd7/QFW0u1hbdC7fhp g505WlQWhxv8cqrQyO0OHn/GN0LqnkEYKSKoVtM7ET1impTKMXSNSqEonVieSGYdpZOR +T4u+Ig6bde3dq8GF0vGh5TQZ6FNs+2PTa27MMCJVOoztRTs3RjAOWURssFl3xwcyeFo QArbwJvaxH/YbLXm7Lc6FCRvJRDpbagBL5LDNoM7PSWxJYJHWSF1KteNXQadmjV16WiK 82/g== 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=ZsHDX8iN8foHq5m87WYXjazf1UiVTKwybYm2YnxPwQY=; b=vwuN4/um8KamfDJ7AhcNMOnrHZN6p+huTeCwRJs9H918OMAeZo+RPSOLHUR4avsi9J OVx4wNndpDaU5tCIuJ11VX28uDVBR/48D11OHqVdn5rZh7XnaRy/PgjcpYi5hjW2lEju QIJHJErS3WgnlzlUg9WAYCiW3NwaV3l3dAaPrCT5oVin3qyRKr+sfXJyZhpbvcL1aDX8 F+UqueZhNT/HiRnuXjQCq5V3mUTeRbKImIja5B7HW7Q6k+lM6B4eDGmzB36bkAW4a5FZ F+9rRq4H9DRHbiQ/d31eA5X+4P3HS//zzDljZcIUQvAeEEjHFFu5G7T3bsXDN92fnCij LwkA== X-Gm-Message-State: AJIora94nkOOc92ezNmtVReWaUjosQH0jm0YYIYEWzByHmWltBEsexdS jcJGaUOYgHa9AnNxsKLHtftAz763+bXF7w== X-Google-Smtp-Source: AGRyM1vs+IdiDjb5lE+gvFcnRC29OCeA1Hjpp7JHCcbIE1OBbJrTvXeUw5rsgvM37+HGc5WG4QCfUQ== X-Received: by 2002:a17:907:c06:b0:701:eb60:ded with SMTP id ga6-20020a1709070c0600b00701eb600dedmr7628015ejc.178.1655455525675; Fri, 17 Jun 2022 01:45:25 -0700 (PDT) Received: from 127.0.0.1localhost.com ([2620:10d:c092:600::2:b65a]) by smtp.gmail.com with ESMTPSA id ot21-20020a170906ccd500b006f3ef214e0esm1844106ejb.116.2022.06.17.01.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 01:45:25 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 1/2] Revert "test/nop: kill cqe32 test code" Date: Fri, 17 Jun 2022 09:42:41 +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 This reverts commit e5d017ab9cd9605248db68168ae5451f830e646c. Signed-off-by: Pavel Begunkov --- test/nop.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/nop.c b/test/nop.c index 01e41a6..ce223b3 100644 --- a/test/nop.c +++ b/test/nop.c @@ -20,6 +20,7 @@ static int test_single_nop(struct io_uring *ring) struct io_uring_cqe *cqe; struct io_uring_sqe *sqe; int ret; + bool cqe32 = (ring->flags & IORING_SETUP_CQE32); sqe = io_uring_get_sqe(ring); if (!sqe) { @@ -28,6 +29,10 @@ static int test_single_nop(struct io_uring *ring) } io_uring_prep_nop(sqe); + if (cqe32) { + sqe->addr = 1234; + sqe->addr2 = 5678; + } sqe->user_data = ++seq; ret = io_uring_submit(ring); @@ -45,6 +50,17 @@ static int test_single_nop(struct io_uring *ring) fprintf(stderr, "Unexpected 0 user_data\n"); goto err; } + if (cqe32) { + if (cqe->big_cqe[0] != 1234) { + fprintf(stderr, "Unexpected extra1\n"); + goto err; + + } + if (cqe->big_cqe[1] != 5678) { + fprintf(stderr, "Unexpected extra2\n"); + goto err; + } + } io_uring_cqe_seen(ring, cqe); return 0; err: @@ -56,6 +72,7 @@ static int test_barrier_nop(struct io_uring *ring) struct io_uring_cqe *cqe; struct io_uring_sqe *sqe; int ret, i; + bool cqe32 = (ring->flags & IORING_SETUP_CQE32); for (i = 0; i < 8; i++) { sqe = io_uring_get_sqe(ring); @@ -67,6 +84,10 @@ static int test_barrier_nop(struct io_uring *ring) io_uring_prep_nop(sqe); if (i == 4) sqe->flags = IOSQE_IO_DRAIN; + if (cqe32) { + sqe->addr = 1234; + sqe->addr2 = 5678; + } sqe->user_data = ++seq; } @@ -89,6 +110,16 @@ static int test_barrier_nop(struct io_uring *ring) fprintf(stderr, "Unexpected 0 user_data\n"); goto err; } + if (cqe32) { + if (cqe->big_cqe[0] != 1234) { + fprintf(stderr, "Unexpected extra1\n"); + goto err; + } + if (cqe->big_cqe[1] != 5678) { + fprintf(stderr, "Unexpected extra2\n"); + goto err; + } + } io_uring_cqe_seen(ring, cqe); } From patchwork Fri Jun 17 08:42:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12885337 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 E1395C43334 for ; Fri, 17 Jun 2022 08:45:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381355AbiFQIpz (ORCPT ); Fri, 17 Jun 2022 04:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381359AbiFQIpi (ORCPT ); Fri, 17 Jun 2022 04:45:38 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 595B06A048 for ; Fri, 17 Jun 2022 01:45:28 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id c13so799064eds.10 for ; Fri, 17 Jun 2022 01:45:28 -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=YOid4TZPDFSstLq1udFewCAf/k9umRs9BDiZHIXtkMU=; b=kLmSeuRWdlwURdPRisYlj3lkSd/1zcdFwML+hESEE1KSIxdNmuc6RlU+4LAU/8EdvY 11pe61NQC7EzDboPy3i8FN/Vg7vjoo5eb52r+58RfGEsTaYiqfFG2U2HQTExCoIedt3i Dl4ERyXo7gNlARMJFuHtIn/0+Z9shtQbEtnW109KB58yxzFTrXXIiGO6uWp809xQrB1w ZaKxmMd5CpeDChEvMgF9QpHnV87l/2qSQHhoseQaoeZXxW47s7UrJxMyKiYokJSoLCs7 OETJwjtnxds/nlCgc340W7jodJHScfn6TX69H5jxY0h3tEhap6Q/9/+SJazMJnqq2s5Q z3xQ== 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=YOid4TZPDFSstLq1udFewCAf/k9umRs9BDiZHIXtkMU=; b=GbX1pYJfRMmZ4Iar3HsG22UCEybq4zXWS/RET6JiXH54ahW8rcGqyDjXqdYAm8/UIS ccJiKTRoSei0G2AzPwrfKa7A4wFTWIflfnN3lpjq2tHM/9GulnuL9agdCvcYb7U1IcvY SVsNJSse2YV0KzGVBZ1PFR/zm8jcstrfDqkYd32ZmIi75HwGZ7JMHQRmtWD0z88AHe51 TVd0HLkGuf0oFPQFhHW6LbwMMlxKJc2AKXz0aEGLeyjl9LTrQOPMv0TqiWrVZpT0c9NN oAxPZjeaNfz55ZMpMbis1Ryj/sHX7QDKYOv/9HllFaGKXrqUZ49ObBw97QWxJ7Dtvmr8 XSQQ== X-Gm-Message-State: AJIora+vjw/TV8AzPN7pg8Ag/KmZwnVgVLdiVTjJAcBKy3kvakPzXWJj 2ZyMajyuMjGHMR9ydXiDm56wb4p9E88rGQ== X-Google-Smtp-Source: AGRyM1vClHFQkMjzD5zBfXs6BknaFHqT045o15B3ZamGtkIAP/qa7ziT3MRlxbozf4LU3/a90b02tw== X-Received: by 2002:a05:6402:2804:b0:431:7dde:6fb5 with SMTP id h4-20020a056402280400b004317dde6fb5mr11115700ede.379.1655455526589; Fri, 17 Jun 2022 01:45:26 -0700 (PDT) Received: from 127.0.0.1localhost.com ([2620:10d:c092:600::2:b65a]) by smtp.gmail.com with ESMTPSA id ot21-20020a170906ccd500b006f3ef214e0esm1844106ejb.116.2022.06.17.01.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 01:45:26 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 2/2] tests: fix and improve nop tests Date: Fri, 17 Jun 2022 09:42:42 +0100 Message-Id: <92f01041e5ef933a6018bd89dd54cc1fae57c6f6.1655455225.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 We removed CQE32 for nops from the kernel, fix the tests and instead test that we return zeroes in the extra fields instead of garbage. Loop over the tests multiple times so it exhausts CQ and we also test CQ entries recycling and internal caching mechanism. Also excersie IOSQE_ASYNC. Signed-off-by: Pavel Begunkov --- test/nop.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/test/nop.c b/test/nop.c index ce223b3..1aa88fc 100644 --- a/test/nop.c +++ b/test/nop.c @@ -15,7 +15,7 @@ static int seq; -static int test_single_nop(struct io_uring *ring) +static int test_single_nop(struct io_uring *ring, unsigned req_flags) { struct io_uring_cqe *cqe; struct io_uring_sqe *sqe; @@ -29,11 +29,8 @@ static int test_single_nop(struct io_uring *ring) } io_uring_prep_nop(sqe); - if (cqe32) { - sqe->addr = 1234; - sqe->addr2 = 5678; - } sqe->user_data = ++seq; + sqe->flags |= req_flags; ret = io_uring_submit(ring); if (ret <= 0) { @@ -51,12 +48,12 @@ static int test_single_nop(struct io_uring *ring) goto err; } if (cqe32) { - if (cqe->big_cqe[0] != 1234) { + if (cqe->big_cqe[0] != 0) { fprintf(stderr, "Unexpected extra1\n"); goto err; } - if (cqe->big_cqe[1] != 5678) { + if (cqe->big_cqe[1] != 0) { fprintf(stderr, "Unexpected extra2\n"); goto err; } @@ -67,7 +64,7 @@ err: return 1; } -static int test_barrier_nop(struct io_uring *ring) +static int test_barrier_nop(struct io_uring *ring, unsigned req_flags) { struct io_uring_cqe *cqe; struct io_uring_sqe *sqe; @@ -84,11 +81,8 @@ static int test_barrier_nop(struct io_uring *ring) io_uring_prep_nop(sqe); if (i == 4) sqe->flags = IOSQE_IO_DRAIN; - if (cqe32) { - sqe->addr = 1234; - sqe->addr2 = 5678; - } sqe->user_data = ++seq; + sqe->flags |= req_flags; } ret = io_uring_submit(ring); @@ -111,11 +105,11 @@ static int test_barrier_nop(struct io_uring *ring) goto err; } if (cqe32) { - if (cqe->big_cqe[0] != 1234) { + if (cqe->big_cqe[0] != 0) { fprintf(stderr, "Unexpected extra1\n"); goto err; } - if (cqe->big_cqe[1] != 5678) { + if (cqe->big_cqe[1] != 0) { fprintf(stderr, "Unexpected extra2\n"); goto err; } @@ -132,7 +126,7 @@ static int test_ring(unsigned flags) { struct io_uring ring; struct io_uring_params p = { }; - int ret; + int ret, i; p.flags = flags; ret = io_uring_queue_init_params(8, &ring, &p); @@ -143,18 +137,21 @@ static int test_ring(unsigned flags) return 1; } - ret = test_single_nop(&ring); - if (ret) { - fprintf(stderr, "test_single_nop failed\n"); - goto err; - } + for (i = 0; i < 1000; i++) { + unsigned req_flags = (i & 1) ? IOSQE_ASYNC : 0; - ret = test_barrier_nop(&ring); - if (ret) { - fprintf(stderr, "test_barrier_nop failed\n"); - goto err; - } + ret = test_single_nop(&ring, req_flags); + if (ret) { + fprintf(stderr, "test_single_nop failed\n"); + goto err; + } + ret = test_barrier_nop(&ring, req_flags); + if (ret) { + fprintf(stderr, "test_barrier_nop failed\n"); + goto err; + } + } err: io_uring_queue_exit(&ring); return ret;