From patchwork Thu Oct 20 01:49: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: 13012535 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 C89D0C433FE for ; Thu, 20 Oct 2022 01:51:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbiJTBvF (ORCPT ); Wed, 19 Oct 2022 21:51:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbiJTBvE (ORCPT ); Wed, 19 Oct 2022 21:51:04 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD00615D0A1 for ; Wed, 19 Oct 2022 18:51:02 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id w18so44020232ejq.11 for ; Wed, 19 Oct 2022 18:51:02 -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 :message-id:reply-to; bh=45GHw6V/7uqAj8k1un4TXI/4zJ+SdB7YUmTI6896xLY=; b=NzJM18oeIKRaiXASR/lKCKDpGlUtITOu7tLiZWrV8y3G+43xhUjl/v7HPTOJT5ow7e r0w5TnXFxYi8pG2YbRlaR9n/xf7J4bYzc9nH4sW0t1TWZK4+9SG4lWyhsh67oMDKaqMr 0uiV1XCk0XsIZXuQaqI61Ke/pmeyUdkwiWKjYGw1c/pXvyyeKXo6S6xtx9nQqhe/kcI6 gs5eGOpxWGMwsbtFuFiw1+Bc9z1lHktx7uveZ9KToA9SSg1ahnZDSZaIRFA+Y7/YfGpI cNpuboLDVvueXc1+GwOgeWxZO6XTwrO0cRMXqRuL50grJAnzpi5KeS/AzDR46ohxuqit 4I2Q== 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=45GHw6V/7uqAj8k1un4TXI/4zJ+SdB7YUmTI6896xLY=; b=vs8eR12vfoeDNQhKYjqodFZ7dnzsiO7wcxenGOHs7oNyOocLnIkSwVV/O9/nWU+2EV 4w3X+5Cf5cLhv1cwP381eFRLqerlPqSJkjYHgp05THhUu63i9cD0+3S+KRBe85rcvPha vreEcOuztuC9ogmHQyzn5ULfd/+ummkEe8MeTXOvM7gS+XjaCrO30kiQ/WqslMLkLuec kJDe00iS8gfxjpJ5Xo7QbdLH4aQJqkmJXczuUP24SS4AHyJjfQC96OOZc9rcVgtwZvzD vpKWdA1K4L6QljD51h3or816LXTKMlh57+gW0+YX2NAbQuJo5ycYJyrHURoUrH6M3VkX 0iug== X-Gm-Message-State: ACrzQf3na0rDji52JC9dKZ9sX2U8gnvuMxnZCWP3s9d8RxpwC7lC47ll 6/kmWxU56dHEg39yX7dMBZQGxmwo4lE= X-Google-Smtp-Source: AMsMyM4RFhuLEIvu1V7oRjxScLUz3yvbRYxd5iMICixmQa6tmveW1yI60iuaRIcbM55xhmnrSUmJvg== X-Received: by 2002:a17:906:ef8b:b0:791:9980:b7b9 with SMTP id ze11-20020a170906ef8b00b007919980b7b9mr9038738ejb.636.1666230661137; Wed, 19 Oct 2022 18:51:01 -0700 (PDT) Received: from 127.0.0.1localhost (94.197.72.2.threembb.co.uk. [94.197.72.2]) by smtp.gmail.com with ESMTPSA id a13-20020a50ff0d000000b00451319a43dasm11318420edu.2.2022.10.19.18.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 18:51:00 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing for-next 1/5] tests: improve zc cflags handling Date: Thu, 20 Oct 2022 02:49:51 +0100 Message-Id: <8ce91fa37051e2b36d5fbb1735a19e2573b2838d.1666230529.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.0 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 4db102b..005220d 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -288,9 +288,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); @@ -335,7 +335,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; @@ -352,13 +352,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) { @@ -367,12 +373,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 Oct 20 01:49: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: 13012537 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 AC08AC43217 for ; Thu, 20 Oct 2022 01:51:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230506AbiJTBvH (ORCPT ); Wed, 19 Oct 2022 21:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbiJTBvH (ORCPT ); Wed, 19 Oct 2022 21:51:07 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F367515DB1B for ; Wed, 19 Oct 2022 18:51:03 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id b12so27810280edd.6 for ; Wed, 19 Oct 2022 18:51:03 -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 :message-id:reply-to; bh=sOADn8KXXdxqhykTm0vT0ios/ldhkL7Pihf8mO8xsCI=; b=efKBk04+su1JZVBDHTBFE5+l6EZleILrsZJyDMTXba0JPz5ocuXLKSOh654o8LszfS iLjDuBsS6VMqq4kIgLP8k6eH4uPNzKZgweS1mbcx1WtAXmQmp3+QGHOTqEkXoKaE80Ap +xQWrI3auLyQzr25uCgU7HABX7MirkjL13nb7vx6L0IkydMRTe8aL5c2i235YhW0sd8f m/bHhl8QB4koXfegAxlGJHuMyBH76MMTLCi5qOzHmYl44yrHzcgLdVWPeovwCBeO6dKV pYdJxB0LUY2s8BUneAOPUwJbVhlPrYQjxl3NA11IJwwIWZgSQYhOyhv12xhOz7H/zJku KV/w== 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=sOADn8KXXdxqhykTm0vT0ios/ldhkL7Pihf8mO8xsCI=; b=fJwzHlkmhANJFjoX8wxgJTXS1qJi2cOdSwvhopKP83ZJwLwfs4p5X4ZHhz2CYCYs8u 6wo6VZ5Vxh4/brp/WJoGy3ImxcEM4G8u8uG7Wl79rbJXFEQlqRP9yyAZ1iIH/xhoWfUN LwuBwzcpb5GKsbIlSaaCXqHTa0F3AVzCsXLuwKJXKLUkskmBTeMgacTe6j/8r2lhj2iR zqJKGct5826H4virYzB8OQ5GyxEtPj0dDuy9Zxc37F89XaGt9dqIMYvwyOfLgdwGxxQj IzC6E9PltJz2kXAT0CcFFAz89ABzABD8u39dJve0tODxWB9lFUQ36XRagTAtQA0q5i+B eo1w== X-Gm-Message-State: ACrzQf0WQsydftu88rITgAkizyxvRILOTsxl1ZbLjogk2/Zdf3F+FO3p bESK4NDozRGzerrGN67O1r+/BQeXBM0= X-Google-Smtp-Source: AMsMyM5bSmY8Ne7XAnAj9o28qoumiM0EiIpev1RckaHt3EA0TImOnTxREU17c7XuUYcsTIoNVaeVuQ== X-Received: by 2002:a05:6402:f96:b0:459:4180:6cf4 with SMTP id eh22-20020a0564020f9600b0045941806cf4mr10075822edb.64.1666230662190; Wed, 19 Oct 2022 18:51:02 -0700 (PDT) Received: from 127.0.0.1localhost (94.197.72.2.threembb.co.uk. [94.197.72.2]) by smtp.gmail.com with ESMTPSA id a13-20020a50ff0d000000b00451319a43dasm11318420edu.2.2022.10.19.18.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 18:51:01 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing for-next 2/5] tests: pass params in a struct Date: Thu, 20 Oct 2022 02:49:52 +0100 Message-Id: <3bf40c6b184b49a9f7a6fe569a25932c209446f6.1666230529.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.0 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 005220d..a69279a 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -254,25 +254,34 @@ static int create_socketpair_ip(struct sockaddr_storage *addr, 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); @@ -281,11 +290,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) @@ -295,15 +304,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); @@ -313,13 +322,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; @@ -388,6 +397,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; @@ -409,35 +419,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 Oct 20 01:49:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13012538 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 3F77FC4332F for ; Thu, 20 Oct 2022 01:51:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbiJTBvI (ORCPT ); Wed, 19 Oct 2022 21:51:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbiJTBvH (ORCPT ); Wed, 19 Oct 2022 21:51:07 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3833015A94F for ; Wed, 19 Oct 2022 18:51:05 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id g27so27795741edf.11 for ; Wed, 19 Oct 2022 18:51:05 -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 :message-id:reply-to; bh=Ub88FywDu/eXdG3lLXCfpl1aayVyR5vajjvg/EkU7D0=; b=c1s+QO69bAJsj2YPg+YYnR4Px/gthTJCY0Mqm2N41JNX/6TryFRITTJqqT79BbgOn2 V8TiVhzpqAZAHL0VFjR6civYcOd3nn75IPtJ9/y7bmKHv6YgC6hN4rfmYF130mZhoPlT JbfoJu420IFlx0sdGpwEDEr7D8zO5ceK4uI1Nxtn+4jN0Sj2gXMNhlAo4+e4tlEbRxxW sCjOZ8k+sBNGuRsLmteILggRWASFR+baCoeRATc1noxonfLn6q32qDszJcAuPfXagK03 IoPboz1nPCDXmoswzz2JeeJXFJTqqUaZPkhc2r1vjKCNFeUIcqfiOkYzA6N7j3bfwH+e 6txw== 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=Ub88FywDu/eXdG3lLXCfpl1aayVyR5vajjvg/EkU7D0=; b=DYl9/9DGbAr0ky1kcyG2rjd9GIUDHAevFWQI4cb6uu6nZjYCURpQpxKgUq5vh+XheA PVCaTV/Ob+TaDjUzqDi3fhzgD2tgoiNn2ZrxH9fqSqn5GFK2LmQzw5698igE47xVOwUU XEPQ1cnQ+f5C2zWSSQwByLJ6x90iRhBETGwLFJ+/kfqonPU1zrJbp1b5iLnoZarpMXhd GH5dQJOkNKYRmdk1EsYMtILlM8yEj8cW/DdAx7zK4bMPlybhiEkVTiBiJzdtDJxPlZ4w OSVTeuvFuHG9I59WFYeS9YLL3eYxXGQr+NuPFwgABjvJPdQpQR3SQQRCUqWMeTshu7XA qAvA== X-Gm-Message-State: ACrzQf07S3H0YDFzxH3JAhJiUtoOqnOvqmvBQ4/F3+idzkAIvBdOHJ/G mmIDq5c26Zhz95+QeUZfmhCK6oVlG+M= X-Google-Smtp-Source: AMsMyM46WbPK5gNQhKIdgjsFew9ZpJ0hbVukIfdlBjj/NZBm7yaJyO8/hPiYAaOgQnhJi1GPh+3Tgg== X-Received: by 2002:a05:6402:ca5:b0:459:3fb0:c157 with SMTP id cn5-20020a0564020ca500b004593fb0c157mr9791563edb.389.1666230663343; Wed, 19 Oct 2022 18:51:03 -0700 (PDT) Received: from 127.0.0.1localhost (94.197.72.2.threembb.co.uk. [94.197.72.2]) by smtp.gmail.com with ESMTPSA id a13-20020a50ff0d000000b00451319a43dasm11318420edu.2.2022.10.19.18.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 18:51:02 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing for-next 3/5] tests: add non-zc tests in send-zerocopy.c Date: Thu, 20 Oct 2022 02:49:53 +0100 Message-Id: <5d3f1be7afe67c2fcff8bcf63c686928477476b6.1666230529.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.0 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 | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index a69279a..646a895 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -261,6 +261,7 @@ struct send_conf { bool force_async; bool use_sendmsg; bool tcp; + bool zc; int buf_index; struct sockaddr_storage *addr; }; @@ -305,8 +306,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; @@ -315,7 +322,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; @@ -418,7 +428,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; @@ -426,8 +436,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) @@ -440,6 +461,8 @@ static int test_inet_send(struct io_uring *ring) continue; if (conf.use_sendmsg && (conf.mix_register || conf.fixed_buf || !has_sendmsg)) continue; + if (msg_zc_set && !conf.zc) + continue; ret = do_test_inet_send(ring, sock_client, sock_server, &conf); if (ret) { From patchwork Thu Oct 20 01:49:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13012539 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 91569C433FE for ; Thu, 20 Oct 2022 01:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230420AbiJTBvJ (ORCPT ); Wed, 19 Oct 2022 21:51:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbiJTBvI (ORCPT ); Wed, 19 Oct 2022 21:51:08 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27B4415F33A for ; Wed, 19 Oct 2022 18:51:06 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id g27so27795779edf.11 for ; Wed, 19 Oct 2022 18:51:06 -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 :message-id:reply-to; bh=fRQtCk7Ki/s2LTufrmyrcMa+mDhtGP7QbQWXDREApAo=; b=BWjWJRZ+AuSTXTUFeH1hRQZwIjJrIb1UyOaX8GlHsMifr+gHR1dgx9yK15s4Z8xVTS GlLH09lbmALFAhQhmamDkvHw3zyk3jmHeVanV74lraVT3PtxlVJbMGCKAU6NmlNT85KR ZePconhYDXQPkv3O1A1Q9zaValyuJwyNbWhiX9IuwjJqbIpjf47yJ7ovQbLU0FhGGgNd bHmENhKMyhohcMmnAF/lNsu5SYg3dbS9a4WtOf3CI/OVCfK7WgAnrw0QiOjwFKdYaQmI 5UQqsO/U0q/vDcmpyrhv0DBb8ZgYaCkFke/A+VJ4Yb9gvCOqQNmipSs7Y/3lyLVOCFB7 HDqw== 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=fRQtCk7Ki/s2LTufrmyrcMa+mDhtGP7QbQWXDREApAo=; b=aS5wprpL24lZTKcSf6iGLNLGSh03cS1KjWtQvCaNjvPvG2aHUwUNMcUTQmS4N0zJvd gbRv97ON7BsO/RUJZe1qvvrmFi+ucVNZW5eZQEx4KJPaLLcZk1UxoptKBVARdG3CdYc/ Yu+VGRkVFoIa2zTfFPRrQnNyKrIwMvmNqdCexBhZUMmuC8GIALJ1ClHdh2MDWel7Nq+D UqiJjORbVnnk6VstzQdniwrVRTlBgcfPEWpH+xQPR8S2Y+YXVh+ZgIUQrXYvT12Ci7ri v+Jm+869lDvSsQeehyqaiGKYxM7JGhROrQGGMj+zXbmMVyRNjeksK7BrH72deQ1CK0dJ DgCQ== X-Gm-Message-State: ACrzQf2z8qXH/ZS1POTzrhEaUqcCvWdObX6/UZoVgWI9yGsuunRUL2gC ZH7yx/W1TRjFBVg/jDe60cnppZkDok4= X-Google-Smtp-Source: AMsMyM5zS1FZ8RQlXNgINyYtBJpD9Wa+OOCy1akMHCfuXJjB/rSiboA+c74dAzgsKz36SuXnllNzLg== X-Received: by 2002:aa7:d357:0:b0:45b:dab5:9789 with SMTP id m23-20020aa7d357000000b0045bdab59789mr10292852edr.222.1666230664427; Wed, 19 Oct 2022 18:51:04 -0700 (PDT) Received: from 127.0.0.1localhost (94.197.72.2.threembb.co.uk. [94.197.72.2]) by smtp.gmail.com with ESMTPSA id a13-20020a50ff0d000000b00451319a43dasm11318420edu.2.2022.10.19.18.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 18:51:04 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing for-next 4/5] tests: add tests for retries with long iovec Date: Thu, 20 Oct 2022 02:49:54 +0100 Message-Id: X-Mailer: git-send-email 2.38.0 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 646a895..010bf50 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 @@ -262,6 +263,8 @@ struct send_conf { bool use_sendmsg; bool tcp; bool zc; + bool iovec; + bool long_iovec; int buf_index; struct sockaddr_storage *addr; }; @@ -269,7 +272,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; @@ -281,6 +284,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; @@ -322,16 +327,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; @@ -428,7 +463,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; @@ -437,10 +474,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, @@ -459,7 +501,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; if (msg_zc_set && !conf.zc) continue; From patchwork Thu Oct 20 01:49:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13012540 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 C0AE8C4332F for ; Thu, 20 Oct 2022 01:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbiJTBvK (ORCPT ); Wed, 19 Oct 2022 21:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbiJTBvJ (ORCPT ); Wed, 19 Oct 2022 21:51:09 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E96160218 for ; Wed, 19 Oct 2022 18:51:07 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id b12so27810410edd.6 for ; Wed, 19 Oct 2022 18:51:07 -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 :message-id:reply-to; bh=V5hVbP21WvWp4Tbq/Evw+Inc3Y3dB3jO1JQfJ1VE0qQ=; b=FEH7PdTFU1R91EbloQeYsJ3+6hZtuv7pKo+zgFlh2oq6wWrlMdBaw+qDUuQ1WsYEt6 8wrbfXhqWoqxfpOxG0s6BkyDVmURdtrW1MTLreof8y6TqAGlA7mtyMrZY8YYqajGrzqD pVYeVyFG0LVJ7XfOmhkFHHLvaQSUCvL6BbSM6QV0/9iMG1fVrpoWlSz2oS9OeLRKCJKY xdkujSUjP+IChx2DAn/KYgPc+4KsXs+gH/wS5flxMAjOw41NApI0pWYZSd0AB8zUv1iX JDsJK9lWiwsbAssl9M3LZNWZwmYwNBmBZlDKSvKdSCoxNdF/kbY4Td21cEglMyjGXwxf WPVg== 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=V5hVbP21WvWp4Tbq/Evw+Inc3Y3dB3jO1JQfJ1VE0qQ=; b=sB1jkgSq6KpI0jGf9LrHWkWesI/bXHUaXc7WWNS3oLhLM6rn8mhPhlnJ/67x0+VG74 VF210xCPYjgxtSrsfTLPPyXnUaMEKZFClaqNvxTdNM+AZ5xDY7UCH30LeRWtn6+97oyV Ow5jRTG2g5FVY2cBwbQmTWlg8mp56ocgcsSm95pfOLOVlqLyCEJjYQ2aV5tz5nyUCd5I 5GL4s9d8QhbskVLwTQp05CSE6CRSjwHyJ8gaAutcxg1m/L3Cx9xMEnBiEXV6xFC9t/rJ 6yjXg4U7JpultIMa6z7sUgEH11SrKgVKxO1LMi0ugZNhHy1EMmB4lsPYHpOx31xM1UrS UqDA== X-Gm-Message-State: ACrzQf008ryIhETK+FsFuQQZ67IjbUw5b9KbZxWRCHYBeXstL5V+s/k5 dwrBbvy6qdrabXu1G8tFvwyt6EzbRZE= X-Google-Smtp-Source: AMsMyM5eJ2O+J3T6MPQVYAJ6eH+M8dFrx5FgiR0eua4QL9p5r0aLzn/s2nZ00t11+QfhJpe6M7yMJw== X-Received: by 2002:aa7:c04f:0:b0:457:1b08:d056 with SMTP id k15-20020aa7c04f000000b004571b08d056mr10481186edo.146.1666230665535; Wed, 19 Oct 2022 18:51:05 -0700 (PDT) Received: from 127.0.0.1localhost (94.197.72.2.threembb.co.uk. [94.197.72.2]) by smtp.gmail.com with ESMTPSA id a13-20020a50ff0d000000b00451319a43dasm11318420edu.2.2022.10.19.18.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 18:51:05 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing for-next 5/5] tests: test poll_first Date: Thu, 20 Oct 2022 02:49:55 +0100 Message-Id: X-Mailer: git-send-email 2.38.0 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index 010bf50..1403fd5 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -265,6 +265,7 @@ struct send_conf { bool zc; bool iovec; bool long_iovec; + bool poll_first; int buf_index; struct sockaddr_storage *addr; }; @@ -375,6 +376,8 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se sqe->user_data = i; if (conf->force_async) sqe->flags |= IOSQE_ASYNC; + if (conf->poll_first) + sqe->ioprio |= IORING_RECVSEND_POLL_FIRST; if (i != nr_reqs - 1) sqe->flags |= IOSQE_IO_LINK; } @@ -463,7 +466,7 @@ static int test_inet_send(struct io_uring *ring) return 1; } - for (i = 0; i < 2048; i++) { + for (i = 0; i < 4096; i++) { bool regbuf; conf.buf_index = i & 3; @@ -476,6 +479,7 @@ static int test_inet_send(struct io_uring *ring) conf.zc = i & 256; conf.iovec = i & 512; conf.long_iovec = i & 1024; + conf.poll_first = i & 2048; conf.tcp = tcp; regbuf = conf.mix_register || conf.fixed_buf;