From patchwork Fri Nov 4 11:05: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: 13031651 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 6E9DEC43217 for ; Fri, 4 Nov 2022 11:08:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbiKDLH6 (ORCPT ); Fri, 4 Nov 2022 07:07:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbiKDLHq (ORCPT ); Fri, 4 Nov 2022 07:07:46 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AABC1A20F for ; Fri, 4 Nov 2022 04:07:45 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id d26so12292057eje.10 for ; Fri, 04 Nov 2022 04:07:45 -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=HgAMscCPPAhCavrOsCy3bwUWODYv1hI3zI94H1LqKf8=; b=Qhtp+tWubT9eaWJUT044z9P+v92gcOi0LMg3PkYdeWJZWTDV/g32FN7Xu3+wX9y15J Vl5pCyrkxsHLEorpyhAPiNZrMnEPVBN3iqqbA323IoCNUZ9C2S5wYD9ZwOONw5RKGhSB EGvsGp/tIizfaklB2kmTK1ClwLVuWMS4gGir9Bd/Jx3GacGqnmFUxvdXtPNKu6ilL+91 KD8q181rBMPjVJHXFKuZIkn+v00/R5emWh/mDTZfMRAaKXPHifGy9c3nxjULisJ6GXXc yIFcS7SLyCWzn4XKNDK0+AF/e8gt7SZNCdgUiTCQw/eEqgApnRB0w85R8wLJoPHAcfc2 gJ6Q== 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=HgAMscCPPAhCavrOsCy3bwUWODYv1hI3zI94H1LqKf8=; b=P+NoJ+Mq2tbVvEWKYvpddHEh4lIoq3W2MJIwADvgXlQJWzHzEe/NhTVbeZzoaBa/rA JvjqYmforzAqy2rLN/cQlb42VGV6NxVJbUI9lknPh/UwghKFt5IxdA44n7zd9UvEhH5b J8Dr7pFe/VYnwQLm0taJPci7m3VRvzZSlQ5LkEBbr1fn0qaWTKXigrwsLqGxgvDk/YxD //jjcSD2Fhz9rgRsoBv/QI09gEk5N9u2juMcVX8MJJGxopWR6Rw4Up8ndiTLsISGCXzZ eJg7JSXWeGnVWedZvetj1LOpkB6iiOq52R4GZ1jD+2P/QSpBICpLeE2W04AIhwuyZ78K K4dQ== X-Gm-Message-State: ACrzQf2A2IchQYFy8AON4SH/VwZAjUb1cSKlwIn9wBFQjVTgwjrOZ1Od eDn6XtcptY1NkMPLgizF0Pu4gFRPkzY= X-Google-Smtp-Source: AMsMyM6aYwpbNZ1Ssq5sgO87AdupqtHjK273uU3K8SGYrL1Q/q6mmCZ+P7o7z4vilBzctiUApaIsdw== X-Received: by 2002:a17:907:6d1b:b0:7a1:11a9:1334 with SMTP id sa27-20020a1709076d1b00b007a111a91334mr5412423ejc.131.1667560063696; Fri, 04 Nov 2022 04:07:43 -0700 (PDT) Received: from 127.0.0.1localhost.com ([2620:10d:c092:600::2:4173]) by smtp.gmail.com with ESMTPSA id bg19-20020a170906a05300b0078df26efb7dsm1665491ejb.107.2022.11.04.04.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 04:07:43 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 1/3] tests/zc: create a new ring for test_send_faults() Date: Fri, 4 Nov 2022 11:05:51 +0000 Message-Id: <2c2adfcd0d89d1961dab3c3a1265f0d26c73e03e.1667559818.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 need IORING_SETUP_SUBMIT_ALL for test_send_faults() to be sure io_uring doesn't stop submission on first failure. Signed-off-by: Pavel Begunkov --- test/send-zerocopy.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index a50b5b1..30b50e1 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -116,7 +116,7 @@ static int test_basic_send(struct io_uring *ring, int sock_tx, int sock_rx) return T_EXIT_PASS; } -static int test_send_faults(struct io_uring *ring, int sock_tx, int sock_rx) +static int test_send_faults(int sock_tx, int sock_rx) { struct io_uring_sqe *sqe; struct io_uring_cqe *cqe; @@ -124,24 +124,31 @@ static int test_send_faults(struct io_uring *ring, int sock_tx, int sock_rx) unsigned zc_flags = 0; int payload_size = 100; int ret, i, nr_cqes = 2; + struct io_uring ring; - sqe = io_uring_get_sqe(ring); + ret = io_uring_queue_init(32, &ring, IORING_SETUP_SUBMIT_ALL); + if (ret) { + fprintf(stderr, "queue init failed: %d\n", ret); + return -1; + } + + sqe = io_uring_get_sqe(&ring); io_uring_prep_send_zc(sqe, sock_tx, (void *)1UL, payload_size, msg_flags, zc_flags); sqe->user_data = 1; - sqe = io_uring_get_sqe(ring); + sqe = io_uring_get_sqe(&ring); io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size, msg_flags, zc_flags); sqe->user_data = 2; io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)1UL, sizeof(struct sockaddr_in6)); - ret = io_uring_submit(ring); + ret = io_uring_submit(&ring); assert(ret == 2); for (i = 0; i < nr_cqes; i++) { - ret = io_uring_wait_cqe(ring, &cqe); + ret = io_uring_wait_cqe(&ring, &cqe); assert(!ret); assert(cqe->user_data <= 2); @@ -150,9 +157,9 @@ static int test_send_faults(struct io_uring *ring, int sock_tx, int sock_rx) if (cqe->flags & IORING_CQE_F_MORE) nr_cqes++; } - io_uring_cqe_seen(ring, cqe); + io_uring_cqe_seen(&ring, cqe); } - assert(check_cq_empty(ring)); + assert(check_cq_empty(&ring)); return T_EXIT_PASS; } @@ -728,7 +735,7 @@ int main(int argc, char *argv[]) has_sendmsg = io_check_zc_sendmsg(&ring); - ret = test_send_faults(&ring, sp[0], sp[1]); + ret = test_send_faults(sp[0], sp[1]); if (ret) { fprintf(stderr, "test_send_faults() failed\n"); return T_EXIT_FAIL; From patchwork Fri Nov 4 11:05: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: 13031652 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 23FFDC433FE for ; Fri, 4 Nov 2022 11:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230507AbiKDLIA (ORCPT ); Fri, 4 Nov 2022 07:08:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231493AbiKDLHr (ORCPT ); Fri, 4 Nov 2022 07:07:47 -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 61FBA644D for ; Fri, 4 Nov 2022 04:07:46 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id r14so7075516edc.7 for ; Fri, 04 Nov 2022 04:07:46 -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=ukBWgP1IqPf+hr/q+Re1wnZEtefqk8gst+cV6x82YFM=; b=iQyrYQkbTKC3q2njaAxZIxhDBJtMKZTGQuoiM5YImXfasCROMmVOuXqYTRQY8ldguH S01gMW0nFLgmVXBJZunCaXOe+hnTu1Mc1onWE2fWOM7BW3evGBLjLyWrHcZSPO1TDY58 PY3fJ9gBEpwX9g4oX7YCzj+aINQxeDiUSCwvtPpny5lfA9La87ENz+8BHzs5G+V2+xet 2caqjwuNyDweJec8uQz4RHP4QS+gyeRrl1Qzs1jM3EPjkL6CVf38VLzcYYVYiYyqAwpC NoMBkvtxjpzX69Kj4yM1sZJ7CG7zIXW7hsMWaR5Rj8aKFzThfDjaMmBiFe+obcDX0Tp+ fsjA== 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=ukBWgP1IqPf+hr/q+Re1wnZEtefqk8gst+cV6x82YFM=; b=u7jE5vHBZoFaQMsz+G/NO3KSgw4h/NyLfcJRJ+Ey69cm6f8kKvqn8YgmMRvqHh1gYQ mkvQo/684+9sKSQyGO4IgoQ1/RGvivpB4YbV80XAcO9osz8VOnYqyIQsAPGTPV/vzXg8 Gi3cJ7w8RPXwVyDcsOZvt8lfeHza799tE0ybKyV/oQCMRHfTm7D60IAtWWssu8Vq6A53 MQusC3ikaMQhOGdRb3iElV3D0jF8MeHejivVNcdu904vPN7qZ9olq1nVj1xTgT5GSwh7 kY5RFafyp+e39Jf2X8o9PE1RCM4pJ4N3zjJFdWar+yVud2NVMA9KwFUSo/yBtpDLKiPX wo/w== X-Gm-Message-State: ACrzQf2cRU69wjtMH+jqawEo0n/nv12YyRhTZz+lLjz1Cwlo5K+7eC6E TTR8byowB0BNDl9VzEvIjJaOiGlatT8= X-Google-Smtp-Source: AMsMyM6UPvLdhEZo+nnPyU7g6TmQ8VmRuhgDhE1MkLzt866b6wCUocG3CllCd8xlC0BsFk1sk34rxA== X-Received: by 2002:a05:6402:164d:b0:464:4ac8:d269 with SMTP id s13-20020a056402164d00b004644ac8d269mr6404704edx.394.1667560064609; Fri, 04 Nov 2022 04:07:44 -0700 (PDT) Received: from 127.0.0.1localhost.com ([2620:10d:c092:600::2:4173]) by smtp.gmail.com with ESMTPSA id bg19-20020a170906a05300b0078df26efb7dsm1665491ejb.107.2022.11.04.04.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 04:07:44 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 2/3] tests/zc: add control flags tests Date: Fri, 4 Nov 2022 11:05:52 +0000 Message-Id: <49b3b714bce66a056b645afe894748f7cabd548d.1667559818.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 | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index 30b50e1..6e637f4 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -123,7 +123,7 @@ static int test_send_faults(int sock_tx, int sock_rx) int msg_flags = 0; unsigned zc_flags = 0; int payload_size = 100; - int ret, i, nr_cqes = 2; + int ret, i, nr_cqes, nr_reqs = 3; struct io_uring ring; ret = io_uring_queue_init(32, &ring, IORING_SETUP_SUBMIT_ALL); @@ -132,28 +132,44 @@ static int test_send_faults(int sock_tx, int sock_rx) return -1; } + /* invalid buffer */ sqe = io_uring_get_sqe(&ring); io_uring_prep_send_zc(sqe, sock_tx, (void *)1UL, payload_size, msg_flags, zc_flags); sqe->user_data = 1; + /* invalid address */ sqe = io_uring_get_sqe(&ring); io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size, msg_flags, zc_flags); - sqe->user_data = 2; io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)1UL, sizeof(struct sockaddr_in6)); + sqe->user_data = 2; + + /* invalid send/recv flags */ + sqe = io_uring_get_sqe(&ring); + io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size, + msg_flags, ~0U); + sqe->user_data = 3; ret = io_uring_submit(&ring); - assert(ret == 2); + assert(ret == nr_reqs); + nr_cqes = nr_reqs; for (i = 0; i < nr_cqes; i++) { ret = io_uring_wait_cqe(&ring, &cqe); assert(!ret); - assert(cqe->user_data <= 2); + assert(cqe->user_data <= nr_reqs); if (!(cqe->flags & IORING_CQE_F_NOTIF)) { - assert(cqe->res == -EFAULT); + int expected = (cqe->user_data == 3) ? -EINVAL : -EFAULT; + + if (cqe->res != expected) { + fprintf(stderr, "invalid cqe res %i vs expected %i, " + "user_data %i\n", + cqe->res, expected, (int)cqe->user_data); + return -1; + } if (cqe->flags & IORING_CQE_F_MORE) nr_cqes++; } From patchwork Fri Nov 4 11:05: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: 13031653 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 D8936C4332F for ; Fri, 4 Nov 2022 11:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231444AbiKDLIB (ORCPT ); Fri, 4 Nov 2022 07:08:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbiKDLHs (ORCPT ); Fri, 4 Nov 2022 07:07:48 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 469FD2197 for ; Fri, 4 Nov 2022 04:07:47 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id d26so12292267eje.10 for ; Fri, 04 Nov 2022 04:07:47 -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=wUnKgN9y5bbjKoQlksOPotWUAOB6t+mfVTCU+Adt/ZU=; b=ZB1A3YlN/buspGldexEx5wIBfnlFT6h/w4oMzO/fZika0bCEb+txSl9YZcC3W8nRpu eAtpgnLu77RCK2CKmsn0GfkesXlvuvB7dOLJvV6Og/mPBc1/0HPFIVdx0tZrsA3lHE8i hxxlvJDtdhy1jWiPORbl2mbAeUHp3xl5K07qfwpVtnf+rJ3afS3B7b5M9IkXUAuuZOgT eEDBwkZc0F8+xeLn40rL2d3jA9AD85XSFtUi9WyecljBxWTFyBCKFoY4654VSWelVwYR 0vLGBD0ZUDvzCa4BTWOkMDDuHOlX00DBYvtfB0bxQMlJeP9omMMBNcDLc4kMaWX3kmW/ wCkA== 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=wUnKgN9y5bbjKoQlksOPotWUAOB6t+mfVTCU+Adt/ZU=; b=mc1iLJ0KPEjwoA4VbwAxzMJAXGSPdzFmOciX50lvsDKjnBrtX9Cbw2FMBuiLdpAL1p 1oFAq4qj1RJPhc3XhUa/+bjBPsl3OGgVe1IHKvUVb3G/dyqVFk1ZV33T9hCpNpRXDXlR GgJjfZdzA8YrkeRFQRpvVUpVVjXMbupKaoXzb1jZtWfSj8iVtw13FtzwbqcwlCq94dlg iQWL5AfGJQavnhmoLRAJX/OurMKX9Rdz1EW0tnpyysPmknbHigi/APvYiexD7Rfc6OP6 Vrd2wwjPWoukGDoQaNww0G2lK2S1DWz6tXIPEJ+qbpT5fz/irlGrD3p0reMcAkLXdjfm odoQ== X-Gm-Message-State: ACrzQf0BRWY7hdCKRdNP/I1eKKonet4tdRaRfaLT1WOa/YOW5ObSwy4+ Wm7X6OFzwdPC2YuxMNlMTVRuWlplDH8= X-Google-Smtp-Source: AMsMyM6WRIW8ztzCu4PG5CtYtFZ5Jv4LIOEv8odD5FckSTff9d2PjMM1HxFpnTgNTMR74vsGet3WGg== X-Received: by 2002:a17:907:2da6:b0:78d:3cf1:9132 with SMTP id gt38-20020a1709072da600b0078d3cf19132mr34237411ejc.299.1667560065538; Fri, 04 Nov 2022 04:07:45 -0700 (PDT) Received: from 127.0.0.1localhost.com ([2620:10d:c092:600::2:4173]) by smtp.gmail.com with ESMTPSA id bg19-20020a170906a05300b0078df26efb7dsm1665491ejb.107.2022.11.04.04.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 04:07:45 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH liburing 3/3] tests/zc: extra verification for notif completions Date: Fri, 4 Nov 2022 11:05:53 +0000 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, 6 insertions(+) diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c index 6e637f4..16830df 100644 --- a/test/send-zerocopy.c +++ b/test/send-zerocopy.c @@ -172,6 +172,12 @@ static int test_send_faults(int sock_tx, int sock_rx) } if (cqe->flags & IORING_CQE_F_MORE) nr_cqes++; + } else { + if (cqe->res != 0 || cqe->flags != IORING_CQE_F_NOTIF) { + fprintf(stderr, "invalid notif cqe %i %i\n", + cqe->res, cqe->flags); + return -1; + } } io_uring_cqe_seen(&ring, cqe); }