From patchwork Thu Jul 21 16:04:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12925513 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 80A76C43334 for ; Thu, 21 Jul 2022 16:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229526AbiGUQES (ORCPT ); Thu, 21 Jul 2022 12:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbiGUQES (ORCPT ); Thu, 21 Jul 2022 12:04:18 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF9D187C1C for ; Thu, 21 Jul 2022 09:04:17 -0700 (PDT) Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LEcmva013825 for ; Thu, 21 Jul 2022 09:04:17 -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=DtNpDi5UKqYByLOq/5oT4wZ1rIs/3pnf9Krv/bkZsy0=; b=TUd7FFDXTwOMeCF3SSTLlrpNT1YZmb7VLrPDi+cKlANy3OltG01aa4ZaxoZF5HB2K6VC ghspBZCilLg1Y9XgA9MGFzC0Hho7MblHQ188tZ61nru/GyZINriWcBsDDfBc5WWqsYzd 9seEO/Xqy+Gv+S5KB/ltLZ3Ls/mURBUurBE= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3hehn2rjka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 21 Jul 2022 09:04:17 -0700 Received: from twshared39111.03.ash8.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c085:11d::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 09:04:16 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id C4EB235A05DA; Thu, 21 Jul 2022 09:04:07 -0700 (PDT) From: Dylan Yudaken To: , CC: , , Dylan Yudaken Subject: [PATCH liburing 1/2] fixup poll-mshot-update Date: Thu, 21 Jul 2022 09:04:05 -0700 Message-ID: <20220721160406.1700508-2-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220721160406.1700508-1-dylany@fb.com> References: <20220721160406.1700508-1-dylany@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: _5Qlgbv7imunmtrSThcsBxTsGjQAwprq X-Proofpoint-ORIG-GUID: _5Qlgbv7imunmtrSThcsBxTsGjQAwprq 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_22,2022-07-20_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org this test did not notice when poll was cancelled. update it to notice, and rearm poll Signed-off-by: Dylan Yudaken --- test/poll-mshot-update.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c index caedb6fddc4b..e01befcfa7eb 100644 --- a/test/poll-mshot-update.c +++ b/test/poll-mshot-update.c @@ -75,6 +75,20 @@ static int arm_poll(struct io_uring *ring, int off) return 0; } +static int submit_arm_poll(struct io_uring *ring, int off) +{ + int ret; + + ret = arm_poll(ring, off); + if (ret) + return ret; + + ret = io_uring_submit(ring); + if (ret < 0) + return ret; + return ret == 1 ? 0 : -1; +} + static int reap_polls(struct io_uring *ring) { struct io_uring_cqe *cqe; @@ -106,6 +120,18 @@ static int reap_polls(struct io_uring *ring) off = cqe->user_data; if (off == 0x12345678) goto seen; + if (!(cqe->flags & IORING_CQE_F_MORE)) { + /* need to re-arm poll */ + ret = submit_arm_poll(ring, off); + if (ret) + break; + if (cqe->res <= 0) { + /* retry this one */ + i--; + goto seen; + } + } + ret = read(p[off].fd[0], &c, 1); if (ret != 1) { if (ret == -1 && errno == EAGAIN) From patchwork Thu Jul 21 16:04:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12925511 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 1DFE5C433EF for ; Thu, 21 Jul 2022 16:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229540AbiGUQEQ (ORCPT ); Thu, 21 Jul 2022 12:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbiGUQEP (ORCPT ); Thu, 21 Jul 2022 12:04:15 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10A5C58876 for ; Thu, 21 Jul 2022 09:04:14 -0700 (PDT) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LF1San005785 for ; Thu, 21 Jul 2022 09:04:14 -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=hB7hrsIwKUiiM+hcXpPwrwCuXz+erNPf3fgsJU38bOw=; b=PAvuCHdZRe8YnI0IT/m//ZSk5tBJ1BcqGnYgCSY/HuEqa9BpEFziQR7tLF6hVGghTOWm l/hrCyBeBsHUHyyc2ZkdfXY1G9dcTNOLxFsFBzCk6kI4ZP/X3hZ3Lu17Mam35LlPLM8j Ds9qc9prVbZUdw4kYFI0Z/Of/Yd9VYNMJW8= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3hes8vd6jx-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 21 Jul 2022 09:04:14 -0700 Received: from twshared7556.02.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::e) 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 09:04:12 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id DF48735A05E2; Thu, 21 Jul 2022 09:04:08 -0700 (PDT) From: Dylan Yudaken To: , CC: , , Dylan Yudaken Subject: [PATCH liburing 2/2] test: have poll-mshot-update run with both big and small cqe Date: Thu, 21 Jul 2022 09:04:06 -0700 Message-ID: <20220721160406.1700508-3-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220721160406.1700508-1-dylany@fb.com> References: <20220721160406.1700508-1-dylany@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: j7j0rR3eJkJygzUdeHVx72QwOIcPa9-r X-Proofpoint-ORIG-GUID: j7j0rR3eJkJygzUdeHVx72QwOIcPa9-r 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_22,2022-07-20_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Run the test twice, with and without overflow to make sure more codepaths are tested. Signed-off-by: Dylan Yudaken --- test/poll-mshot-update.c | 90 +++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c index e01befcfa7eb..eeb725437cc8 100644 --- a/test/poll-mshot-update.c +++ b/test/poll-mshot-update.c @@ -213,52 +213,23 @@ static int arm_polls(struct io_uring *ring) return 0; } -int main(int argc, char *argv[]) +static int run(int cqe) { struct io_uring ring; struct io_uring_params params = { }; - struct rlimit rlim; pthread_t thread; int i, j, ret; - if (argc > 1) - return 0; - - ret = has_poll_update(); - if (ret < 0) { - fprintf(stderr, "poll update check failed %i\n", ret); - return -1; - } else if (!ret) { - fprintf(stderr, "no poll update, skip\n"); - return 0; - } - - if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) { - perror("getrlimit"); - goto err_noring; - } - - if (rlim.rlim_cur < (2 * NFILES + 5)) { - rlim.rlim_cur = (2 * NFILES + 5); - rlim.rlim_max = rlim.rlim_cur; - if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) { - if (errno == EPERM) - goto err_nofail; - perror("setrlimit"); - goto err_noring; - } - } - for (i = 0; i < NFILES; i++) { if (pipe(p[i].fd) < 0) { perror("pipe"); - goto err_noring; + return 1; } fcntl(p[i].fd[0], F_SETFL, O_NONBLOCK); } params.flags = IORING_SETUP_CQSIZE; - params.cq_entries = 4096; + params.cq_entries = cqe; ret = io_uring_queue_init_params(RING_SIZE, &ring, ¶ms); if (ret) { if (ret == -EINVAL) { @@ -286,10 +257,63 @@ int main(int argc, char *argv[]) } io_uring_queue_exit(&ring); + for (i = 0; i < NFILES; i++) { + close(p[i].fd[0]); + close(p[i].fd[1]); + } return 0; err: io_uring_queue_exit(&ring); -err_noring: + return 1; +} + +int main(int argc, char *argv[]) +{ + struct rlimit rlim; + int ret; + + if (argc > 1) + return 0; + + ret = has_poll_update(); + if (ret < 0) { + fprintf(stderr, "poll update check failed %i\n", ret); + return -1; + } else if (!ret) { + fprintf(stderr, "no poll update, skip\n"); + return 0; + } + + if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) { + perror("getrlimit"); + goto err; + } + + if (rlim.rlim_cur < (2 * NFILES + 5)) { + rlim.rlim_cur = (2 * NFILES + 5); + rlim.rlim_max = rlim.rlim_cur; + if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) { + if (errno == EPERM) + goto err_nofail; + perror("setrlimit"); + goto err; + } + } + + ret = run(1024); + if (ret) { + fprintf(stderr, "run(1024) failed\n"); + goto err; + } + + ret = run(8192); + if (ret) { + fprintf(stderr, "run(8192) failed\n"); + goto err; + } + + return 0; +err: fprintf(stderr, "poll-many failed\n"); return 1; err_nofail: