From patchwork Fri Sep 16 01:59:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Gongyi X-Patchwork-Id: 1678461 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MTHRb6Bc5z1ynm for ; Fri, 16 Sep 2022 12:03:39 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 11ED23CA493 for ; Fri, 16 Sep 2022 04:03:37 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 9681C3CA493 for ; Fri, 16 Sep 2022 04:03:34 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 6801F1A011D6 for ; Fri, 16 Sep 2022 04:03:32 +0200 (CEST) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MTHL31KybzNm57 for ; Fri, 16 Sep 2022 09:58:51 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.63) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 16 Sep 2022 10:03:28 +0800 To: Date: Fri, 16 Sep 2022 09:59:48 +0800 Message-ID: <20220916015948.156798-1-zhaogongyi@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.63] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500005.china.huawei.com (7.192.104.229) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH] lapi/io_uring.h: Optimization io_uring_setup_supported_by_kernel() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Zhao Gongyi via ltp From: Zhao Gongyi Reply-To: Zhao Gongyi Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Optimization function io_uring_setup_supported_by_kernel() when CONFIG_IO_URING is not set. Signed-off-by: Zhao Gongyi --- include/lapi/io_uring.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/include/lapi/io_uring.h b/include/lapi/io_uring.h index 397324511..24e57b069 100644 --- a/include/lapi/io_uring.h +++ b/include/lapi/io_uring.h @@ -297,13 +297,18 @@ static inline int io_uring_enter(int fd, unsigned int to_submit, static inline void io_uring_setup_supported_by_kernel(void) { long ret; - if ((tst_kvercmp(5, 1, 0)) < 0) { - ret = syscall(__NR_io_uring_setup, NULL, 0); - if (ret != -1) - SAFE_CLOSE(ret); - else if (errno == ENOSYS) + ret = syscall(__NR_io_uring_setup, NULL, 0); + if (ret != -1) { + SAFE_CLOSE(ret); + return + } + + if (errno == ENOSYS) { + if ((tst_kvercmp(5, 1, 0)) < 0) { tst_brk(TCONF, "Test not supported on kernel version < v5.1"); + } + tst_brk(TCONF, "CONFIG_IO_URING not set?"); } }