All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] tcp: add tcp_tx_skb_cache_key checking in sk_stream_alloc_skb()
@ 2021-09-01 10:39 Yunsheng Lin
  2021-09-01 10:52   ` Paolo Abeni
  2021-09-02  0:47 ` Yunsheng Lin
  0 siblings, 2 replies; 18+ messages in thread
From: Yunsheng Lin @ 2021-09-01 10:39 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, linuxarm, edumazet, yoshfuji, dsahern

Since tcp_tx_skb_cache is disabled by default in:
commit 0b7d7f6b2208 ("tcp: add tcp_tx_skb_cache sysctl")

Add tcp_tx_skb_cache_key checking in sk_stream_alloc_skb() to
avoid possible branch-misses.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
---
Also, the sk->sk_tx_skb_cache may be both changed by allocation
and freeing side, I assume there may be some implicit protection
here too, such as the NAPI protection for rx?
---
 net/ipv4/tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e8b48df..226ddef 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -866,7 +866,7 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
 {
 	struct sk_buff *skb;
 
-	if (likely(!size)) {
+	if (static_branch_unlikely(&tcp_tx_skb_cache_key) && likely(!size)) {
 		skb = sk->sk_tx_skb_cache;
 		if (skb) {
 			skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-09-02  2:07 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 10:39 [PATCH net-next] tcp: add tcp_tx_skb_cache_key checking in sk_stream_alloc_skb() Yunsheng Lin
2021-09-01 10:52 ` Paolo Abeni
2021-09-01 10:52   ` Paolo Abeni
2021-09-01 15:06   ` Eric Dumazet
2021-09-01 15:06     ` Eric Dumazet
2021-09-01 15:16     ` Eric Dumazet
2021-09-01 15:16       ` Eric Dumazet
2021-09-01 15:25       ` Paolo Abeni
2021-09-01 15:25         ` Paolo Abeni
2021-09-01 15:29         ` Eric Dumazet
2021-09-01 15:29           ` Eric Dumazet
2021-09-01 16:01         ` Paolo Abeni
2021-09-01 16:01           ` Paolo Abeni
2021-09-01 16:02           ` Eric Dumazet
2021-09-01 16:02             ` Eric Dumazet
2021-09-02  0:47 ` Yunsheng Lin
2021-09-02  1:13   ` Eric Dumazet
2021-09-02  2:05     ` Yunsheng Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.