diff mbox series

[net] af_packet: do not call packet_read_pending() from tpacket_destruct_skb()

Message ID 20240515163358.4105915-1-edumazet@google.com (mailing list archive)
State Accepted
Commit 581073f626e387d3e7eed55c48c8495584ead7ba
Delegated to: Netdev Maintainers
Headers show
Series [net] af_packet: do not call packet_read_pending() from tpacket_destruct_skb() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 922 this patch: 922
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 925 this patch: 925
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 927 this patch: 927
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-17--00-00 (tests: 1034)

Commit Message

Eric Dumazet May 15, 2024, 4:33 p.m. UTC
trafgen performance considerably sank on hosts with many cores
after the blamed commit.

packet_read_pending() is very expensive, and calling it
in af_packet fast path defeats Daniel intent in commit
b013840810c2 ("packet: use percpu mmap tx frame pending refcount")

tpacket_destruct_skb() makes room for one packet, we can immediately
wakeup a producer, no need to completely drain the tx ring.

Fixes: 89ed5b519004 ("af_packet: Block execution of tasks waiting for transmit to complete in AF_PACKET")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
---
 net/packet/af_packet.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Willem de Bruijn May 15, 2024, 6:02 p.m. UTC | #1
Eric Dumazet wrote:
> trafgen performance considerably sank on hosts with many cores
> after the blamed commit.
> 
> packet_read_pending() is very expensive, and calling it
> in af_packet fast path defeats Daniel intent in commit
> b013840810c2 ("packet: use percpu mmap tx frame pending refcount")
> 
> tpacket_destruct_skb() makes room for one packet, we can immediately
> wakeup a producer, no need to completely drain the tx ring.
> 
> Fixes: 89ed5b519004 ("af_packet: Block execution of tasks waiting for transmit to complete in AF_PACKET")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>

Thanks!
patchwork-bot+netdevbpf@kernel.org May 17, 2024, 2:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 15 May 2024 16:33:58 +0000 you wrote:
> trafgen performance considerably sank on hosts with many cores
> after the blamed commit.
> 
> packet_read_pending() is very expensive, and calling it
> in af_packet fast path defeats Daniel intent in commit
> b013840810c2 ("packet: use percpu mmap tx frame pending refcount")
> 
> [...]

Here is the summary with links:
  - [net] af_packet: do not call packet_read_pending() from tpacket_destruct_skb()
    https://git.kernel.org/netdev/net/c/581073f626e3

You are awesome, thank you!
Daniel Borkmann May 21, 2024, 9:34 a.m. UTC | #3
On 5/15/24 6:33 PM, Eric Dumazet wrote:
> trafgen performance considerably sank on hosts with many cores
> after the blamed commit.
> 
> packet_read_pending() is very expensive, and calling it
> in af_packet fast path defeats Daniel intent in commit
> b013840810c2 ("packet: use percpu mmap tx frame pending refcount")
> 
> tpacket_destruct_skb() makes room for one packet, we can immediately
> wakeup a producer, no need to completely drain the tx ring.
> 
> Fixes: 89ed5b519004 ("af_packet: Block execution of tasks waiting for transmit to complete in AF_PACKET")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

Thanks Eric!
diff mbox series

Patch

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 8c6d3fbb4ed87f17c2e365810106a05fe9b8ff0c..ea3ebc160e25cc661901717a755f47db927c304d 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2522,8 +2522,7 @@  static void tpacket_destruct_skb(struct sk_buff *skb)
 		ts = __packet_set_timestamp(po, ph, skb);
 		__packet_set_status(po, ph, TP_STATUS_AVAILABLE | ts);
 
-		if (!packet_read_pending(&po->tx_ring))
-			complete(&po->skb_completion);
+		complete(&po->skb_completion);
 	}
 
 	sock_wfree(skb);