From patchwork Thu Nov 24 08:00:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13054651 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 80038C43219 for ; Thu, 24 Nov 2022 08:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229570AbiKXIB3 (ORCPT ); Thu, 24 Nov 2022 03:01:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbiKXIB2 (ORCPT ); Thu, 24 Nov 2022 03:01:28 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38ED8C6234 for ; Thu, 24 Nov 2022 00:01:28 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.240]) by gnuweeb.org (Postfix) with ESMTPSA id 9BDE581712; Thu, 24 Nov 2022 08:01:24 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1669276888; bh=/UbXrvHQTICdm47XpD4CYl+mOolYdxyIGwcPMlD4uQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aWY3iAujm39Y04NEbU9X9BPAjqaQ9dQ0+EuS5d5UuXtO3ABggVI6SCJx7JuDFVp/j UDEKtjSqNeyle5uhNJXbj+6V+tbQYZcdvvE+BCxCF8K0HfJpsY1jnAq+0EktsgFACH +4TakGUpKlyfWshfo0Pf6r/E3D5ev0M7qrTCfQFWVOXFgWmBB571Nqp2OJd9UOr1P2 67WW2iuB39ta2vldR5HOHWiaBijx+WxqHg7faEfHCztlO4ZsL3Lhiy4u1QX6CV63Yr Z/zwpXYhfkPBNgvVfWPLFzkuWg8CIQfWF1S3x6PcMSeHY7taq7767U8xLYTW+12YpY murQWK/JNxsHw== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List , Gilang Fachrezy , Muhammad Rizki , Alviro Iskandar Setiawan , VNLX Kernel Department Subject: [PATCH liburing v1 1/7] liburing.h: Export `__io_uring_flush_sq()` function Date: Thu, 24 Nov 2022 15:00:56 +0700 Message-Id: <20221124075846.3784701-2-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221124075846.3784701-1-ammar.faizi@intel.com> References: <20221124075846.3784701-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi clang says: queue.c:204:10: error: no previous prototype for function \ '__io_uring_flush_sq' [-Werror,-Wmissing-prototypes] \ unsigned __io_uring_flush_sq(struct io_uring *ring) ^ queue.c:204:1: note: declare 'static' if the function is not intended \ to be used outside of this translation unit \ unsigned __io_uring_flush_sq(struct io_uring *ring) This function is used by test/iopoll.c, therefore, it can't be static. Export it. Signed-off-by: Ammar Faizi --- src/include/liburing.h | 1 + src/liburing.map | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/include/liburing.h b/src/include/liburing.h index 12a703f..c1d8edb 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -237,6 +237,7 @@ int io_uring_register_file_alloc_range(struct io_uring *ring, int io_uring_get_events(struct io_uring *ring); int io_uring_submit_and_get_events(struct io_uring *ring); +unsigned __io_uring_flush_sq(struct io_uring *ring); /* * io_uring syscalls. diff --git a/src/liburing.map b/src/liburing.map index 06c64f8..6b2f4b2 100644 --- a/src/liburing.map +++ b/src/liburing.map @@ -67,3 +67,8 @@ LIBURING_2.3 { io_uring_get_events; io_uring_submit_and_get_events; } LIBURING_2.2; + +LIBURING_2.4 { + global: + __io_uring_flush_sq; +} LIBURING_2.3; From patchwork Thu Nov 24 08:00:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13054652 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 45112C4332F for ; Thu, 24 Nov 2022 08:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229508AbiKXIBe (ORCPT ); Thu, 24 Nov 2022 03:01:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbiKXIBd (ORCPT ); Thu, 24 Nov 2022 03:01:33 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8F2C78FA for ; Thu, 24 Nov 2022 00:01:32 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.240]) by gnuweeb.org (Postfix) with ESMTPSA id 8B1C38166D; Thu, 24 Nov 2022 08:01:28 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1669276891; bh=Ov7T+cVML2fZWPau1xESLQDyLzqpY18IJ9L7HJxRzOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mZRYIAAY8L9Y59rUYByV3IydQoela8luIfbCXQuNtwC3gG0PSRI2VEA36q7zS8n2d tfcJUIUtU7DW3D3tfFWg/YDts2FR8fKzc1AHzUUmA0ADojhUwn87BW0I3A6m+FD9/O amV3RLGc2bgwzwnpo1KsNE8x8Q+cXSikTZE1lvsLoaoWENjM80ZiLG+XN2eSiXOD04 sK/Gxneyapm6ix7CPjfSRXATjesdRg0A1vHWLxjK3e3xI+eYzOcltRFVQg9KKpGvr/ FoCh8C7FBW3ZijQBuel12uq/Niwhq09QuSfo4ICfpEBfT5g0s5vY1ttqPsFRI3nTmi Qdpz25hc+BClg== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List , Gilang Fachrezy , Muhammad Rizki , Alviro Iskandar Setiawan , VNLX Kernel Department Subject: [PATCH liburing v1 2/7] test/io_uring_setup: Remove unused functions Date: Thu, 24 Nov 2022 15:00:57 +0700 Message-Id: <20221124075846.3784701-3-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221124075846.3784701-1-ammar.faizi@intel.com> References: <20221124075846.3784701-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi When marking all internal functions as static after an attempt to integrate `-Wmissing-prototypes` flag. Unused functions are found: io_uring_setup.c:22:14: error: unused function 'features_string' [-Werror,-Wunused-function] static char *features_string(struct io_uring_params *p) ^ io_uring_setup.c:44:14: error: unused function 'flags_string' [-Werror,-Wunused-function] static char *flags_string(struct io_uring_params *p) ^ io_uring_setup.c:83:15: error: unused function 'dump_resv' [-Werror,-Wunused-function] static char * dump_resv(struct io_uring_params *p) ^ 3 errors generated. make[1]: *** [Makefile:215: io_uring_setup.t] Error 1 make[1]: *** Waiting for unfinished jobs.... Remove them. Signed-off-by: Ammar Faizi --- test/io_uring_setup.c | 82 ++----------------------------------------- 1 file changed, 2 insertions(+), 80 deletions(-) diff --git a/test/io_uring_setup.c b/test/io_uring_setup.c index d945421..9e1a353 100644 --- a/test/io_uring_setup.c +++ b/test/io_uring_setup.c @@ -19,86 +19,9 @@ #include "../syscall.h" -char *features_string(struct io_uring_params *p) -{ - static char flagstr[64]; - - if (!p || !p->features) - return "none"; - - if (p->features & ~IORING_FEAT_SINGLE_MMAP) { - snprintf(flagstr, 64, "0x%.8x", p->features); - return flagstr; - } - - if (p->features & IORING_FEAT_SINGLE_MMAP) - strncat(flagstr, "IORING_FEAT_SINGLE_MMAP", 64 - strlen(flagstr)); - - return flagstr; -} - -/* - * Attempt the call with the given args. Return 0 when expect matches - * the return value of the system call, 1 otherwise. - */ -char * -flags_string(struct io_uring_params *p) -{ - static char flagstr[64]; - int add_pipe = 0; - - memset(flagstr, 0, sizeof(flagstr)); - - if (!p || p->flags == 0) - return "none"; - - /* - * If unsupported flags are present, just print the bitmask. - */ - if (p->flags & ~(IORING_SETUP_IOPOLL | IORING_SETUP_SQPOLL | - IORING_SETUP_SQ_AFF)) { - snprintf(flagstr, 64, "0x%.8x", p->flags); - return flagstr; - } - - if (p->flags & IORING_SETUP_IOPOLL) { - strncat(flagstr, "IORING_SETUP_IOPOLL", 64 - strlen(flagstr)); - add_pipe = 1; - } - if (p->flags & IORING_SETUP_SQPOLL) { - if (add_pipe) - strncat(flagstr, "|", 64 - strlen(flagstr)); - else - add_pipe = 1; - strncat(flagstr, "IORING_SETUP_SQPOLL", 64 - strlen(flagstr)); - } - if (p->flags & IORING_SETUP_SQ_AFF) { - if (add_pipe) - strncat(flagstr, "|", 64 - strlen(flagstr)); - strncat(flagstr, "IORING_SETUP_SQ_AFF", 64 - strlen(flagstr)); - } - - return flagstr; -} - -char * -dump_resv(struct io_uring_params *p) -{ - static char resvstr[4096]; - - if (!p) - return ""; - - sprintf(resvstr, "0x%.8x 0x%.8x 0x%.8x", p->resv[0], - p->resv[1], p->resv[2]); - - return resvstr; -} - /* bogus: setup returns a valid fd on success... expect can't predict the fd we'll get, so this really only takes 1 parameter: error */ -int -try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect) +int try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect) { int ret; @@ -123,8 +46,7 @@ try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect) return 0; } -int -main(int argc, char **argv) +int main(int argc, char **argv) { int fd; unsigned int status = 0; From patchwork Thu Nov 24 08:00:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13054653 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 C48F2C433FE for ; Thu, 24 Nov 2022 08:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbiKXIBj (ORCPT ); Thu, 24 Nov 2022 03:01:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbiKXIBh (ORCPT ); Thu, 24 Nov 2022 03:01:37 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18E0EC6611 for ; Thu, 24 Nov 2022 00:01:36 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.240]) by gnuweeb.org (Postfix) with ESMTPSA id 7B36281712; Thu, 24 Nov 2022 08:01:32 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1669276895; bh=IjiWigqeUBXqOFxVyLVTRYHaAHBjdEuLBkIGHoU0ZZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OAzT2XRY+uA87vqAircmkzHXM0BBsdDx3XVeoV5+gw4lzkHN9f1qTFwOrVnwubUr7 yKj20kQh+siy2yio9aHHAGopZ9VF1GGZSHMK+RnI3LK4SOTCGZVvOYjYy3kFtrqQJw PqRRIQMQVYaF+pqdGutl03orpGJ9tFBoGgr4cMBnVqUvTMXpaBJ/xjQIbLvVf/2M/v giBe1OptvwlKsirDCuGgKr+0LWjGKaPCsJg954eifD6E9fFLbzBxrnm5eOMuf5WfwK YAGsQtjAA1LMPqVy2vIEt5WNPN7nzDNCJsDgfgTDyHVo3EXF7yS+6+K6mbnR3KNfnY S6QLNsosFm0bA== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List , Gilang Fachrezy , Muhammad Rizki , Alviro Iskandar Setiawan , VNLX Kernel Department Subject: [PATCH liburing v1 3/7] ucontext-cp: Remove an unused function Date: Thu, 24 Nov 2022 15:00:58 +0700 Message-Id: <20221124075846.3784701-4-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221124075846.3784701-1-ammar.faizi@intel.com> References: <20221124075846.3784701-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi When marking all internal functions as static after an attempt to integrate `-Wmissing-prototypes` flag. An unused function is found: ucontext-cp.c:71:12: error: ‘await_poll’ defined but not used [-Werror=unused-function] 71 | static int await_poll(async_context *pctx, int fd, short poll_mask) | ^~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:36: ucontext-cp] Error 1 Remove it. Signed-off-by: Ammar Faizi --- examples/ucontext-cp.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/examples/ucontext-cp.c b/examples/ucontext-cp.c index 281013f..ed3b342 100644 --- a/examples/ucontext-cp.c +++ b/examples/ucontext-cp.c @@ -68,23 +68,8 @@ DEFINE_AWAIT_OP(readv) DEFINE_AWAIT_OP(writev) #undef DEFINE_AWAIT_OP -int await_poll(async_context *pctx, int fd, short poll_mask) { - struct io_uring_sqe *sqe = io_uring_get_sqe(pctx->ring); - struct io_uring_cqe *cqe; - if (!sqe) - return -1; - - io_uring_prep_poll_add(sqe, fd, poll_mask); - io_uring_sqe_set_data(sqe, pctx); - swapcontext(&pctx->ctx_fnew, &pctx->ctx_main); - io_uring_peek_cqe(pctx->ring, &cqe); - assert(cqe); - io_uring_cqe_seen(pctx->ring, cqe); - - return cqe->res; -} - -int await_delay(async_context *pctx, time_t seconds) { +int await_delay(async_context *pctx, time_t seconds) +{ struct io_uring_sqe *sqe = io_uring_get_sqe(pctx->ring); struct io_uring_cqe *cqe; struct __kernel_timespec ts = { From patchwork Thu Nov 24 08:00:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13054654 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 AFA30C4332F for ; Thu, 24 Nov 2022 08:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbiKXIBp (ORCPT ); Thu, 24 Nov 2022 03:01:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbiKXIBm (ORCPT ); Thu, 24 Nov 2022 03:01:42 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E44FC6611 for ; Thu, 24 Nov 2022 00:01:40 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.240]) by gnuweeb.org (Postfix) with ESMTPSA id 697CA816FF; Thu, 24 Nov 2022 08:01:36 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1669276900; bh=GLK5b6QqmdJIXrUcwe6xKwQBsQh+Nnqfkuk9rNRB2lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lgYU3ZFW8i7BRF6YGe0PscihakF62Z1EFlD+yFIA0BA6v5IDUu3Ti5xxEH1uzj+01 HTQEJTLIKwOV4mFCvjJiImS9/3DvjFLD75DQlBp2EKhkpanxSg8MwqNo++G42lPCY5 CT8oTV8mo42ftVHLMUka87xcgpo7ZMV2//WrFY37rLgbw+REr8mGrkplRsa3JYzBxE vVOu0AZmt2BBNQzAYuaS3V9utZ6dWKX3RgowO0ddLuPA0D/S8poWFyiBGsgrb2mYGW sLCTBJ4r7FmOSQ3AKkLvo03Pr0r41D7jdSEZjKazuW8+zT10FQAnde90Nb3EgxNzJd lqXsVLUzV6L1Q== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List , Gilang Fachrezy , Muhammad Rizki , Alviro Iskandar Setiawan , VNLX Kernel Department Subject: [PATCH liburing v1 4/7] tests: Mark internal functions as static Date: Thu, 24 Nov 2022 15:00:59 +0700 Message-Id: <20221124075846.3784701-5-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221124075846.3784701-1-ammar.faizi@intel.com> References: <20221124075846.3784701-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi Functions that are not used outside the translation unit should be static. Signed-off-by: Ammar Faizi --- test/accept-link.c | 2 +- test/accept-reuse.c | 9 ++++----- test/ce593a6c480a.c | 4 ++-- test/defer-taskrun.c | 2 +- test/exit-no-cleanup.c | 2 +- test/hardlink.c | 2 +- test/io_uring_setup.c | 3 ++- test/link_drain.c | 2 +- test/multicqes_drain.c | 27 ++++++++++++++++----------- test/nvme.h | 3 ++- test/poll-link.c | 2 +- test/poll-mshot-overflow.c | 2 +- test/read-before-exit.c | 2 +- test/ring-leak2.c | 2 +- test/sq-poll-kthread.c | 2 +- test/sqpoll-cancel-hang.c | 2 +- test/symlink.c | 3 ++- test/timeout-new.c | 12 ++++++++---- 18 files changed, 47 insertions(+), 36 deletions(-) diff --git a/test/accept-link.c b/test/accept-link.c index d0dc73b..4d42f15 100644 --- a/test/accept-link.c +++ b/test/accept-link.c @@ -77,7 +77,7 @@ static void *send_thread(void *arg) return NULL; } -void *recv_thread(void *arg) +static void *recv_thread(void *arg) { struct data *data = arg; struct io_uring ring; diff --git a/test/accept-reuse.c b/test/accept-reuse.c index 66eded2..7df5e56 100644 --- a/test/accept-reuse.c +++ b/test/accept-reuse.c @@ -13,15 +13,14 @@ struct io_uring io_uring; -int sys_io_uring_enter(const int fd, - const unsigned to_submit, - const unsigned min_complete, - const unsigned flags, sigset_t * const sig) +static int sys_io_uring_enter(const int fd, const unsigned to_submit, + const unsigned min_complete, + const unsigned flags, sigset_t * const sig) { return __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig); } -int submit_sqe(void) +static int submit_sqe(void) { struct io_uring_sq *sq = &io_uring.sq; const unsigned tail = *sq->ktail; diff --git a/test/ce593a6c480a.c b/test/ce593a6c480a.c index 4c71fbc..9fa74a9 100644 --- a/test/ce593a6c480a.c +++ b/test/ce593a6c480a.c @@ -15,7 +15,7 @@ static int use_sqpoll = 0; -void notify_fd(int fd) +static void notify_fd(int fd) { char buf[8] = {0, 0, 0, 0, 0, 0, 1}; int ret; @@ -25,7 +25,7 @@ void notify_fd(int fd) perror("write"); } -void *delay_set_fd_from_thread(void *data) +static void *delay_set_fd_from_thread(void *data) { int fd = (intptr_t) data; diff --git a/test/defer-taskrun.c b/test/defer-taskrun.c index 9283f28..624285e 100644 --- a/test/defer-taskrun.c +++ b/test/defer-taskrun.c @@ -119,7 +119,7 @@ struct thread_data { char buff[8]; }; -void *thread(void *t) +static void *thread(void *t) { struct thread_data *td = t; diff --git a/test/exit-no-cleanup.c b/test/exit-no-cleanup.c index 4b8574d..aadef8c 100644 --- a/test/exit-no-cleanup.c +++ b/test/exit-no-cleanup.c @@ -26,7 +26,7 @@ static pthread_barrier_t init_barrier; static int sleep_fd, notify_fd; static sem_t sem; -void *thread_func(void *arg) +static void *thread_func(void *arg) { struct io_uring ring; int res; diff --git a/test/hardlink.c b/test/hardlink.c index aeb9ac6..2b5140e 100644 --- a/test/hardlink.c +++ b/test/hardlink.c @@ -44,7 +44,7 @@ err: return 1; } -int files_linked_ok(const char* fn1, const char *fn2) +static int files_linked_ok(const char* fn1, const char *fn2) { struct stat s1, s2; diff --git a/test/io_uring_setup.c b/test/io_uring_setup.c index 9e1a353..2e95418 100644 --- a/test/io_uring_setup.c +++ b/test/io_uring_setup.c @@ -21,7 +21,8 @@ /* bogus: setup returns a valid fd on success... expect can't predict the fd we'll get, so this really only takes 1 parameter: error */ -int try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect) +static int try_io_uring_setup(unsigned entries, struct io_uring_params *p, + int expect) { int ret; diff --git a/test/link_drain.c b/test/link_drain.c index b95168d..1a50c10 100644 --- a/test/link_drain.c +++ b/test/link_drain.c @@ -96,7 +96,7 @@ err: return 1; } -int test_link_drain_multi(struct io_uring *ring) +static int test_link_drain_multi(struct io_uring *ring) { struct io_uring_cqe *cqe; struct io_uring_sqe *sqe[9]; diff --git a/test/multicqes_drain.c b/test/multicqes_drain.c index f95c438..3755bee 100644 --- a/test/multicqes_drain.c +++ b/test/multicqes_drain.c @@ -42,12 +42,16 @@ struct sqe_info { * up an entry in multi_sqes when form a cancellation sqe. * multi_cap: limitation of number of multishot sqes */ -const unsigned sqe_flags[4] = {0, IOSQE_IO_LINK, IOSQE_IO_DRAIN, - IOSQE_IO_LINK | IOSQE_IO_DRAIN}; -int multi_sqes[max_entry], cnt = 0; -int multi_cap = max_entry / 5; +static const unsigned sqe_flags[4] = { + 0, + IOSQE_IO_LINK, + IOSQE_IO_DRAIN, + IOSQE_IO_LINK | IOSQE_IO_DRAIN +}; +static int multi_sqes[max_entry], cnt = 0; +static int multi_cap = max_entry / 5; -int write_pipe(int pipe, char *str) +static int write_pipe(int pipe, char *str) { int ret; do { @@ -57,7 +61,7 @@ int write_pipe(int pipe, char *str) return ret; } -void read_pipe(int pipe) +static void read_pipe(int pipe) { char str[4] = {0}; int ret; @@ -67,7 +71,7 @@ void read_pipe(int pipe) perror("read"); } -int trigger_event(int p[]) +static int trigger_event(int p[]) { int ret; if ((ret = write_pipe(p[1], "foo")) != 3) { @@ -78,7 +82,8 @@ int trigger_event(int p[]) return 0; } -void io_uring_sqe_prep(int op, struct io_uring_sqe *sqe, unsigned sqe_flags, int arg) +static void io_uring_sqe_prep(int op, struct io_uring_sqe *sqe, + unsigned sqe_flags, int arg) { switch (op) { case multi: @@ -98,7 +103,7 @@ void io_uring_sqe_prep(int op, struct io_uring_sqe *sqe, unsigned sqe_flags, int sqe->flags = sqe_flags; } -__u8 generate_flags(int sqe_op) +static __u8 generate_flags(int sqe_op) { __u8 flags = 0; /* @@ -136,7 +141,7 @@ __u8 generate_flags(int sqe_op) * - ensure number of multishot sqes doesn't exceed multi_cap * - don't generate multishot sqes after high watermark */ -int generate_opcode(int i, int pre_flags) +static int generate_opcode(int i, int pre_flags) { int sqe_op; int high_watermark = max_entry - max_entry / 5; @@ -163,7 +168,7 @@ static inline void add_multishot_sqe(int index) multi_sqes[cnt++] = index; } -int remove_multishot_sqe() +static int remove_multishot_sqe(void) { int ret; diff --git a/test/nvme.h b/test/nvme.h index 14dc338..52f4172 100644 --- a/test/nvme.h +++ b/test/nvme.h @@ -120,7 +120,8 @@ static inline int ilog2(uint32_t i) return log; } -int nvme_get_info(const char *file) +__attribute__((__unused__)) +static int nvme_get_info(const char *file) { struct nvme_id_ns ns; int fd, err; diff --git a/test/poll-link.c b/test/poll-link.c index 39b48f5..b94f954 100644 --- a/test/poll-link.c +++ b/test/poll-link.c @@ -71,7 +71,7 @@ static void *send_thread(void *arg) return 0; } -void *recv_thread(void *arg) +static void *recv_thread(void *arg) { struct sockaddr_in addr = { }; struct data *data = arg; diff --git a/test/poll-mshot-overflow.c b/test/poll-mshot-overflow.c index 431a337..97d1cbe 100644 --- a/test/poll-mshot-overflow.c +++ b/test/poll-mshot-overflow.c @@ -12,7 +12,7 @@ #include "liburing.h" #include "helpers.h" -int check_final_cqe(struct io_uring *ring) +static int check_final_cqe(struct io_uring *ring) { struct io_uring_cqe *cqe; int count = 0; diff --git a/test/read-before-exit.c b/test/read-before-exit.c index be36bd4..d57cdd2 100644 --- a/test/read-before-exit.c +++ b/test/read-before-exit.c @@ -22,7 +22,7 @@ struct data { uint64_t buf2; }; -void *submit(void *data) +static void *submit(void *data) { struct io_uring_sqe *sqe; struct data *d = data; diff --git a/test/ring-leak2.c b/test/ring-leak2.c index a8c03fe..6e76717 100644 --- a/test/ring-leak2.c +++ b/test/ring-leak2.c @@ -46,7 +46,7 @@ static struct io_uring *client_ring; static int client_eventfd = -1; -int setup_io_uring(struct io_uring *ring) +static int setup_io_uring(struct io_uring *ring) { struct io_uring_params p = { }; int ret; diff --git a/test/sq-poll-kthread.c b/test/sq-poll-kthread.c index 3f4a07b..bf5122a 100644 --- a/test/sq-poll-kthread.c +++ b/test/sq-poll-kthread.c @@ -117,7 +117,7 @@ err_pipe: return ret; } -int test_sq_poll_kthread_stopped(bool do_exit) +static int test_sq_poll_kthread_stopped(bool do_exit) { pid_t pid; int status = 0; diff --git a/test/sqpoll-cancel-hang.c b/test/sqpoll-cancel-hang.c index ef62272..cd1c309 100644 --- a/test/sqpoll-cancel-hang.c +++ b/test/sqpoll-cancel-hang.c @@ -92,7 +92,7 @@ SIZEOF_IO_URING_CQE + 63) & ~63; } -void trigger_bug(void) +static void trigger_bug(void) { intptr_t res = 0; *(uint32_t*)0x20000204 = 0; diff --git a/test/symlink.c b/test/symlink.c index cf4aa96..7edb514 100644 --- a/test/symlink.c +++ b/test/symlink.c @@ -43,7 +43,8 @@ err: return 1; } -int test_link_contents(const char* linkname, const char *expected_contents) +static int test_link_contents(const char* linkname, + const char *expected_contents) { char buf[128]; int ret = readlink(linkname, buf, 127); diff --git a/test/timeout-new.c b/test/timeout-new.c index 6efcfb4..8640678 100644 --- a/test/timeout-new.c +++ b/test/timeout-new.c @@ -111,7 +111,8 @@ static int test_return_after_timeout(struct io_uring *ring) return 0; } -int __reap_thread_fn(void *data) { +static int __reap_thread_fn(void *data) +{ struct io_uring *ring = (struct io_uring *)data; struct io_uring_cqe *cqe; struct __kernel_timespec ts; @@ -123,12 +124,14 @@ int __reap_thread_fn(void *data) { return io_uring_wait_cqe_timeout(ring, &cqe, &ts); } -void *reap_thread_fn0(void *data) { +static void *reap_thread_fn0(void *data) +{ thread_ret0 = __reap_thread_fn(data); return NULL; } -void *reap_thread_fn1(void *data) { +static void *reap_thread_fn1(void *data) +{ thread_ret1 = __reap_thread_fn(data); return NULL; } @@ -137,7 +140,8 @@ void *reap_thread_fn1(void *data) { * This is to test issuing a sqe in main thread and reaping it in two child-thread * at the same time. To see if timeout feature works or not. */ -int test_multi_threads_timeout() { +static int test_multi_threads_timeout(void) +{ struct io_uring ring; int ret; bool both_wait = false; From patchwork Thu Nov 24 08:01:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13054655 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 ACCFAC433FE for ; Thu, 24 Nov 2022 08:01:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbiKXIBr (ORCPT ); Thu, 24 Nov 2022 03:01:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbiKXIBp (ORCPT ); Thu, 24 Nov 2022 03:01:45 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4858D1C30 for ; Thu, 24 Nov 2022 00:01:44 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.240]) by gnuweeb.org (Postfix) with ESMTPSA id D267381712; Thu, 24 Nov 2022 08:01:40 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1669276904; bh=PiYQQILwWUGqPy72iXWcKsCfm2nayS/FojzHuMN10q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IUyapkpegtof5aiJGNi+iOJZbsrxrC79AYGqPnlMZRPiEui7X/4ADXgdfm1Rcv7pl Di3iFVGCRDhJl1yfmC4EUPoxpQkYEtR0J9j+ITFqxaXrOWeIKJbCCFcnBnTZ2RbwpS uAHLkiJt+sruGyedbmGy4yicqaM3KEQP6jpJhGzDEdVzcsT/WTYI7v2Pa2BLsqOhcW RrMnk4y3HlxbSRiwXhvv4tcKKM5AOuRnO1pVR+JK8GsOQojCIGmNSfW4l7oi57yH3h QAA29Cf1FoIAdAtCSjeIWGaOfgh0TEY/1+zZHkWjZHwbrRc0ypxQ5s2XYl8Ze9iqYs oQT+prihRGKbw== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List , Gilang Fachrezy , Muhammad Rizki , Alviro Iskandar Setiawan , VNLX Kernel Department Subject: [PATCH liburing v1 5/7] ucontext-cp: Mark internal functions as static Date: Thu, 24 Nov 2022 15:01:00 +0700 Message-Id: <20221124075846.3784701-6-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221124075846.3784701-1-ammar.faizi@intel.com> References: <20221124075846.3784701-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi Functions that are not used outside the translation unit should be static. Signed-off-by: Ammar Faizi --- examples/ucontext-cp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ucontext-cp.c b/examples/ucontext-cp.c index ed3b342..d17aae7 100644 --- a/examples/ucontext-cp.c +++ b/examples/ucontext-cp.c @@ -68,7 +68,7 @@ DEFINE_AWAIT_OP(readv) DEFINE_AWAIT_OP(writev) #undef DEFINE_AWAIT_OP -int await_delay(async_context *pctx, time_t seconds) +static int await_delay(async_context *pctx, time_t seconds) { struct io_uring_sqe *sqe = io_uring_get_sqe(pctx->ring); struct io_uring_cqe *cqe; From patchwork Thu Nov 24 08:01:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13054656 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 6AF60C4332F for ; Thu, 24 Nov 2022 08:01:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229697AbiKXIBu (ORCPT ); Thu, 24 Nov 2022 03:01:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229717AbiKXIBt (ORCPT ); Thu, 24 Nov 2022 03:01:49 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED15C6611 for ; Thu, 24 Nov 2022 00:01:48 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.240]) by gnuweeb.org (Postfix) with ESMTPSA id D1B9C816FF; Thu, 24 Nov 2022 08:01:44 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1669276908; bh=I8+aPRh++xFhEmPVgD+jVUkqZVdfhhklZ90+OLkmncE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CJtpFAMrVlWU5FM4cAulJ8XV2htCkp/nyWEXhujh+DvzGNLZKileiMv+Aq2BtYSWw hi0dmE2sGO+ezgdxVT+0+qVj54KohYn4onpXMTD0t1cLjDOHjs+dnjzkphLCPYCW3O qlgNSLJHLIovPUSJCAMehNTm+UhNqQoUjHy7k0aBqxmmtpbzCRpFzIdhJ0EB13nQRJ qujP0267+ovIyuD1A2viX/LHlvoN/N4J+p2HXv2e8XATi/oL/n+OhH+TnP8uDfDHe1 ss8H7zbVlPU9bW2yCINwlwoQFZYOutxdt0zvfkCN9IBZaFvihvk9R7bShFr25xHwnw f9Jud+s1oghBQ== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List , Gilang Fachrezy , Muhammad Rizki , Alviro Iskandar Setiawan , VNLX Kernel Department Subject: [PATCH liburing v1 6/7] test/Makefile: Omit `-Wmissing-prototypes` from the C++ compiler flags Date: Thu, 24 Nov 2022 15:01:01 +0700 Message-Id: <20221124075846.3784701-7-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221124075846.3784701-1-ammar.faizi@intel.com> References: <20221124075846.3784701-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi This is a preparation patch to integrate -Wmissing-prototypes to the CI test robot. Clang++ is not happy with -Wmissing-prototypes: cc1plus: warning: command-line option '-Wmissing-prototypes' \ is valid for C/ObjC but not for C++ Omit this flag when we are compiling a C++ source file. Using -Wmissing-prototypes ensures we mark functions and variables as static if we don't use them outside the translation unit. Signed-off-by: Ammar Faizi --- test/Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 8ad9964..87b1fe1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -214,8 +214,17 @@ helpers.o: helpers.c %.t: %.c $(helpers) helpers.h ../src/liburing.a $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(helpers) $(LDFLAGS) +# +# Clang++ is not happy with -Wmissing-prototypes: +# +# cc1plus: warning: command-line option '-Wmissing-prototypes' \ +# is valid for C/ObjC but not for C++ +# %.t: %.cc $(helpers) helpers.h ../src/liburing.a - $(QUIET_CXX)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(helpers) $(LDFLAGS) + $(QUIET_CXX)$(CXX) \ + $(patsubst -Wmissing-prototypes,,$(CPPFLAGS)) \ + $(patsubst -Wmissing-prototypes,,$(CXXFLAGS)) \ + -o $@ $< $(helpers) $(LDFLAGS) install: $(test_targets) runtests.sh runtests-loop.sh From patchwork Thu Nov 24 08:01:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13054657 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 C3B44C433FE for ; Thu, 24 Nov 2022 08:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbiKXIBz (ORCPT ); Thu, 24 Nov 2022 03:01:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbiKXIBx (ORCPT ); Thu, 24 Nov 2022 03:01:53 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7144CC17E for ; Thu, 24 Nov 2022 00:01:52 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.240]) by gnuweeb.org (Postfix) with ESMTPSA id C4C3081352; Thu, 24 Nov 2022 08:01:48 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1669276912; bh=XmqNASuTOUfQYepVgge6guKR+RUrIm89rG2vy1bPaFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JDZhfJJv4qlvI9QyXxIKxjXgZIP63RVaE4tHZYt66LnAtO6CUQmagaNU2vHZo7jCv J2jY7VCln8slp683tAYHxnd4iITdgBmM2zwW2eryOKeYFj87YB0gzfyY08yCvMe7a1 5y7D6qG89OiSuHyRG167Yj7yDn8IB8ne8XcmEUBdFr9Ysiv3/XywSkibEq7I/Mh2kr fYtC0/76Tv5nhhqKItn/DTA1CW5mYTRsJSgjh2ZkcLEBP5dQNMp81DKk9zd60AD/x4 j5zFX9Pvcf25IHmI3UaioKgUvkwpdeTVa8FN33QK38rGL+9zKfT8LSguyhBcFMSDSb PPl/sQ70QwYrg== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List , Gilang Fachrezy , Muhammad Rizki , Alviro Iskandar Setiawan , VNLX Kernel Department Subject: [PATCH liburing v1 7/7] github: Add `-Wmissing-prototypes` for GitHub CI bot Date: Thu, 24 Nov 2022 15:01:02 +0700 Message-Id: <20221124075846.3784701-8-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221124075846.3784701-1-ammar.faizi@intel.com> References: <20221124075846.3784701-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi Using -Wmissing-prototypes ensures we mark functions and variables as static if we don't use them outside the translation unit. This enforcement is good because it hints the compiler to do escape analysis and optimization better. Signed-off-by: Ammar Faizi --- .github/workflows/build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0e669d..4c0bd26 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,8 @@ jobs: cxx_pkg: clang cc: clang cxx: clang++ - extra_flags: -Wshorten-64-to-32 + liburing_extra_flags: -Wshorten-64-to-32 + extra_flags: -Wmissing-prototypes # x86 (32-bit) gcc - arch: i686 @@ -85,10 +86,10 @@ jobs: cxx: mips-linux-gnu-g++ env: - FLAGS: -g -O3 -Wall -Wextra -Werror + FLAGS: -g -O3 -Wall -Wextra -Werror ${{matrix.extra_flags}} # Flags for building sources in src/ dir only. - LIBURING_CFLAGS: ${{matrix.extra_flags}} + LIBURING_CFLAGS: ${{matrix.liburing_extra_flags}} steps: - name: Checkout source