From patchwork Mon Sep 5 22:05:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12966580 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 29002ECAAA1 for ; Mon, 5 Sep 2022 22:08:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbiIEWIQ (ORCPT ); Mon, 5 Sep 2022 18:08:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232592AbiIEWIO (ORCPT ); Mon, 5 Sep 2022 18:08:14 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFBFA5723B for ; Mon, 5 Sep 2022 15:08:12 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id bz13so9473271wrb.2 for ; Mon, 05 Sep 2022 15:08:12 -0700 (PDT) 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; bh=+6GKmuMBvxvZ7P18wLcMpxJrZ6oY37ClDCfrGbE2Lhw=; b=pUBbrQd2bZq2aR3lK4jg7v7EXO3guqtqKRm+4jbJz7BdTtL/JzeF2B+6DI9nS1AEud sJEH23ZKH3X1wsXwZsSnx9by8wDMD/e4CGWXHkcZGJlkgk8/kQH2ck5gaTu8wmReW0+I 996EDk6aaZITGDn5DBcPyZmMSAHXlmVEKG3ehVZAUEONABn3cBCFo26mGu5Hm3T2W74P DpZwOTzJoNYbwGSXGbx05ujwcN32wVqBUKHjz9C2EzYohs4pyZF6tq1guw6teoY23ja6 9+jM+KZoDU3YQhgAKvQFI443RFr4dp+ugtvADmAVp8u0ZqJbf/vYgSXnZvYcXGQHzXRM heLQ== 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; bh=+6GKmuMBvxvZ7P18wLcMpxJrZ6oY37ClDCfrGbE2Lhw=; b=KR5PBIDViNSbeSf+BQ25dpovuCHUmk4hIhAXnQs7aLKAAsSCtEM1gfm1s1c8tNEsgQ gCtvFz5oZBateqOorXgLfRbuIW5Wm4hkybrR10K3g0lLPIAapx2iSM+cb2exFHmF2i9w Z/RliUz03yPkgo8+NaesdI6VMazs6H7yaRVMt1hrylie4I98UGAGT9vmm5M10NDOs6qO NJvF2NS13ZlO1z/7xXASioW2PPZYwUrNsvs9IPR2Y7UFV0T7EDox6LqbR5Ixq0x2yOh/ BiTWgXfRzgL822gdF0XlJsdTAYgH73alkBtPg0rxBPVtYBjlbsJty5N16oOpuX5WKJ35 cdmQ== X-Gm-Message-State: ACgBeo1W64m50wle4bj+MVu+yTi3Vi+UQkplmZojGfMt0hqbOmdpH2CH +IK0WgSPfZ7y3LXxG4N59rc5XLryxp4= X-Google-Smtp-Source: AA6agR6CgnO3rar6OPy7vyltQfnYUwGEo6/j/0rkQJ3RK1rdtSY2CuWF2yCOb1GplVEegrJSy2y6OQ== X-Received: by 2002:a5d:6f19:0:b0:228:d8e8:3ac8 with SMTP id ay25-20020a5d6f19000000b00228d8e83ac8mr169227wrb.101.1662415690875; Mon, 05 Sep 2022 15:08:10 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.126.24.threembb.co.uk. [188.28.126.24]) by smtp.gmail.com with ESMTPSA id z7-20020a05600c0a0700b003a5c1e916c8sm33791067wmp.1.2022.09.05.15.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 15:08:10 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing v2 1/5] tests/zc: move send size calc into do_test_inet_send Date: Mon, 5 Sep 2022 23:05:58 +0100 Message-Id: X-Mailer: git-send-email 2.37.2 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/send-zerocopy.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index 8714b6f..0a8531e 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -238,7 +238,7 @@ static int prepare_ip(struct sockaddr_storage *addr, int *sock_client, int *sock static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_server, bool fixed_buf, struct sockaddr_storage *addr, - size_t send_size, bool cork, bool mix_register, + bool small_send, bool cork, bool mix_register, int buf_idx, bool force_async) { const unsigned zc_flags = 0; @@ -246,13 +246,13 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se struct io_uring_cqe *cqe; int nr_reqs = cork ? 5 : 1; int i, ret, nr_cqes; + size_t send_size = small_send ? 137 : buffers_iov[buf_idx].iov_len; size_t chunk_size = send_size / nr_reqs; size_t chunk_size_last = send_size - chunk_size * (nr_reqs - 1); char *buf = buffers_iov[buf_idx].iov_base; pid_t p; int wstatus; - assert(send_size <= buffers_iov[buf_idx].iov_len); memset(rx_buffer, 0, send_size); for (i = 0; i < nr_reqs; i++) { @@ -394,7 +394,7 @@ static int test_inet_send(struct io_uring *ring) for (i = 0; i < 256; i++) { bool fixed_buf = i & 1; struct sockaddr_storage *addr_arg = (i & 2) ? &addr : NULL; - size_t size = (i & 4) ? 137 : 4096; + bool small_send = i & 4; bool cork = i & 8; bool mix_register = i & 16; bool aligned = i & 32; @@ -406,8 +406,7 @@ static int test_inet_send(struct io_uring *ring) continue; if (large_buf) { buf_idx = 2; - size = buffers_iov[buf_idx].iov_len; - if (!aligned || !tcp) + if (!aligned || !tcp || small_send) continue; } if (!buffers_iov[buf_idx].iov_base) @@ -420,7 +419,7 @@ static int test_inet_send(struct io_uring *ring) continue; ret = do_test_inet_send(ring, sock_client, sock_server, fixed_buf, - addr_arg, size, cork, mix_register, + addr_arg, small_send, cork, mix_register, buf_idx, force_async); if (ret) { fprintf(stderr, "send failed fixed buf %i, conn %i, addr %i, " @@ -535,8 +534,8 @@ int main(int argc, char *argv[]) return T_EXIT_FAIL; } - buffers_iov[0].iov_base = tx_buffer; - buffers_iov[0].iov_len = 8192; + buffers_iov[0].iov_base = tx_buffer + 4096; + buffers_iov[0].iov_len = 4096; buffers_iov[1].iov_base = tx_buffer + BUFFER_OFFSET; buffers_iov[1].iov_len = 8192 - BUFFER_OFFSET - 13; From patchwork Mon Sep 5 22:05:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12966581 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 D6DD9C6FA83 for ; Mon, 5 Sep 2022 22:08:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231421AbiIEWIQ (ORCPT ); Mon, 5 Sep 2022 18:08:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232633AbiIEWIP (ORCPT ); Mon, 5 Sep 2022 18:08:15 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7F3F51A0D for ; Mon, 5 Sep 2022 15:08:13 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id n17so12894629wrm.4 for ; Mon, 05 Sep 2022 15:08:13 -0700 (PDT) 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; bh=hIx/uQLZr8G/oqBxR1JafNpk64QXFQUgFBNLn+IqcbQ=; b=TtkupnSCgAV8btJwBl92bWeryNQbLKzrK8YlgJdjolRLQQhWpw4bney3JokuOV7Qco +pCkOMsVv9KbuEzhHIYNkqGHlV+xF9VO0VxyiwpdXPpZw37vCQy7ipgK6VHeaEeqeWvY hBvQd8yav9S8CSeDSJq+OILC6lQxN2F0SyFTt2jRHNXT5z8B38jMQt1bkntrYRcbNkKQ UpGHLKO4ksUsUTRXx+yA40izwWiLHQGVAI3lbA0RpLiPZOImVvNz3J/BJkU+pDyL5YEo vCeFw+UryMo1uqLNEFpcHFaxig+YNdpKhDARAfj0xDepldvgZL1xBGihfnXvKArQAGea CyRQ== 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; bh=hIx/uQLZr8G/oqBxR1JafNpk64QXFQUgFBNLn+IqcbQ=; b=GvNWWeQpqL8VDMTxoBiM8+atQaTtn0eWsX+NdaWLvOquy6uy8n/sZiCypMIFo5Xlg8 WKSOLn8DzzfZO9IxRDb/6rVGjAjT1p23UKq4Oml1KrMfpStfoK36TV4C7cbFTsZxAVXv ocGxmioFPiC3sdRG8pbv8IyP3AlyR0rbg1XD7nw4sT9o8OeyYxQ/41a9beImwJ+snRTu Qp+UHU5S0wtxNY/UeLBEiC/XYCWxAIDgLz3bTUH8axd9cj/zfPNgyaaAnVIF4FOkrQw4 Bbjr0Jo5cD4eHqxpgpFXsyyPkk/BHvwHhEBlKBO6RoiKC/3KgT4MLXREtcKZMwAPJPX1 xzuQ== X-Gm-Message-State: ACgBeo3p06uco/deeGneovbj+FUSZVHheIemBxrOlyEpwAq0BNUOhPeL KiRzH40GXcPVyVXX5f95RuKleRZvgTw= X-Google-Smtp-Source: AA6agR4vRjucT5s/JY2VXDMlosO84w15pPZqboLNcSbRcrXae3Bi7NMNRizSST8ny66kqwOGr1qI9g== X-Received: by 2002:a5d:544a:0:b0:228:64cd:243b with SMTP id w10-20020a5d544a000000b0022864cd243bmr5069752wrv.238.1662415691829; Mon, 05 Sep 2022 15:08:11 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.126.24.threembb.co.uk. [188.28.126.24]) by smtp.gmail.com with ESMTPSA id z7-20020a05600c0a0700b003a5c1e916c8sm33791067wmp.1.2022.09.05.15.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 15:08:11 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing v2 2/5] tests/zc: use io_uring for rx Date: Mon, 5 Sep 2022 23:05:59 +0100 Message-Id: X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Recieve via io_uring, this simplifies code by removing forking. Signed-off-by: Pavel Begunkov --- test/send-zerocopy.c | 70 +++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index 0a8531e..f80a5cd 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -44,7 +44,7 @@ #define HOST "127.0.0.1" #define HOSTV6 "::1" -#define ZC_TAG 10000 +#define RX_TAG 10000 #define BUFFER_OFFSET 41 #ifndef ARRAY_SIZE @@ -250,8 +250,6 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se size_t chunk_size = send_size / nr_reqs; size_t chunk_size_last = send_size - chunk_size * (nr_reqs - 1); char *buf = buffers_iov[buf_idx].iov_base; - pid_t p; - int wstatus; memset(rx_buffer, 0, send_size); @@ -289,42 +287,17 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se sqe->flags |= IOSQE_ASYNC; } + sqe = io_uring_get_sqe(ring); + io_uring_prep_recv(sqe, sock_server, rx_buffer, send_size, MSG_WAITALL); + sqe->user_data = RX_TAG; + ret = io_uring_submit(ring); - if (ret != nr_reqs) { + if (ret != nr_reqs + 1) { fprintf(stderr, "submit failed, got %i expected %i\n", ret, nr_reqs); return 1; } - p = fork(); - if (p == -1) { - fprintf(stderr, "fork() failed\n"); - return 1; - } else if (p == 0) { - size_t bytes_received = 0; - - while (bytes_received != send_size) { - ret = recv(sock_server, - rx_buffer + bytes_received, - send_size - bytes_received, 0); - if (ret <= 0) { - fprintf(stderr, "recv failed, got %i, errno %i\n", - ret, errno); - exit(1); - } - bytes_received += ret; - } - - for (i = 0; i < send_size; i++) { - if (buf[i] != rx_buffer[i]) { - fprintf(stderr, "botched data, first mismated byte %i, " - "%u vs %u\n", i, buf[i], rx_buffer[i]); - exit(1); - } - } - exit(0); - } - - nr_cqes = 2 * nr_reqs; + nr_cqes = 2 * nr_reqs + 1; for (i = 0; i < nr_cqes; i++) { int expected = chunk_size; @@ -333,8 +306,18 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret); return 1; } + if (cqe->user_data == RX_TAG) { + if (cqe->res != send_size) { + fprintf(stderr, "rx failed %i\n", cqe->res); + return 1; + } + io_uring_cqe_seen(ring, cqe); + continue; + } + if (cqe->user_data >= nr_reqs) { - fprintf(stderr, "invalid user_data\n"); + fprintf(stderr, "invalid user_data %lu\n", + (unsigned long)cqe->user_data); return 1; } if (!(cqe->flags & IORING_CQE_F_NOTIF)) { @@ -354,17 +337,12 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se io_uring_cqe_seen(ring, cqe); } - if (waitpid(p, &wstatus, 0) == (pid_t)-1) { - perror("waitpid()"); - return 1; - } - if (!WIFEXITED(wstatus)) { - fprintf(stderr, "child failed %i\n", WEXITSTATUS(wstatus)); - return 1; - } - if (WEXITSTATUS(wstatus)) { - fprintf(stderr, "child failed\n"); - return 1; + for (i = 0; i < send_size; i++) { + if (buf[i] != rx_buffer[i]) { + fprintf(stderr, "botched data, first mismated byte %i, " + "%u vs %u\n", i, buf[i], rx_buffer[i]); + return 1; + } } return 0; } From patchwork Mon Sep 5 22:06:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12966582 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 20C00ECAAA1 for ; Mon, 5 Sep 2022 22:08:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231331AbiIEWIS (ORCPT ); Mon, 5 Sep 2022 18:08:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232525AbiIEWIR (ORCPT ); Mon, 5 Sep 2022 18:08:17 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA5E15B04E for ; Mon, 5 Sep 2022 15:08:14 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id bd26-20020a05600c1f1a00b003a5e82a6474so6366745wmb.4 for ; Mon, 05 Sep 2022 15:08:14 -0700 (PDT) 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; bh=AKrZ1urcngCqlh4eeSJunnwPCrMDBRenolGBDYtEd20=; b=d93NuYUmP4wBknHanSaFrre0GEk7fq2okamL5PihkWE8KEjB1aiogd62sHaTH5XVbd mc/rH76UDBv06QtpYZ2/5T8qbKbZPYJlV9PZBUutBjq0nkO8VO8/Jv8y0YfgnLJelmoQ vJeB0eUuAu5GQP1XPykrgDVm783Z5JgoA9aU+itTlOPSFkkFjzgyb42CU+2oEaNi/E5B C1zYgmJaWGP+zNu2l3w5nw0ti9kzdAOvoOI+W1g29BJlqkssc/FjLggTJXrLHGX5PP2d MEJWxvboaKNFX/fM5A3ErzIbrxQC3gbP+9mHCN1JWFt3po2JqKt7HNqrm4PBCaYjWXJq CGyQ== 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; bh=AKrZ1urcngCqlh4eeSJunnwPCrMDBRenolGBDYtEd20=; b=o399xLbSOdeA1asPKOHYttQs07GQZPKFpeHg9su4LmPiT9iTP7oq3IVHvRmefSTv7x HCWvDJi5Guu0wK7Emg6kNIL7fLQTt0d+ilfD3dvR/RYSTTmjEmXpUgsbJJGREfoYnw+g WDk5WQ4/QUCu786GRSDdcADBHLyMnAAtJ4uHgg3h8P/HbU/yoo8L78FkyKg9lJ7m0uTe qrrPzjzaDSkdbvEp/O/ziBHYnsV4WHLQHaT4itLN9IaSpyXxeDe6PV6vYlOBIhgfca/h 9yruJ6tSjS6FwSXLdyGIYXwA+GQwH+HB8N08RRWSIuHQnyoPaBu2hSLjszE1IEsW8EDJ jnvA== X-Gm-Message-State: ACgBeo2NsENGpQTeyuLkyjnHUJ+SKeWQxxzM0IqIwMdJyFSLeOMjezli f4KyQz9bQXB8HnIw6NDHBwyIC0M/K5E= X-Google-Smtp-Source: AA6agR5KxGDaxuJWUfO6iN81dJpthifB3PpTTVR3+2a0uPCQPme4amSfUCCAHvExqessivDZXt5m7A== X-Received: by 2002:a05:600c:3512:b0:3a5:e9d3:d418 with SMTP id h18-20020a05600c351200b003a5e9d3d418mr12098780wmq.0.1662415692915; Mon, 05 Sep 2022 15:08:12 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.126.24.threembb.co.uk. [188.28.126.24]) by smtp.gmail.com with ESMTPSA id z7-20020a05600c0a0700b003a5c1e916c8sm33791067wmp.1.2022.09.05.15.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 15:08:12 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing v2 3/5] tests/zc: fix udp testing Date: Mon, 5 Sep 2022 23:06:00 +0100 Message-Id: X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org The tcp vs large_buf skip condition is not what we want and it skips udp testing, fix it and also make sure we serialise cork requests with IOSQE_IO_LINK as they might get executed OOO. Signed-off-by: Pavel Begunkov --- test/send-zerocopy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index f80a5cd..bfe4cf7 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -285,6 +285,8 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se } if (force_async) sqe->flags |= IOSQE_ASYNC; + if (cork && i != nr_reqs - 1) + sqe->flags |= IOSQE_IO_LINK; } sqe = io_uring_get_sqe(ring); @@ -380,11 +382,9 @@ static int test_inet_send(struct io_uring *ring) int buf_idx = aligned ? 0 : 1; bool force_async = i & 128; - if (!tcp || !large_buf) - continue; if (large_buf) { buf_idx = 2; - if (!aligned || !tcp || small_send) + if (!aligned || !tcp || small_send || cork) continue; } if (!buffers_iov[buf_idx].iov_base) From patchwork Mon Sep 5 22:06:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12966583 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 BD7FDECAAD3 for ; Mon, 5 Sep 2022 22:08:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231821AbiIEWIS (ORCPT ); Mon, 5 Sep 2022 18:08:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232558AbiIEWIR (ORCPT ); Mon, 5 Sep 2022 18:08:17 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EDDD52478 for ; Mon, 5 Sep 2022 15:08:15 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id t7so7849293wrm.10 for ; Mon, 05 Sep 2022 15:08:15 -0700 (PDT) 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; bh=ZdoJFONLECkquhpfAoDXLsgpqQvHhQguLo+f31RzLwY=; b=ZEh8JVWLRTB8ABe8vT4YRioE1GuVwt9jT0qNvDu62nogl3cR3PaVK0US5zamhzQDey o9+wX4Vb0I43tyyQird6cdFXuKoz0bqqDOosQa8rE8t0w1AUD7awxqO1CIB2IiBFxIhW bo5INRIZuDBptoKDSdy8oAFXmJVsUYv3mLBSfnJmMrbAPKaasnT9kDwJb6iNhdTzB7KK tILskpruAMMfW+1rWKc1p5Cn/0cJNl64xAYQeTt1yidWkREwlP5IB43AL2R2Y4fzMqFN HcCcqWrZiV9PeGO36uw2W0T9H1FhtKOQMfFmHkUZ+oPXf1njODMseByHHuQ/oVMx8LWA QSGQ== 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; bh=ZdoJFONLECkquhpfAoDXLsgpqQvHhQguLo+f31RzLwY=; b=aJnqmw+an0ax+NKhaad/XsTM78AAeaK2SN+KSZFekITNHGVKrHz3sgX08pTFTr1X4K zG4K0BlDjA1Q36fOxjYyp5ADysbdfa6ZdTPCVY/mQQeKkKnaNzx8abVsYrF7r+Z5Uws9 sKPinLoxXK6Ez4ldgLVy72dnRWOMfQp+olBp2f+zx6jAacNCG/nHDqKOK9UeuCG/6rnx ss75eysUYb+5zYWq3qDJEKfUqTCq5xiSFuudAeXZ49TXi1YWp2tEHO5qRtWsS8Z784i+ kIEbdua8f5ndcs79PHeNhL5g/7qWVhgbPyTdr2SnlazSlZyW8kByVqaQ7nWpJqybGyGV kW+g== X-Gm-Message-State: ACgBeo0ro5seldGE5c0ZKaL0/C5zIqeh/TOP3EtB/M6/NmaQeOOTiMgt 1OyDkJaIXjdEc589tDSQ+luwHi8hDa0= X-Google-Smtp-Source: AA6agR45Tj9xbFCnYkiqqct4V3RuWRWHA5aGUYNhTGK+8YIRjmQ9PynOhFdMyMWrJMjEB6ubZq2vMQ== X-Received: by 2002:adf:ed81:0:b0:226:a509:14b6 with SMTP id c1-20020adfed81000000b00226a50914b6mr25284237wro.150.1662415693906; Mon, 05 Sep 2022 15:08:13 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.126.24.threembb.co.uk. [188.28.126.24]) by smtp.gmail.com with ESMTPSA id z7-20020a05600c0a0700b003a5c1e916c8sm33791067wmp.1.2022.09.05.15.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 15:08:13 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing v2 4/5] tests/zc: name buffer flavours Date: Mon, 5 Sep 2022 23:06:01 +0100 Message-Id: <0ad14b1b4cf74ab503c32e945e150dbcbf678961.1662404421.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Remove duplicating tests and pass a buf index instead of dozens of flags to specify the buffer we want to use. Signed-off-by: Pavel Begunkov --- test/send-zerocopy.c | 59 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index bfe4cf7..f996f22 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -51,8 +51,15 @@ #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) #endif +enum { + BUF_T_NORMAL, + BUF_T_SMALL, + BUF_T_NONALIGNED, + BUF_T_LARGE, +}; + static char *tx_buffer, *rx_buffer; -static struct iovec buffers_iov[3]; +static struct iovec buffers_iov[4]; static bool check_cq_empty(struct io_uring *ring) { @@ -238,7 +245,7 @@ static int prepare_ip(struct sockaddr_storage *addr, int *sock_client, int *sock static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_server, bool fixed_buf, struct sockaddr_storage *addr, - bool small_send, bool cork, bool mix_register, + bool cork, bool mix_register, int buf_idx, bool force_async) { const unsigned zc_flags = 0; @@ -246,7 +253,7 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se struct io_uring_cqe *cqe; int nr_reqs = cork ? 5 : 1; int i, ret, nr_cqes; - size_t send_size = small_send ? 137 : buffers_iov[buf_idx].iov_len; + size_t send_size = buffers_iov[buf_idx].iov_len; size_t chunk_size = send_size / nr_reqs; size_t chunk_size_last = send_size - chunk_size * (nr_reqs - 1); char *buf = buffers_iov[buf_idx].iov_base; @@ -371,23 +378,17 @@ static int test_inet_send(struct io_uring *ring) return 1; } - for (i = 0; i < 256; i++) { - bool fixed_buf = i & 1; - struct sockaddr_storage *addr_arg = (i & 2) ? &addr : NULL; - bool small_send = i & 4; - bool cork = i & 8; - bool mix_register = i & 16; - bool aligned = i & 32; - bool large_buf = i & 64; - int buf_idx = aligned ? 0 : 1; - bool force_async = i & 128; - - if (large_buf) { - buf_idx = 2; - if (!aligned || !tcp || small_send || cork) - continue; - } - if (!buffers_iov[buf_idx].iov_base) + for (i = 0; i < 128; i++) { + int buf_flavour = i & 3; + bool fixed_buf = i & 4; + struct sockaddr_storage *addr_arg = (i & 8) ? &addr : NULL; + bool cork = i & 16; + bool mix_register = i & 32; + bool force_async = i & 64; + + if (buf_flavour == BUF_T_LARGE && !tcp) + continue; + if (!buffers_iov[buf_flavour].iov_base) continue; if (tcp && cork) continue; @@ -397,8 +398,8 @@ static int test_inet_send(struct io_uring *ring) continue; ret = do_test_inet_send(ring, sock_client, sock_server, fixed_buf, - addr_arg, small_send, cork, mix_register, - buf_idx, force_async); + addr_arg, cork, mix_register, + buf_flavour, force_async); if (ret) { fprintf(stderr, "send failed fixed buf %i, conn %i, addr %i, " "cork %i\n", @@ -498,8 +499,8 @@ int main(int argc, char *argv[]) tx_buffer = aligned_alloc(4096, len); rx_buffer = aligned_alloc(4096, len); if (tx_buffer && rx_buffer) { - buffers_iov[2].iov_base = tx_buffer; - buffers_iov[2].iov_len = len; + buffers_iov[BUF_T_LARGE].iov_base = tx_buffer; + buffers_iov[BUF_T_LARGE].iov_len = len; } else { printf("skip large buffer tests, can't alloc\n"); @@ -512,10 +513,12 @@ int main(int argc, char *argv[]) return T_EXIT_FAIL; } - buffers_iov[0].iov_base = tx_buffer + 4096; - buffers_iov[0].iov_len = 4096; - buffers_iov[1].iov_base = tx_buffer + BUFFER_OFFSET; - buffers_iov[1].iov_len = 8192 - BUFFER_OFFSET - 13; + buffers_iov[BUF_T_NORMAL].iov_base = tx_buffer + 4096; + buffers_iov[BUF_T_NORMAL].iov_len = 4096; + buffers_iov[BUF_T_SMALL].iov_base = tx_buffer; + buffers_iov[BUF_T_SMALL].iov_len = 137; + buffers_iov[BUF_T_NONALIGNED].iov_base = tx_buffer + BUFFER_OFFSET; + buffers_iov[BUF_T_NONALIGNED].iov_len = 8192 - BUFFER_OFFSET - 13; ret = io_uring_queue_init(32, &ring, 0); if (ret) { From patchwork Mon Sep 5 22:06:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12966584 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 6D499C6FA83 for ; Mon, 5 Sep 2022 22:08:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232328AbiIEWIT (ORCPT ); Mon, 5 Sep 2022 18:08:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231480AbiIEWIR (ORCPT ); Mon, 5 Sep 2022 18:08:17 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AABD251A0D for ; Mon, 5 Sep 2022 15:08:16 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id ay39-20020a05600c1e2700b003a5503a80cfso6377322wmb.2 for ; Mon, 05 Sep 2022 15:08:16 -0700 (PDT) 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; bh=vR4+2X/z/Zv2XLVvonQCP2Kyh5vtobI+HtIIAYhbxmM=; b=YtoNM5DCnsGnmC28wA7REJMTJPKq0dfupsSllR2L3WMCnrq0+OfVETZJor54C+m/VA Sm0cnWJcwzAa69LPwy7qU02bxaBFIPeNdt8lwLVk4hBG1+3gcls/YFRvMEJz57rwEkvV R1VB1pI/7WfaM5fjtEa9sEt6f7qz1F1WADD9Ah6ih54vr9YU8w2W/nl7ERrsiO+/vlK/ hB/SHdhiXNhVPS74LWyHdbob2tuYlWkdOn8nhfBPckziIj81yma5M0+V08wnaw7Jn0Gi N0Y98+6BHhA/++J/8n6aEavSalEWcNZZqYq+I9ace0UAdvps9yUlJS9GaSLzNdw4Z55A U11A== 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; bh=vR4+2X/z/Zv2XLVvonQCP2Kyh5vtobI+HtIIAYhbxmM=; b=SP1KXlRzwwU1fGPDNuxJM/3DRcW2nEN9qBZZjGmXJ6EPCoTLUb86cofcFBPPAPYtCF fwEbss5KDe6rdJQGxaF+7d1YGIYlZUzIhz7zycIdbfJT6e+XTlGEM2zEw01PSlBXEyb9 YtHpnM3YHARd8dWaBW3ZAfif1w8tb/6VfXsHQZGFrXraXf+036JpqUM6B5ztSJX3eX/2 UZTo2keM02G/KQTYafnQr8AOBm3xkf6spG6IAlVrlduDL3Lm92a3/zddIP5wlxwsRc0V bRaU8RqXjA8OFGX9KcGK1mRbHdrSxW++s0ClGms4j4sOHUW6W0aqgronEzD3F/IVQhC3 LCsQ== X-Gm-Message-State: ACgBeo0ylyJQ8UgpjXl/MUN1JinGfgudmPG+O5NyagkNhx/6Ig0AQcI+ 7IlZ4rJ+14GpBNHke87HHG/tcPsrDMY= X-Google-Smtp-Source: AA6agR5l3N3Iiwh/KjqlnYJ7ttlnj5Ud4Ds5PEibgruF7djTxyhi0lGjzRw/HSRDV+ofNKTVfqylqw== X-Received: by 2002:a05:600c:418a:b0:3a5:e724:21d4 with SMTP id p10-20020a05600c418a00b003a5e72421d4mr12119595wmh.168.1662415694947; Mon, 05 Sep 2022 15:08:14 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.126.24.threembb.co.uk. [188.28.126.24]) by smtp.gmail.com with ESMTPSA id z7-20020a05600c0a0700b003a5c1e916c8sm33791067wmp.1.2022.09.05.15.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 15:08:14 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing v2 5/5] tests/zc: skip tcp w/ addr Date: Mon, 5 Sep 2022 23:06:02 +0100 Message-Id: <77860403d6fa96a9288e037ede9dcae23a4314e2.1662404421.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.37.2 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/send-zerocopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index f996f22..39c5c5d 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -390,7 +390,7 @@ static int test_inet_send(struct io_uring *ring) continue; if (!buffers_iov[buf_flavour].iov_base) continue; - if (tcp && cork) + if (tcp && (cork || addr_arg)) continue; if (mix_register && (!cork || fixed_buf)) continue;