netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev <netdev@vger.kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: [PATCH net-next 4/4] net: call skb_defer_free_flush() before each napi_poll()
Date: Sun, 15 May 2022 21:24:56 -0700	[thread overview]
Message-ID: <20220516042456.3014395-5-eric.dumazet@gmail.com> (raw)
In-Reply-To: <20220516042456.3014395-1-eric.dumazet@gmail.com>

From: Eric Dumazet <edumazet@google.com>

skb_defer_free_flush() can consume cpu cycles,
it seems better to call it in the inner loop:

- Potentially frees page/skb that will be reallocated while hot.

- Account for the cpu cycles in the @time_limit determination.

- Keep softnet_data.defer_count small to reduce chances for
  skb_attempt_defer_free() to send an IPI.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/dev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index ac22fedfeaf72dc0d46f4793bbd9b2d5dd301730..aabb695e25f35402bbc85602e1bb9c86d2fa209e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6654,6 +6654,8 @@ static __latent_entropy void net_rx_action(struct softirq_action *h)
 	for (;;) {
 		struct napi_struct *n;
 
+		skb_defer_free_flush(sd);
+
 		if (list_empty(&list)) {
 			if (!sd_has_rps_ipi_waiting(sd) && list_empty(&repoll))
 				goto end;
@@ -6683,8 +6685,7 @@ static __latent_entropy void net_rx_action(struct softirq_action *h)
 		__raise_softirq_irqoff(NET_RX_SOFTIRQ);
 
 	net_rps_action_and_irq_enable(sd);
-end:
-	skb_defer_free_flush(sd);
+end:;
 }
 
 struct netdev_adjacent {
-- 
2.36.0.550.gb090851708-goog


  parent reply	other threads:[~2022-05-16  4:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16  4:24 [PATCH net-next 0/4] net: polish skb defer freeing Eric Dumazet
2022-05-16  4:24 ` [PATCH net-next 1/4] net: fix possible race in skb_attempt_defer_free() Eric Dumazet
2022-05-16 18:15   ` Jakub Kicinski
2022-05-16 18:24     ` Eric Dumazet
2022-05-16 18:54       ` Jakub Kicinski
2022-05-16  4:24 ` [PATCH net-next 2/4] net: use napi_consume_skb() in skb_defer_free_flush() Eric Dumazet
2022-05-16  4:24 ` [PATCH net-next 3/4] net: add skb_defer_max sysctl Eric Dumazet
2022-05-16 20:39   ` Jakub Kicinski
2022-05-16 20:43     ` Eric Dumazet
2022-05-16  4:24 ` Eric Dumazet [this message]
2022-05-16 18:21   ` [PATCH net-next 4/4] net: call skb_defer_free_flush() before each napi_poll() Jakub Kicinski
2022-05-16 18:26     ` Eric Dumazet
2022-05-16 18:56       ` Jakub Kicinski
2022-05-16 10:40 ` [PATCH net-next 0/4] net: polish skb defer freeing patchwork-bot+netdevbpf

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=20220516042456.3014395-5-eric.dumazet@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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).