* [PATCH net-next] net: call skb_defer_free_flush() from __napi_busy_loop()
@ 2024-02-27 21:01 Eric Dumazet
2024-02-27 21:07 ` Stanislav Fomichev
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2024-02-27 21:01 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, eric.dumazet, Eric Dumazet, Samiullah Khawaja,
Stanislav Fomichev
skb_defer_free_flush() is currently called from net_rx_action()
and napi_threaded_poll().
We should also call it from __napi_busy_loop() otherwise
there is the risk the percpu queue can grow until an IPI
is forced from skb_attempt_defer_free() adding a latency spike.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Stanislav Fomichev <sdf@google.com>
---
net/core/dev.c | 43 ++++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 275fd5259a4a92d0bd2e145d66a716248b6c2804..053fac78305c7322b894ceb07a925f7e64ed70aa 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6173,6 +6173,27 @@ struct napi_struct *napi_by_id(unsigned int napi_id)
return NULL;
}
+static void skb_defer_free_flush(struct softnet_data *sd)
+{
+ struct sk_buff *skb, *next;
+
+ /* Paired with WRITE_ONCE() in skb_attempt_defer_free() */
+ if (!READ_ONCE(sd->defer_list))
+ return;
+
+ spin_lock(&sd->defer_lock);
+ skb = sd->defer_list;
+ sd->defer_list = NULL;
+ sd->defer_count = 0;
+ spin_unlock(&sd->defer_lock);
+
+ while (skb != NULL) {
+ next = skb->next;
+ napi_consume_skb(skb, 1);
+ skb = next;
+ }
+}
+
#if defined(CONFIG_NET_RX_BUSY_POLL)
static void __busy_poll_stop(struct napi_struct *napi, bool skip_schedule)
@@ -6297,6 +6318,7 @@ static void __napi_busy_loop(unsigned int napi_id,
if (work > 0)
__NET_ADD_STATS(dev_net(napi->dev),
LINUX_MIB_BUSYPOLLRXPACKETS, work);
+ skb_defer_free_flush(this_cpu_ptr(&softnet_data));
local_bh_enable();
if (!loop_end || loop_end(loop_end_arg, start_time))
@@ -6726,27 +6748,6 @@ static int napi_thread_wait(struct napi_struct *napi)
return -1;
}
-static void skb_defer_free_flush(struct softnet_data *sd)
-{
- struct sk_buff *skb, *next;
-
- /* Paired with WRITE_ONCE() in skb_attempt_defer_free() */
- if (!READ_ONCE(sd->defer_list))
- return;
-
- spin_lock(&sd->defer_lock);
- skb = sd->defer_list;
- sd->defer_list = NULL;
- sd->defer_count = 0;
- spin_unlock(&sd->defer_lock);
-
- while (skb != NULL) {
- next = skb->next;
- napi_consume_skb(skb, 1);
- skb = next;
- }
-}
-
static int napi_threaded_poll(void *data)
{
struct napi_struct *napi = data;
--
2.44.0.rc1.240.g4c46232300-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: call skb_defer_free_flush() from __napi_busy_loop()
2024-02-27 21:01 [PATCH net-next] net: call skb_defer_free_flush() from __napi_busy_loop() Eric Dumazet
@ 2024-02-27 21:07 ` Stanislav Fomichev
2024-02-28 11:08 ` Jiri Pirko
2024-02-29 4:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Stanislav Fomichev @ 2024-02-27 21:07 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, netdev,
eric.dumazet, Samiullah Khawaja
On 02/27, Eric Dumazet wrote:
> skb_defer_free_flush() is currently called from net_rx_action()
> and napi_threaded_poll().
>
> We should also call it from __napi_busy_loop() otherwise
> there is the risk the percpu queue can grow until an IPI
> is forced from skb_attempt_defer_free() adding a latency spike.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Samiullah Khawaja <skhawaja@google.com>
> Cc: Stanislav Fomichev <sdf@google.com>
Acked-by: Stanislav Fomichev <sdf@google.com>
Thank you!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: call skb_defer_free_flush() from __napi_busy_loop()
2024-02-27 21:01 [PATCH net-next] net: call skb_defer_free_flush() from __napi_busy_loop() Eric Dumazet
2024-02-27 21:07 ` Stanislav Fomichev
@ 2024-02-28 11:08 ` Jiri Pirko
2024-02-29 4:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2024-02-28 11:08 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, netdev,
eric.dumazet, Samiullah Khawaja, Stanislav Fomichev
Tue, Feb 27, 2024 at 10:01:04PM CET, edumazet@google.com wrote:
>skb_defer_free_flush() is currently called from net_rx_action()
>and napi_threaded_poll().
>
>We should also call it from __napi_busy_loop() otherwise
>there is the risk the percpu queue can grow until an IPI
>is forced from skb_attempt_defer_free() adding a latency spike.
>
>Signed-off-by: Eric Dumazet <edumazet@google.com>
>Cc: Samiullah Khawaja <skhawaja@google.com>
>Cc: Stanislav Fomichev <sdf@google.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: call skb_defer_free_flush() from __napi_busy_loop()
2024-02-27 21:01 [PATCH net-next] net: call skb_defer_free_flush() from __napi_busy_loop() Eric Dumazet
2024-02-27 21:07 ` Stanislav Fomichev
2024-02-28 11:08 ` Jiri Pirko
@ 2024-02-29 4:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-29 4:40 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, pabeni, netdev, eric.dumazet, skhawaja, sdf
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 27 Feb 2024 21:01:04 +0000 you wrote:
> skb_defer_free_flush() is currently called from net_rx_action()
> and napi_threaded_poll().
>
> We should also call it from __napi_busy_loop() otherwise
> there is the risk the percpu queue can grow until an IPI
> is forced from skb_attempt_defer_free() adding a latency spike.
>
> [...]
Here is the summary with links:
- [net-next] net: call skb_defer_free_flush() from __napi_busy_loop()
https://git.kernel.org/netdev/net-next/c/1200097fa8f0
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-29 4:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 21:01 [PATCH net-next] net: call skb_defer_free_flush() from __napi_busy_loop() Eric Dumazet
2024-02-27 21:07 ` Stanislav Fomichev
2024-02-28 11:08 ` Jiri Pirko
2024-02-29 4:40 ` patchwork-bot+netdevbpf
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).