From patchwork Thu Jul 21 14:42:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12925301 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 DA8C9C43334 for ; Thu, 21 Jul 2022 14:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229540AbiGUOm5 (ORCPT ); Thu, 21 Jul 2022 10:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiGUOm4 (ORCPT ); Thu, 21 Jul 2022 10:42:56 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E91808688C for ; Thu, 21 Jul 2022 07:42:55 -0700 (PDT) Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26L3weDX007158 for ; Thu, 21 Jul 2022 07:42:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=uO0KAPMm6YGt6ajJYA3hrW+Dyimx5K+isJgcvILlXlU=; b=n/v5wy/AF5cobS1tWAabgfDUz0B7RK/X708xpdyKhofckscjLoIGCzcvXL0lgc/KMIlH rFlhNMK1itKgXq6cs4XExhG0nzZE68h2rUMCmkYdlXOSB0CMkE/wa7xUHN0Hp22nn7SA Qq3umto/g7n7t8jq2x1yHQTGLyBxFydLf5w= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3heyc8ttcv-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 21 Jul 2022 07:42:55 -0700 Received: from twshared33626.07.ash9.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 21 Jul 2022 07:42:54 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 709CB3593BA3; Thu, 21 Jul 2022 07:42:50 -0700 (PDT) From: Dylan Yudaken To: , CC: , , Dylan Yudaken Subject: [PATCH liburing 1/4] add a test for bad buf_ring register Date: Thu, 21 Jul 2022 07:42:26 -0700 Message-ID: <20220721144229.1224141-2-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220721144229.1224141-1-dylany@fb.com> References: <20220721144229.1224141-1-dylany@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: NU4hOaOi2L1D2ENvKUk8lag6IZ0kGa5i X-Proofpoint-ORIG-GUID: NU4hOaOi2L1D2ENvKUk8lag6IZ0kGa5i X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_18,2022-07-20_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org This shows up a kernel panic in v5.19-rc7 Signed-off-by: Dylan Yudaken --- test/buf-ring.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/buf-ring.c b/test/buf-ring.c index 5e032663d93b..b17030cbe952 100644 --- a/test/buf-ring.c +++ b/test/buf-ring.c @@ -206,6 +206,30 @@ static int test_reg_unreg(int bgid) return 0; } +static int test_bad_reg(int bgid) +{ + struct io_uring ring; + int ret; + struct io_uring_buf_reg reg = { }; + + ret = t_create_ring(1, &ring, 0); + if (ret == T_SETUP_SKIP) + return 0; + else if (ret != T_SETUP_OK) + return 1; + + reg.ring_addr = 4096; + reg.ring_entries = 32; + reg.bgid = bgid; + + ret = io_uring_register_buf_ring(&ring, ®, 0); + if (!ret) + fprintf(stderr, "Buffer ring register worked unexpectedly\n"); + + io_uring_queue_exit(&ring); + return !ret; +} + static int test_one_read(int fd, int bgid, struct io_uring *ring) { int ret; @@ -359,6 +383,12 @@ int main(int argc, char *argv[]) if (no_buf_ring) break; + ret = test_bad_reg(bgids[i]); + if (ret) { + fprintf(stderr, "test_bad_reg failed\n"); + return T_EXIT_FAIL; + } + ret = test_double_reg_unreg(bgids[i]); if (ret) { fprintf(stderr, "test_double_reg_unreg failed\n"); From patchwork Thu Jul 21 14:42:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12925302 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 064F2C433EF for ; Thu, 21 Jul 2022 14:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbiGUOnA (ORCPT ); Thu, 21 Jul 2022 10:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbiGUOm7 (ORCPT ); Thu, 21 Jul 2022 10:42:59 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF75F8688C for ; Thu, 21 Jul 2022 07:42:58 -0700 (PDT) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LCAf5T023800 for ; Thu, 21 Jul 2022 07:42:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=FPASyAN564D/lc/S3W9vE3+3soN/s8+Q9bnq2cCVTTw=; b=kux8e5k4tWwKtFTa6SKgr+ff/1DtScpbzPRqWN3KC6j8ddCRRyF1UmZ3VhIeq9YtFABM T0WOQLKmKJt88ozTXzgmk+k9AQAgpTpUUYMFnDmFDGll6OKJz8qftGI4l1Tp9Gqh5b4U hCM3XAThKXXDXMtxBz6LU9iFckXb9d4qQBQ= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3hf6jjrvbw-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 21 Jul 2022 07:42:58 -0700 Received: from twshared39111.03.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 21 Jul 2022 07:42:56 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 74C223593BA9; Thu, 21 Jul 2022 07:42:50 -0700 (PDT) From: Dylan Yudaken To: , CC: , , Dylan Yudaken Subject: [PATCH liburing 2/4] Copy IORING_SETUP_SINGLE_ISSUER into io_uring.h Date: Thu, 21 Jul 2022 07:42:27 -0700 Message-ID: <20220721144229.1224141-3-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220721144229.1224141-1-dylany@fb.com> References: <20220721144229.1224141-1-dylany@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: PAHkGvztSOfyupAaKBckJxTfH2obTcS1 X-Proofpoint-ORIG-GUID: PAHkGvztSOfyupAaKBckJxTfH2obTcS1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_18,2022-07-20_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Copy from the 5.20 tree IORING_SETUP_SINGLE_ISSUER which is queued up. Signed-off-by: Dylan Yudaken --- src/include/liburing/io_uring.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h index 51126c4f6fd5..99e6963f3ff9 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h @@ -134,6 +134,10 @@ enum { #define IORING_SETUP_SQE128 (1U << 10) /* SQEs are 128 byte */ #define IORING_SETUP_CQE32 (1U << 11) /* CQEs are 32 byte */ +/* + * Only one task is allowed to submit requests + */ +#define IORING_SETUP_SINGLE_ISSUER (1U << 12) enum io_uring_op { IORING_OP_NOP, From patchwork Thu Jul 21 14:42:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12925303 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 1D014C433EF for ; Thu, 21 Jul 2022 14:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbiGUOnC (ORCPT ); Thu, 21 Jul 2022 10:43:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiGUOnA (ORCPT ); Thu, 21 Jul 2022 10:43:00 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 235B7868B8 for ; Thu, 21 Jul 2022 07:43:00 -0700 (PDT) Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26L3wqAI007214 for ; Thu, 21 Jul 2022 07:43:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=uiK6OhNPMvjRjGEU/SXekliH2h4VS+5BDnEE57w2G8w=; b=kNnw5T5KgYooMPjEkpRYXuRMLLjVytG4ZPR3ysZ8XQfDnDvlpic7DFMnw3gwEH0bPbE/ edKqS9mGUyDaLT+wJc4JOA8CdXiDVKozc9QoLaGbP4/5fiaJNyZ/d3zBIR+vM2L8uhW0 KnjFQKvWPixMCEboHpF8CHzYrpcQIvFOepk= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3heyc8ttdd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 21 Jul 2022 07:42:59 -0700 Received: from twshared25107.07.ash9.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 21 Jul 2022 07:42:58 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 7AD963593BAB; Thu, 21 Jul 2022 07:42:50 -0700 (PDT) From: Dylan Yudaken To: , CC: , , Dylan Yudaken Subject: [PATCH liburing 3/4] test: poll-mshot-overflow use proper return codes Date: Thu, 21 Jul 2022 07:42:28 -0700 Message-ID: <20220721144229.1224141-4-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220721144229.1224141-1-dylany@fb.com> References: <20220721144229.1224141-1-dylany@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: cHaTyhRGk__YyxXCwE3oQ2TP8KF5KHjY X-Proofpoint-ORIG-GUID: cHaTyhRGk__YyxXCwE3oQ2TP8KF5KHjY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_18,2022-07-20_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org This missed out on the refactor, so do it now in preparation for adding a skip path. Signed-off-by: Dylan Yudaken --- test/poll-mshot-overflow.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/test/poll-mshot-overflow.c b/test/poll-mshot-overflow.c index 078df04294fc..17039f585a77 100644 --- a/test/poll-mshot-overflow.c +++ b/test/poll-mshot-overflow.c @@ -10,6 +10,7 @@ #include #include "liburing.h" +#include "helpers.h" int check_final_cqe(struct io_uring *ring) { @@ -22,23 +23,23 @@ int check_final_cqe(struct io_uring *ring) count++; if (signalled_no_more) { fprintf(stderr, "signalled no more!\n"); - return 1; + return T_EXIT_FAIL; } if (!(cqe->flags & IORING_CQE_F_MORE)) signalled_no_more = true; } else if (cqe->user_data != 3) { fprintf(stderr, "%d: got unexpected %d\n", count, (int)cqe->user_data); - return 1; + return T_EXIT_FAIL; } io_uring_cqe_seen(ring, cqe); } if (!count) { fprintf(stderr, "no cqe\n"); - return 1; + return T_EXIT_FAIL; } - return 0; + return T_EXIT_PASS; } int main(int argc, char *argv[]) @@ -54,7 +55,7 @@ int main(int argc, char *argv[]) if (pipe(pipe1) != 0) { perror("pipe"); - return 1; + return T_EXIT_FAIL; } struct io_uring_params params = { @@ -65,20 +66,20 @@ int main(int argc, char *argv[]) ret = io_uring_queue_init_params(2, &ring, ¶ms); if (ret) { fprintf(stderr, "ring setup failed: %d\n", ret); - return 1; + return T_EXIT_FAIL; } sqe = io_uring_get_sqe(&ring); if (!sqe) { fprintf(stderr, "get sqe failed\n"); - return 1; + return T_EXIT_FAIL; } io_uring_prep_poll_multishot(sqe, pipe1[0], POLLIN); io_uring_sqe_set_data64(sqe, 1); if (io_uring_cq_ready(&ring)) { fprintf(stderr, "unexpected cqe\n"); - return 1; + return T_EXIT_FAIL; } for (i = 0; i < 2; i++) { @@ -95,18 +96,18 @@ int main(int argc, char *argv[]) if (ret <= 0) { fprintf(stderr, "write failed: %d\n", errno); - return 1; + return T_EXIT_FAIL; } /* should have 2 cqe + 1 overflow now, so take out two cqes */ for (i = 0; i < 2; i++) { if (io_uring_peek_cqe(&ring, &cqe)) { fprintf(stderr, "unexpectedly no cqe\n"); - return 1; + return T_EXIT_FAIL; } if (cqe->user_data != 2) { fprintf(stderr, "unexpected user_data\n"); - return 1; + return T_EXIT_FAIL; } io_uring_cqe_seen(&ring, cqe); } @@ -119,7 +120,7 @@ int main(int argc, char *argv[]) if (ret != 1) { fprintf(stderr, "bad poll remove\n"); - return 1; + return T_EXIT_FAIL; } ret = check_final_cqe(&ring); From patchwork Thu Jul 21 14:42:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12925304 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 5D74DC433EF for ; Thu, 21 Jul 2022 14:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbiGUOnI (ORCPT ); Thu, 21 Jul 2022 10:43:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiGUOnG (ORCPT ); Thu, 21 Jul 2022 10:43:06 -0400 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38FD386C06 for ; Thu, 21 Jul 2022 07:43:06 -0700 (PDT) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 26KNbDLA007622 for ; Thu, 21 Jul 2022 07:43:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=jHUAHgrEJ+nfgklTktgy3xNwfDMFkupd5aO5OfmBe78=; b=TniFPUrqSQs2U26rj3szl6KdXJ58UoU9Heq1Wp2fYV2p41uzdZLrcxJ0NQya4qw7Hiy4 JRPoF1MA1D0Xr8kG3452+UubOTXCBC/3X+uVZvhxR63zYdu/uBjmL+VexdJX99Mnn24u udnXI6k62VfoTtX936yAhJyI2yJ7O/DUkZw= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net (PPS) with ESMTPS id 3hek9pqex7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 21 Jul 2022 07:43:05 -0700 Received: from twshared39111.03.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 21 Jul 2022 07:43:04 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 8318D3593BAD; Thu, 21 Jul 2022 07:42:50 -0700 (PDT) From: Dylan Yudaken To: , CC: , , Dylan Yudaken , Ammar Faizi Subject: [PATCH liburing 4/4] skip poll-mshot-overflow on old kernels Date: Thu, 21 Jul 2022 07:42:29 -0700 Message-ID: <20220721144229.1224141-5-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220721144229.1224141-1-dylany@fb.com> References: <20220721144229.1224141-1-dylany@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: rIMu2JxUr8UDb4X8o2Y3fdzfgzkPwmZ- X-Proofpoint-ORIG-GUID: rIMu2JxUr8UDb4X8o2Y3fdzfgzkPwmZ- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_18,2022-07-20_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Older kernels have slightly different behaviour, so rather skip the test on them. Reported-by: Ammar Faizi Signed-off-by: Dylan Yudaken Tested-by: Ammar Faizi --- test/poll-mshot-overflow.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/poll-mshot-overflow.c b/test/poll-mshot-overflow.c index 17039f585a77..360df65d2b15 100644 --- a/test/poll-mshot-overflow.c +++ b/test/poll-mshot-overflow.c @@ -59,15 +59,16 @@ int main(int argc, char *argv[]) } struct io_uring_params params = { - .flags = IORING_SETUP_CQSIZE, + /* cheat using SINGLE_ISSUER existence to know if this behaviour + * is updated + */ + .flags = IORING_SETUP_CQSIZE | IORING_SETUP_SINGLE_ISSUER, .cq_entries = 2 }; ret = io_uring_queue_init_params(2, &ring, ¶ms); - if (ret) { - fprintf(stderr, "ring setup failed: %d\n", ret); - return T_EXIT_FAIL; - } + if (ret) + return T_EXIT_SKIP; sqe = io_uring_get_sqe(&ring); if (!sqe) {