Skip to content

Commit

Permalink
af_packet: do not call packet_read_pending() from tpacket_destruct_skb()
Browse files Browse the repository at this point in the history
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
b013840 ("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: 89ed5b5 ("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>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20240515163358.4105915-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Eric Dumazet authored and kuba-moo committed May 17, 2024
1 parent fa033de commit 581073f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 581073f

Please sign in to comment.