From patchwork Thu Sep 29 00:03:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12993308 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 47FFEC32771 for ; Thu, 29 Sep 2022 00:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229496AbiI2AFB (ORCPT ); Wed, 28 Sep 2022 20:05:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbiI2AE7 (ORCPT ); Wed, 28 Sep 2022 20:04:59 -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 17D465B051 for ; Wed, 28 Sep 2022 17:04:58 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id cc5so22100045wrb.6 for ; Wed, 28 Sep 2022 17:04:58 -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=xuf35eDdmgnfP746vQ9rPpPl8nRl8vGm+d8UsiKTck0=; b=GSn66RQfrq7IuerFkmJ7mNz4N/1c2quOvSvAEwIk8Km2YBxH9oeEmIifg7yu/6hqIb vl4+rZI6R2RWhy9nS3ZI9JQZXsQ87P4aHC+ZdTCFWy/q5DWadagCyuojgW5XYd/NSbDG Xo9ZtfMqz2T/Y30iMWdPJxNSjt6FkOMurhEAThCOsSs1pxGt0u0HvzCEFJijvri6y3nY VqXchglIvcJ1wiyCf67Qf6U1+/eQdHkgN32X2QPOfOrmSOvrqrzJijwKP9sdDdJM/a5r ZtfJZrNCwPAN5Q3wglfzmRe1v/MIRzSueCpiemmCGcHwQjn79+KQjVcCrx18u9vtdUmr 7hPg== 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=xuf35eDdmgnfP746vQ9rPpPl8nRl8vGm+d8UsiKTck0=; b=IzRWUs1dweYcTOLLjHdAhQ293lrOwTNDX89dK0T+1tUa0JZxiWmiAe7MHrr0vURvJt OiVtaal3F0JrVi8+0JhsYCnNCyVKTGcPe83rsy7FWF5HH7Ekaz69oVxAQpfvJ0uqEA2F USOX8Dm4en4267CNQ6MggZ3Sdu20b992gUIODVO1dsfhSI/EQkVRTy5vkg62lrBENsj2 WSVVp527fuTewYFZki683G2RgmEI76cOKVqhBfn627sCsOQ9k6GaoZOf73luqJeX3IcE u+eNvvTqd7FwBg536LT5HveZVew+dRE+DN9Lc/GxJN3R9C10pnhzj0/eDtkEzQ+4OWWI dGyw== X-Gm-Message-State: ACrzQf3mb/Pkk+QsxBGe2DaoR3whiRfCQu6/HS/XAf1ngYR2Keyp0PaI +t0h70Z0dsBHTqfFp+5lBLXWEnAcfWI= X-Google-Smtp-Source: AMsMyM7BaCWPYc5X7t3oQR/OaGh5HxMNH1gASb09qS2TP9CBcGBJsA5i1qb5ipRVR0KBaTACmJTYmQ== X-Received: by 2002:adf:f501:0:b0:22c:cbea:240a with SMTP id q1-20020adff501000000b0022ccbea240amr238877wro.78.1664409896305; Wed, 28 Sep 2022 17:04:56 -0700 (PDT) Received: from 127.0.0.1localhost (94.196.228.157.threembb.co.uk. [94.196.228.157]) by smtp.gmail.com with ESMTPSA id f14-20020a05600c4e8e00b003b47e75b401sm3284705wmq.37.2022.09.28.17.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 17:04:55 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 1/4] tests: improve zc cflags handling Date: Thu, 29 Sep 2022 01:03:49 +0100 Message-Id: <4ab6329e9a9dc619e009dd8273345bca5ee36584.1664409593.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 Add a couple of tweaks, count nr_cqes on in the loop, so it's easier to adapt for other test cases. Signed-off-by: Pavel Begunkov --- test/send-zerocopy.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index 31d66e3..e58b11c 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -283,9 +283,9 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se if (mix_register) real_fixed_buf = rand() & 1; - if (cork && i != nr_reqs - 1) + if (i != nr_reqs - 1) msg_flags |= MSG_MORE; - if (i == nr_reqs - 1) + else cur_size = chunk_size_last; sqe = io_uring_get_sqe(ring); @@ -330,7 +330,7 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se return 1; } - nr_cqes = 2 * nr_reqs + 1; + nr_cqes = nr_reqs + 1; for (i = 0; i < nr_cqes; i++) { int expected = chunk_size; @@ -347,13 +347,19 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se io_uring_cqe_seen(ring, cqe); continue; } - + if ((cqe->flags & IORING_CQE_F_MORE) && (cqe->flags & IORING_CQE_F_NOTIF)) { + fprintf(stderr, "unexpected cflags %i res %i\n", + cqe->flags, cqe->res); + return 1; + } if (cqe->user_data >= nr_reqs) { fprintf(stderr, "invalid user_data %lu\n", (unsigned long)cqe->user_data); return 1; } if (!(cqe->flags & IORING_CQE_F_NOTIF)) { + if (cqe->flags & IORING_CQE_F_MORE) + nr_cqes++; if (cqe->user_data == nr_reqs - 1) expected = chunk_size_last; if (cqe->res != expected) { @@ -362,12 +368,6 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se return 1; } } - if ((cqe->flags & IORING_CQE_F_MORE) == - (cqe->flags & IORING_CQE_F_NOTIF)) { - fprintf(stderr, "unexpected cflags %i res %i\n", - cqe->flags, cqe->res); - return 1; - } io_uring_cqe_seen(ring, cqe); } From patchwork Thu Sep 29 00:03:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12993309 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 14F56C6FA86 for ; Thu, 29 Sep 2022 00:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229508AbiI2AFB (ORCPT ); Wed, 28 Sep 2022 20:05:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232298AbiI2AFA (ORCPT ); Wed, 28 Sep 2022 20:05:00 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A755F20F for ; Wed, 28 Sep 2022 17:04:59 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id n10so22036462wrw.12 for ; Wed, 28 Sep 2022 17:04:59 -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=EAOWcQ+a3ESXBHnwbnSb5VdHpBVKg5utrvG78Chma6s=; b=Ui5/epuwy8P7nyhFlu6SUxVCfBkXy2+bL1n53bzETcq8I9ETvsNApM17fYFIQ0y8hc 6HhgpTeLSdZp/xdybBmTl+iAscs8XjoOYEaoKBLQIw0GZtjHKi9YzZpMGMnIscqdyr4P fAFjGJz4+6joXGcdY+aQWTgD+P1LW4h06AWC3XCyU/GwyjW1oBU0NAgtIrE4vVGj5ZXj +uScFScwu3ROdZTS0FGyum2bUSdsO9iuz5LF7hhTs+84aQaukwCxkNKhpjv6rQnX1Z/B Dz0KqvZjUuYXAcJ/6QzH9RtxVSdB30dqt/xFjX//CDvSY7UAyBzIKKxfN2Cce7WDx6Fz t5Mg== 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=EAOWcQ+a3ESXBHnwbnSb5VdHpBVKg5utrvG78Chma6s=; b=Xxu9LLG9rJw46NyI5JMJ2OfetAREuXoab2ZtrflCAbyFZBQk2okY9Fv0Wf/xTmgGxk QXgY1ShzS92FiKbdVYqW9tTembvOyG83bGqfFeWa4JviHFRbqCwTZ6Ukb4UzUP9fm0Dw 43XSSWJ/ab8+2TWR3zF1PuEnz1q7xPDOW3RfsNMneCsf37+TRPSVLAwOvPZiWkrHDZqX WbWzUIQfuyHp9wW6rVJDFFnrwPU8dU4MyHjBBXTQA15YAWKL+ZW7X9uUk4/tkDEAES0k ScEmREN7MB28YwGmEk2H2HQ2kCxyaEOD5BNLSaEbdXyqAoqvW98o4fCcK8aUWfuHW6n1 Bq9Q== X-Gm-Message-State: ACrzQf08oG0SZHjU+Yt6YBiuJyw/s/z+TFN4R4fVcFc34rw7Xy7LRQaE Ry/vKZoRIElmVsUJ5a8xWl6YBxZUifI= X-Google-Smtp-Source: AMsMyM5PZLM316iZb15nALtj+9K6rvplcwfQ22NK60GeM23MmpUNWMydAAreR0xzPHU6t5srXJ+5qQ== X-Received: by 2002:a05:6000:1085:b0:228:da84:5d31 with SMTP id y5-20020a056000108500b00228da845d31mr213700wrw.712.1664409897448; Wed, 28 Sep 2022 17:04:57 -0700 (PDT) Received: from 127.0.0.1localhost (94.196.228.157.threembb.co.uk. [94.196.228.157]) by smtp.gmail.com with ESMTPSA id f14-20020a05600c4e8e00b003b47e75b401sm3284705wmq.37.2022.09.28.17.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 17:04:57 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 2/4] tests/zc: pass params in a struct Date: Thu, 29 Sep 2022 01:03:50 +0100 Message-Id: <169e6b83afa4e125fd85a84787fe59012a1b35ad.1664409593.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 | 81 ++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index e58b11c..cdf71ea 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -249,25 +249,34 @@ static int prepare_ip(struct sockaddr_storage *addr, int *sock_client, int *sock return 0; } +struct send_conf { + bool fixed_buf; + bool mix_register; + bool cork; + bool force_async; + bool use_sendmsg; + bool tcp; + int buf_index; + struct sockaddr_storage *addr; +}; + static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_server, - bool fixed_buf, struct sockaddr_storage *addr, - bool cork, bool mix_register, - int buf_idx, bool force_async, bool use_sendmsg) + struct send_conf *conf) { struct iovec iov[CORK_REQS]; struct msghdr msghdr[CORK_REQS]; const unsigned zc_flags = 0; struct io_uring_sqe *sqe; struct io_uring_cqe *cqe; - int nr_reqs = cork ? CORK_REQS : 1; + int nr_reqs = conf->cork ? CORK_REQS : 1; int i, ret, nr_cqes, addr_len = 0; - size_t send_size = buffers_iov[buf_idx].iov_len; + size_t send_size = buffers_iov[conf->buf_index].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; + char *buf = buffers_iov[conf->buf_index].iov_base; - if (addr) { - sa_family_t fam = ((struct sockaddr_in *)addr)->sin_family; + if (conf->addr) { + sa_family_t fam = ((struct sockaddr_in *)conf->addr)->sin_family; addr_len = (fam == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6); @@ -276,11 +285,11 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se memset(rx_buffer, 0, send_size); for (i = 0; i < nr_reqs; i++) { - bool real_fixed_buf = fixed_buf; + bool real_fixed_buf = conf->fixed_buf; size_t cur_size = chunk_size; int msg_flags = MSG_WAITALL; - if (mix_register) + if (conf->mix_register) real_fixed_buf = rand() & 1; if (i != nr_reqs - 1) @@ -290,15 +299,15 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se sqe = io_uring_get_sqe(ring); - if (!use_sendmsg) { + if (!conf->use_sendmsg) { io_uring_prep_send_zc(sqe, sock_client, buf + i * chunk_size, cur_size, msg_flags, zc_flags); if (real_fixed_buf) { sqe->ioprio |= IORING_RECVSEND_FIXED_BUF; - sqe->buf_index = buf_idx; + sqe->buf_index = conf->buf_index; } - if (addr) - io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)addr, + if (conf->addr) + io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)conf->addr, addr_len); } else { io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags); @@ -308,13 +317,13 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se iov[i].iov_base = buf + i * chunk_size; msghdr[i].msg_iov = &iov[i]; msghdr[i].msg_iovlen = 1; - if (addr) { - msghdr[i].msg_name = addr; + if (conf->addr) { + msghdr[i].msg_name = conf->addr; msghdr[i].msg_namelen = addr_len; } } sqe->user_data = i; - if (force_async) + if (conf->force_async) sqe->flags |= IOSQE_ASYNC; if (i != nr_reqs - 1) sqe->flags |= IOSQE_IO_LINK; @@ -383,6 +392,7 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se static int test_inet_send(struct io_uring *ring) { + struct send_conf conf; struct sockaddr_storage addr; int sock_client = -1, sock_server = -1; int ret, j, i; @@ -404,35 +414,34 @@ static int test_inet_send(struct io_uring *ring) } for (i = 0; i < 256; 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; - bool use_sendmsg = i & 128; - - if (buf_flavour == BUF_T_LARGE && !tcp) + conf.buf_index = i & 3; + conf.fixed_buf = i & 4; + conf.addr = (i & 8) ? &addr : NULL; + conf.cork = i & 16; + conf.mix_register = i & 32; + conf.force_async = i & 64; + conf.use_sendmsg = i & 128; + conf.tcp = tcp; + + if (conf.buf_index == BUF_T_LARGE && !tcp) continue; - if (!buffers_iov[buf_flavour].iov_base) + if (!buffers_iov[conf.buf_index].iov_base) continue; - if (tcp && (cork || addr_arg)) + if (tcp && (conf.cork || conf.addr)) continue; - if (mix_register && (!cork || fixed_buf)) + if (conf.mix_register && (!conf.cork || conf.fixed_buf)) continue; - if (!client_connect && addr_arg == NULL) + if (!client_connect && conf.addr == NULL) continue; - if (use_sendmsg && (mix_register || fixed_buf || !has_sendmsg)) + if (conf.use_sendmsg && (conf.mix_register || conf.fixed_buf || !has_sendmsg)) continue; - ret = do_test_inet_send(ring, sock_client, sock_server, fixed_buf, - addr_arg, cork, mix_register, - buf_flavour, force_async, use_sendmsg); + ret = do_test_inet_send(ring, sock_client, sock_server, &conf); if (ret) { fprintf(stderr, "send failed fixed buf %i, conn %i, addr %i, " "cork %i\n", - fixed_buf, client_connect, !!addr_arg, - cork); + conf.fixed_buf, client_connect, !!conf.addr, + conf.cork); return 1; } } From patchwork Thu Sep 29 00:03:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12993310 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 CB08CC32771 for ; Thu, 29 Sep 2022 00:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232792AbiI2AFD (ORCPT ); Wed, 28 Sep 2022 20:05:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiI2AFC (ORCPT ); Wed, 28 Sep 2022 20:05:02 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DD045F7CB for ; Wed, 28 Sep 2022 17:05:00 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id t4so9430386wmj.5 for ; Wed, 28 Sep 2022 17:05:00 -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=L1kxNzLQaK1IY8b/qMyFN3J9URSi5UM5DNdbwJp5icI=; b=X01vdj95udgTRMKqyL8pvBkFbxoheLThUk78gxAGtgUqH2okb0jY4K292zkdhg74r0 LHSeuz4Ign6gpWji64c4/XP5PxoLgkngsOqgkUMAwH/5R0/ra1lEPzBpmGmSXPwb3XMT lSmXgvCsK98VMgrDgVB3+5JhCBmYr0jg4c7pR4LB877V80D+W2y8KEhp856JEbHYoTjZ Ake2s3TT4lsoPXA/EN0Gxd0hKVCmGhqiPkmaMzyBXkuamXcRGYEHbJzq7z/b8ddBOneQ DhMI4Wu1vWuexeux9XHVPbpvzbsLLxEWC6TnIHxT+bwinpetalW5fDKVjYr3skOYAjWB IXBA== 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=L1kxNzLQaK1IY8b/qMyFN3J9URSi5UM5DNdbwJp5icI=; b=5hvh8SURHk5lUPnbgfXuNydPFz3608vl0s3OP9UO64GnmHkjFR08vIRXXWv4qxFbpx flnCZmBCYFG/QwAapKPXKJ1jJMTDeW/KEs8+LsjuWDhya7O895ifziJo8xDCdjKS8yf5 p07zblVcfc1Nalx5rDwwOIEs9Z72tNEQnNkTYCMkOwhs06y49nz7T8xd+U+CnEQH6fZJ 1JUPdJZ5kobPBzsZ6sRG6Bz4jYtBEnBScU1Om4IB5U10tCvZLI6HCuvKle0kyH2+TYcb ix8FRcbENBtre/M8Yu1SQj629zrjilXa9Nv+PLmm77l3RtOGg1d+70AdqnOaG2n/Ihv5 YO5w== X-Gm-Message-State: ACrzQf3txA9MCCA5fm2k8vWEJgZ3V8vqz3jFONl8eTQnVchmq2Wpp9WP iqbGJ0RXsqdgd9r7l6hrngiOfPhK3pY= X-Google-Smtp-Source: AMsMyM5JjrKwEXgKNmmliN1EIOZEOI8YjK573OLVM4RE9TMSftAFJJ6qKwRb7RcAqiY3b7kRn3tPGA== X-Received: by 2002:a05:600c:1e08:b0:3b4:8fef:d63c with SMTP id ay8-20020a05600c1e0800b003b48fefd63cmr8485192wmb.158.1664409898480; Wed, 28 Sep 2022 17:04:58 -0700 (PDT) Received: from 127.0.0.1localhost (94.196.228.157.threembb.co.uk. [94.196.228.157]) by smtp.gmail.com with ESMTPSA id f14-20020a05600c4e8e00b003b47e75b401sm3284705wmq.37.2022.09.28.17.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 17:04:58 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 3/4] tests: add non-zc tests in send-zerocopy.c Date: Thu, 29 Sep 2022 01:03:51 +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 We don't have good tests for normal non-zerocopy paths. Add them to test_inet_send(), which covers lots of different cases. We can move it into send_recv.c or so later. Signed-off-by: Pavel Begunkov --- test/send-zerocopy.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index cdf71ea..b51f421 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -256,6 +256,7 @@ struct send_conf { bool force_async; bool use_sendmsg; bool tcp; + bool zc; int buf_index; struct sockaddr_storage *addr; }; @@ -300,8 +301,14 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se sqe = io_uring_get_sqe(ring); if (!conf->use_sendmsg) { - io_uring_prep_send_zc(sqe, sock_client, buf + i * chunk_size, - cur_size, msg_flags, zc_flags); + if (conf->zc) { + io_uring_prep_send_zc(sqe, sock_client, buf + i * chunk_size, + cur_size, msg_flags, zc_flags); + } else { + io_uring_prep_send(sqe, sock_client, buf + i * chunk_size, + cur_size, msg_flags); + } + if (real_fixed_buf) { sqe->ioprio |= IORING_RECVSEND_FIXED_BUF; sqe->buf_index = conf->buf_index; @@ -310,7 +317,10 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)conf->addr, addr_len); } else { - io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags); + if (conf->zc) + io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags); + else + io_uring_prep_sendmsg(sqe, sock_client, &msghdr[i], msg_flags); memset(&msghdr[i], 0, sizeof(msghdr[i])); iov[i].iov_len = cur_size; @@ -413,7 +423,7 @@ static int test_inet_send(struct io_uring *ring) return 1; } - for (i = 0; i < 256; i++) { + for (i = 0; i < 512; i++) { conf.buf_index = i & 3; conf.fixed_buf = i & 4; conf.addr = (i & 8) ? &addr : NULL; @@ -421,8 +431,19 @@ static int test_inet_send(struct io_uring *ring) conf.mix_register = i & 32; conf.force_async = i & 64; conf.use_sendmsg = i & 128; + conf.zc = i & 256; conf.tcp = tcp; + if (!conf.zc) { + if (conf.mix_register || conf.fixed_buf) + continue; + /* + * Non zerocopy send w/ addr was added together with sendmsg_zc, + * skip if we the kernel doesn't support it. + */ + if (conf.addr && !has_sendmsg) + continue; + } if (conf.buf_index == BUF_T_LARGE && !tcp) continue; if (!buffers_iov[conf.buf_index].iov_base) From patchwork Thu Sep 29 00:03:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12993311 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 EB74DC6FA82 for ; Thu, 29 Sep 2022 00:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbiI2AFE (ORCPT ); Wed, 28 Sep 2022 20:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232380AbiI2AFD (ORCPT ); Wed, 28 Sep 2022 20:05:03 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EF06DF4D for ; Wed, 28 Sep 2022 17:05:01 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id u16-20020a05600c211000b003b5152ebf09so2258628wml.5 for ; Wed, 28 Sep 2022 17:05:01 -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=dxX5/rXeLjku7BfLtox9Zy/kAxNAfz5xG0/Ffg3rAMA=; b=CKYsv6gI9JA4TDg3VL9JvkW++Pbkh6BUHt5Gt9FV/7RkfsIwizKNHqzLY0vXe8swY+ rK4Mc2ScOTpfnBpJ1B1UHtodHdc2A8q/TW4O49VnfPyQ/Cn0S/E71qeubnDv62+O0kLB o9bNxUjhJ+zxDGiv4RoghxIi3+I6ejLUuMFBzfKgtYhQf3evcmnrKcdiQDUQnT3IfK1Q bzIOozh7E/xYdZv3EGpAfUmW8ouBXTrIUD/f7/+Azhj2J+eIel+8NbfYrqgCCkVJEIQR 4kNeUhTOOOCDnF+2YYHhf6I5eb0XS3b49EinzvK5T9K7MaP0Jm1Hpwmb+LTNVJuIuqJ9 bIVA== 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=dxX5/rXeLjku7BfLtox9Zy/kAxNAfz5xG0/Ffg3rAMA=; b=DOVtIngEgFmA6IoRkceQgLKH9y0NxW+D0rShZktynrnbBpzer+K/+Wkg2ipSNv/c6f IPlPbZbSheJG+YbKbKtz12kgYP6RvIvHRQv2v7KnfIDtsUeQ2KBt1YDWlJYddnIMtyCs 5v7wlQ/EA6T4SXFMmUyBP60XjMEm8nABWhUbo8K/plIGtI/L/kfXhPRaMJyZgH8lYaIz /lZdgBtW/86wegiDXGfzxUKTTPUwLNUQqTXnywngvlxnigj0gRtU2KnEbVVYXj0qsrqu NrvjXAX2Aj66+8lIMTtatUiceE4MPnZPIsrqkUZ7K3OVVOGzZdKGKqDWaRvoZSIKjTL+ qBKw== X-Gm-Message-State: ACrzQf3JWs6t77egQIOrUTZaQTA4AcBWODRHmFoquGo3xQHCVbAc27Kn j8KrQIf0BBGL/ALXH4oVhsIUD4Jkg5U= X-Google-Smtp-Source: AMsMyM4M1rsyfeSLuQRWiie24tKNzwH7vrOwxzAeOTvIbuAMuS/Nd0kG2bL4JcEBsuzkXtQtKk69WQ== X-Received: by 2002:a7b:cb41:0:b0:3b3:34d6:189f with SMTP id v1-20020a7bcb41000000b003b334d6189fmr8653536wmj.6.1664409899662; Wed, 28 Sep 2022 17:04:59 -0700 (PDT) Received: from 127.0.0.1localhost (94.196.228.157.threembb.co.uk. [94.196.228.157]) by smtp.gmail.com with ESMTPSA id f14-20020a05600c4e8e00b003b47e75b401sm3284705wmq.37.2022.09.28.17.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 17:04:59 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 4/4] tests: add tests for retries with long iovec Date: Thu, 29 Sep 2022 01:03:52 +0100 Message-Id: <2a1e442706e07c9bf6cc4ccb06cd6c5fe2e4c04a.1664409593.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 | 58 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index b51f421..adf730d 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -44,6 +44,7 @@ #define HOST "127.0.0.1" #define HOSTV6 "::1" +#define MAX_IOV 32 #define CORK_REQS 5 #define RX_TAG 10000 #define BUFFER_OFFSET 41 @@ -257,6 +258,8 @@ struct send_conf { bool use_sendmsg; bool tcp; bool zc; + bool iovec; + bool long_iovec; int buf_index; struct sockaddr_storage *addr; }; @@ -264,7 +267,7 @@ struct send_conf { static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_server, struct send_conf *conf) { - struct iovec iov[CORK_REQS]; + struct iovec iov[MAX_IOV]; struct msghdr msghdr[CORK_REQS]; const unsigned zc_flags = 0; struct io_uring_sqe *sqe; @@ -276,6 +279,8 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se size_t chunk_size_last = send_size - chunk_size * (nr_reqs - 1); char *buf = buffers_iov[conf->buf_index].iov_base; + assert(MAX_IOV >= CORK_REQS); + if (conf->addr) { sa_family_t fam = ((struct sockaddr_in *)conf->addr)->sin_family; @@ -317,16 +322,46 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)conf->addr, addr_len); } else { + struct iovec *io; + int iov_len; + if (conf->zc) io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags); else io_uring_prep_sendmsg(sqe, sock_client, &msghdr[i], msg_flags); + if (!conf->iovec) { + io = &iov[i]; + iov_len = 1; + iov[i].iov_len = cur_size; + iov[i].iov_base = buf + i * chunk_size; + } else { + char *it = buf; + int j; + + assert(nr_reqs == 1); + iov_len = conf->long_iovec ? MAX_IOV : 4; + io = iov; + + for (j = 0; j < iov_len; j++) + io[j].iov_len = 1; + /* first want to be easily advanced */ + io[0].iov_base = it; + it += io[0].iov_len; + /* this should cause retry */ + io[1].iov_len = chunk_size - iov_len + 1; + io[1].iov_base = it; + it += io[1].iov_len; + /* fill the rest */ + for (j = 2; j < iov_len; j++) { + io[j].iov_base = it; + it += io[j].iov_len; + } + } + memset(&msghdr[i], 0, sizeof(msghdr[i])); - iov[i].iov_len = cur_size; - iov[i].iov_base = buf + i * chunk_size; - msghdr[i].msg_iov = &iov[i]; - msghdr[i].msg_iovlen = 1; + msghdr[i].msg_iov = io; + msghdr[i].msg_iovlen = iov_len; if (conf->addr) { msghdr[i].msg_name = conf->addr; msghdr[i].msg_namelen = addr_len; @@ -423,7 +458,9 @@ static int test_inet_send(struct io_uring *ring) return 1; } - for (i = 0; i < 512; i++) { + for (i = 0; i < 2048; i++) { + bool regbuf; + conf.buf_index = i & 3; conf.fixed_buf = i & 4; conf.addr = (i & 8) ? &addr : NULL; @@ -432,10 +469,15 @@ static int test_inet_send(struct io_uring *ring) conf.force_async = i & 64; conf.use_sendmsg = i & 128; conf.zc = i & 256; + conf.iovec = i & 512; + conf.long_iovec = i & 1024; conf.tcp = tcp; + regbuf = conf.mix_register || conf.fixed_buf; + if (conf.iovec && (!conf.use_sendmsg || regbuf || conf.cork)) + continue; if (!conf.zc) { - if (conf.mix_register || conf.fixed_buf) + if (regbuf) continue; /* * Non zerocopy send w/ addr was added together with sendmsg_zc, @@ -454,7 +496,7 @@ static int test_inet_send(struct io_uring *ring) continue; if (!client_connect && conf.addr == NULL) continue; - if (conf.use_sendmsg && (conf.mix_register || conf.fixed_buf || !has_sendmsg)) + if (conf.use_sendmsg && (regbuf || !has_sendmsg)) continue; ret = do_test_inet_send(ring, sock_client, sock_server, &conf);