netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Roesch <shr@devkernel.io>
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 v15 1/7] net: split off __napi_busy_poll from napi_busy_poll
Date: Thu,  8 Jun 2023 09:38:33 -0700	[thread overview]
Message-ID: <20230608163839.2891748-2-shr@devkernel.io> (raw)
In-Reply-To: <20230608163839.2891748-1-shr@devkernel.io>

This splits off the key part of the napi_busy_poll function into its own
function __napi_busy_poll. The new function has an additional rcu
parameter. This new parameter can be used when the caller is already
holding the rcu read lock.

This is done in preparation for an additional napi_busy_poll() function,
that doesn't take the rcu_read_lock(). The new function is introduced
in the next patch.

Signed-off-by: Stefan Roesch <shr@devkernel.io>
---
 net/core/dev.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index b3c13e041935..ae90265f4020 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6179,9 +6179,10 @@ static void busy_poll_stop(struct napi_struct *napi, void *have_poll_lock, bool
 	local_bh_enable();
 }
 
-void napi_busy_loop(unsigned int napi_id,
-		    bool (*loop_end)(void *, unsigned long),
-		    void *loop_end_arg, bool prefer_busy_poll, u16 budget)
+void __napi_busy_loop(unsigned int napi_id,
+		      bool (*loop_end)(void *, unsigned long),
+		      void *loop_end_arg, bool prefer_busy_poll, u16 budget,
+		      bool rcu)
 {
 	unsigned long start_time = loop_end ? busy_loop_current_time() : 0;
 	int (*napi_poll)(struct napi_struct *napi, int budget);
@@ -6191,7 +6192,8 @@ void napi_busy_loop(unsigned int napi_id,
 restart:
 	napi_poll = NULL;
 
-	rcu_read_lock();
+	if (!rcu)
+		rcu_read_lock();
 
 	napi = napi_by_id(napi_id);
 	if (!napi)
@@ -6237,6 +6239,8 @@ void napi_busy_loop(unsigned int napi_id,
 			break;
 
 		if (unlikely(need_resched())) {
+			if (rcu)
+				break;
 			if (napi_poll)
 				busy_poll_stop(napi, have_poll_lock, prefer_busy_poll, budget);
 			preempt_enable();
@@ -6252,7 +6256,16 @@ void napi_busy_loop(unsigned int napi_id,
 		busy_poll_stop(napi, have_poll_lock, prefer_busy_poll, budget);
 	preempt_enable();
 out:
-	rcu_read_unlock();
+	if (!rcu)
+		rcu_read_unlock();
+}
+
+void napi_busy_loop(unsigned int napi_id,
+		    bool (*loop_end)(void *, unsigned long),
+		    void *loop_end_arg, bool prefer_busy_poll, u16 budget)
+{
+	__napi_busy_loop(napi_id, loop_end, loop_end_arg, prefer_busy_poll,
+			 budget, false);
 }
 EXPORT_SYMBOL(napi_busy_loop);
 
-- 
2.39.1


  reply	other threads:[~2023-06-08 16:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08 16:38 [PATCH v15 0/7] io_uring: add napi busy polling support Stefan Roesch
2023-06-08 16:38 ` Stefan Roesch [this message]
2023-06-08 19:33   ` [PATCH v15 1/7] net: split off __napi_busy_poll from napi_busy_poll kernel test robot
2023-06-08 16:38 ` [PATCH v15 2/7] net: add napi_busy_loop_rcu() Stefan Roesch
2023-06-08 16:38 ` [PATCH v15 3/7] io-uring: move io_wait_queue definition to header file Stefan Roesch
2023-06-08 16:38 ` [PATCH v15 4/7] io-uring: add napi busy poll support Stefan Roesch
2023-06-08 16:38 ` [PATCH v15 5/7] io-uring: add sqpoll support for napi busy poll Stefan Roesch
2023-06-08 16:38 ` [PATCH v15 6/7] io_uring: add register/unregister napi function Stefan Roesch
2023-06-08 16:38 ` [PATCH v15 7/7] io_uring: add prefer busy poll to register and unregister napi api Stefan Roesch
2024-01-30 21:20 ` [PATCH v15 0/7] io_uring: add napi busy polling support Olivier Langlois
2024-01-30 22:59   ` Jens Axboe
2024-01-31  5:30     ` Olivier Langlois
2024-01-31 17:22     ` Olivier Langlois
2024-01-31 17:32       ` Jens Axboe
2024-01-31 17:59         ` Olivier Langlois
2024-01-31 19:56           ` Olivier Langlois
2024-01-31 20:52             ` Jens Axboe
2024-01-31 21:03               ` Olivier Langlois
2024-02-02 20:20               ` Olivier Langlois
2024-02-02 22:58                 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230608163839.2891748-2-shr@devkernel.io \
    --to=shr@devkernel.io \
    --cc=ammarfaizi2@gnuweeb.org \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=kernel-team@fb.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olivier@trillion01.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).