From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4169C433C1 for ; Tue, 30 Mar 2021 10:31:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B70F2619A9 for ; Tue, 30 Mar 2021 10:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231701AbhC3Kaf (ORCPT ); Tue, 30 Mar 2021 06:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231579AbhC3KaX (ORCPT ); Tue, 30 Mar 2021 06:30:23 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E36CC061574 for ; Tue, 30 Mar 2021 03:30:20 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id j18so15720745wra.2 for ; Tue, 30 Mar 2021 03:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=IlEfzAhLue7KXkSCB3k2Sceuj/YicMS0nq+WNJb1zpw=; b=T2jgvpDYCcb1qHcYOXIf4acdORmzWDc80nHU1h8uc1A465Vim95uW0POCK4T65PQpA BKVmSdKlKRQZMCYh+Q5eeHjVReTLOIZSX39Ylj8dpPrXpmc0igE2cV6WGh6UsQRjcd6c b3bRskl7ul4XwNySfmZ5Q6B733UCFqcdc8bbGavuc/djFBQdqhAEnDLF04RQ58AQHcKr S3ZuRavOihK9YCoOtl921zppHWThvUcqLsm/8LQhq6Y3x+uW4kyIQuADdIVjmK048AO/ MkmkjEWfYstzoO7yHehEMxoQwpMkg+F/+1m7PPdvQoRfYbdUcE9BLvrDioJ/Ni8HHj2T shBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=IlEfzAhLue7KXkSCB3k2Sceuj/YicMS0nq+WNJb1zpw=; b=Xs/8/EcuphWdH+sE46wurbQqaiuXI3Kkutu7trCiSDxOZRvtRjxBHMi3b/52LsEIuJ /ZPAXaINVTh0gHpfI1DMeCzs4+qaY8j264kYkXWOJFaKr8lSt2mm/d5bwW/huc0ruayM Q+7NWQ2wqzzjDvMcb8Rpr5bvnkVhwFaLAQ+5DS2obYmroTiQsuLmS+tW18Ww+1kQn/AP MtqaX7mVt7dgZhuvmGSaaLKjhFxiq09FeQoJv28Kio9YKm9YbsMixBiViZvaXS0TD/eB US1fzRcNYAegbYISRqGq3wG+wdJVnbtQJotHVoBlWgLNYmGVrZjoFKyJR4jGO/VsfyXR 6eYQ== X-Gm-Message-State: AOAM533VBfkkb9ih3SfZzOumMjvW6AeBmnbrVuIQbDxveuRDoFOtYqzY 3mXalSa4BNypZEvAjzDseJxTQAF8swXZRA== X-Google-Smtp-Source: ABdhPJzU/rFIHL/HXio2Q5GYy2zG8aPrlnhI7t/1cpO7ucUhGRmNoU5OiNvOvdnH8w5/sVWf7PiFyg== X-Received: by 2002:a5d:604b:: with SMTP id j11mr23719938wrt.424.1617100219453; Tue, 30 Mar 2021 03:30:19 -0700 (PDT) Received: from localhost.localdomain ([85.255.234.174]) by smtp.gmail.com with ESMTPSA id c131sm2794178wma.37.2021.03.30.03.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 03:30:18 -0700 (PDT) From: Pavel Begunkov To: Jens Axboe , io-uring@vger.kernel.org Subject: [PATCH liburing] tests: test CQE ordering on early submission fail Date: Tue, 30 Mar 2021 11:26:09 +0100 Message-Id: X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Check that CQEs of a link comes in the order of submission, even when a link fails early during submission initial prep. Signed-off-by: Pavel Begunkov --- test/link.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/link.c b/test/link.c index c89d6b2..fadd0b5 100644 --- a/test/link.c +++ b/test/link.c @@ -429,6 +429,53 @@ err: return 1; } +static int test_link_fail_ordering(struct io_uring *ring) +{ + struct io_uring_cqe *cqe; + struct io_uring_sqe *sqe; + int ret, i, nr_compl; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_nop(sqe); + sqe->flags |= IOSQE_IO_LINK; + sqe->user_data = 0; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_write(sqe, -1, NULL, 100, 0); + sqe->flags |= IOSQE_IO_LINK; + sqe->user_data = 1; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_nop(sqe); + sqe->flags |= IOSQE_IO_LINK; + sqe->user_data = 2; + + nr_compl = ret = io_uring_submit(ring); + /* at least the first nop should have been submitted */ + if (ret < 1) { + fprintf(stderr, "sqe submit failed: %d\n", ret); + goto err; + } + + for (i = 0; i < nr_compl; i++) { + ret = io_uring_wait_cqe(ring, &cqe); + if (ret) { + fprintf(stderr, "wait completion %d\n", ret); + goto err; + } + if (cqe->user_data != i) { + fprintf(stderr, "wrong CQE order, got %i, expected %i\n", + (int)cqe->user_data, i); + goto err; + } + io_uring_cqe_seen(ring, cqe); + } + + return 0; +err: + return 1; +} + int main(int argc, char *argv[]) { struct io_uring ring, poll_ring; @@ -492,5 +539,11 @@ int main(int argc, char *argv[]) return ret; } + ret = test_link_fail_ordering(&ring); + if (ret) { + fprintf(stderr, "test_link_fail_ordering last failed\n"); + return ret; + } + return 0; } -- 2.24.0