Skip to contentSkip to conversation

net: sock_dequeue_err_skb() optimization

PATCH Applied Eric Dumazet 2 participants 2 messages Oct 5, 2023 – Oct 7, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: sock_dequeue_err_skb() optimization

Exit early if the list is empty.

Some applications using TCP zerocopy are calling recvmsg( ... MSG_ERRQUEUE) and hit this case quite often, probably because busy polling only deals with sk_receive_queue.

---
 net/core/skbuff.c | 3 +++
 1 file changed, 3 insertions(+)
net/core/skbuff.c +3 -0
index da3f96bdd6f66cbea2f8e17513bff05a036a48ac..0401f40973a584ba4a89509b02510c8352bd6fb5 100644
@@ -5162,6 +5162,9 @@ struct sk_buff *sock_dequeue_err_skb(struct sock *sk)
 	bool icmp_next = false;
 	unsigned long flags;
 
+	if (skb_queue_empty_lockless(q))
+		return NULL;
+
 	spin_lock_irqsave(&q->lock, flags);
 	skb = __skb_dequeue(q);
 	if (skb && (skb_next = skb_peek(q))) {
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Thu, 5 Oct 2023 11:45:04 +0000 you wrote:

Exit early if the list is empty.

Some applications using TCP zerocopy are calling recvmsg( ... MSG_ERRQUEUE) and hit this case quite often, probably because busy polling only deals with sk_receive_queue.

[...]

Here is the summary with links:
- [net-next] net: sock_dequeue_err_skb() optimization

    https://git.kernel.org/netdev/net-next/c/48533eca606e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html