Commit 88f15278 authored by Eric Dumazet's avatar Eric Dumazet Committed by Dong Chenchen
Browse files

af_packet: do not call packet_read_pending() from tpacket_destruct_skb()

stable inclusion
from stable-v4.19.316
commit 4f3ae7d846b4565c0b80d65ed607c3277bc984d4
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAMPH5

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4f3ae7d846b4565c0b80d65ed607c3277bc984d4



--------------------------------

[ Upstream commit 581073f626e387d3e7eed55c48c8495584ead7ba ]

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
b0138408 ("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: 89ed5b51 ("af_packet: Block execution of tasks waiting for transmit to complete in AF_PACKET")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20240515163358.4105915-1-edumazet@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarDong Chenchen <dongchenchen2@huawei.com>
parent 73a86ad6
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2437,7 +2437,6 @@ 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);
	}