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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 964D9C7EE2E for ; Thu, 18 May 2023 21:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbjERVSM (ORCPT ); Thu, 18 May 2023 17:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbjERVSM (ORCPT ); Thu, 18 May 2023 17:18:12 -0400 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62061E4D for ; Thu, 18 May 2023 14:18:11 -0700 (PDT) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id BAC415B1A664; Thu, 18 May 2023 14:17:56 -0700 (PDT) From: Stefan Roesch To: io-uring@vger.kernel.org, kernel-team@fb.com Cc: shr@devkernel.io, axboe@kernel.dk, ammarfaizi2@gnuweeb.org, netdev@vger.kernel.org, kuba@kernel.org, olivier@trillion01.com Subject: [PATCH v13 3/7] io-uring: move io_wait_queue definition to header file Date: Thu, 18 May 2023 14:17:47 -0700 Message-Id: <20230518211751.3492982-4-shr@devkernel.io> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230518211751.3492982-1-shr@devkernel.io> References: <20230518211751.3492982-1-shr@devkernel.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org This moves the definition of the io_wait_queue structure to the header file so it can be also used from other files. Signed-off-by: Stefan Roesch --- io_uring/io_uring.c | 21 --------------------- io_uring/io_uring.h | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 3d43df8f1e4e..efbd6c9c56e5 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2516,33 +2516,12 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsig= ned int nr) return ret; } =20 -struct io_wait_queue { - struct wait_queue_entry wq; - struct io_ring_ctx *ctx; - unsigned cq_tail; - unsigned nr_timeouts; - ktime_t timeout; -}; - static inline bool io_has_work(struct io_ring_ctx *ctx) { return test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq) || !llist_empty(&ctx->work_llist); } =20 -static inline bool io_should_wake(struct io_wait_queue *iowq) -{ - struct io_ring_ctx *ctx =3D iowq->ctx; - int dist =3D READ_ONCE(ctx->rings->cq.tail) - (int) iowq->cq_tail; - - /* - * Wake up if we have enough events, or if a timeout occurred since we - * started waiting. For timeouts, we always want to return to userspace= , - * regardless of event count. - */ - return dist >=3D 0 || atomic_read(&ctx->cq_timeouts) !=3D iowq->nr_time= outs; -} - static int io_wake_function(struct wait_queue_entry *curr, unsigned int = mode, int wake_flags, void *key) { diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index 259bf798a390..2fde89abd792 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -41,6 +41,28 @@ enum { IOU_STOP_MULTISHOT =3D -ECANCELED, }; =20 +struct io_wait_queue { + struct wait_queue_entry wq; + struct io_ring_ctx *ctx; + unsigned cq_tail; + unsigned nr_timeouts; + ktime_t timeout; + +}; + +static inline bool io_should_wake(struct io_wait_queue *iowq) +{ + struct io_ring_ctx *ctx =3D iowq->ctx; + int dist =3D READ_ONCE(ctx->rings->cq.tail) - (int) iowq->cq_tail; + + /* + * Wake up if we have enough events, or if a timeout occurred since we + * started waiting. For timeouts, we always want to return to userspace= , + * regardless of event count. + */ + return dist >=3D 0 || atomic_read(&ctx->cq_timeouts) !=3D iowq->nr_time= outs; +} + struct io_uring_cqe *__io_get_cqe(struct io_ring_ctx *ctx, bool overflow= ); bool io_req_cqe_overflow(struct io_kiocb *req); int io_run_task_work_sig(struct io_ring_ctx *ctx); --=20 2.39.1