All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yunsheng Lin <linyunsheng@huawei.com>
To: Eric Dumazet <edumazet@google.com>
Cc: David Miller <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, netdev <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, <linuxarm@openeuler.org>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	"David Ahern" <dsahern@kernel.org>
Subject: Re: [PATCH net-next] tcp: add tcp_tx_skb_cache_key checking in sk_stream_alloc_skb()
Date: Thu, 2 Sep 2021 10:05:57 +0800	[thread overview]
Message-ID: <b4c6f14a-31dc-f1e1-3669-5b6721a4c87d@huawei.com> (raw)
In-Reply-To: <CANn89i+X_K2A1kepmLh1ySC_UE=+ov=Cya2mtW7R0LT68kyb2w@mail.gmail.com>

On 2021/9/2 9:13, Eric Dumazet wrote:
> On Wed, Sep 1, 2021 at 5:47 PM Yunsheng Lin <linyunsheng@huawei.com> wrote:
>>
>> On 2021/9/1 18:39, Yunsheng Lin wrote:
>>> 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?
>>
>> Hi, Eric
>>    Is there any implicit protection for sk->sk_tx_skb_cache?
>> As my understanding, sk_stream_alloc_skb() seems to be protected
>> by lock_sock(), and the sk_wmem_free_skb() seems to be mostly
>> happening in NAPI polling for TCP(when ack packet is received)
>> without lock_sock(), so it seems there is no protection here?
>>
> 
> Please look again.
> This is protected by socket lock of course.
> Otherwise sk_mem_uncharge() would be very broken, sk->sk_forward_alloc
> is not an atomic field.

Thanks for clarifying.
I have been looking for a point to implement the socket'pp_alloc_cache for
page pool, and sk_wmem_free_skb() seems like the place to avoid the
scalablity problem of ptr_ring in page pool.

The protection for sk_wmem_free_skb() is in tcp_v4_rcv(), right?
https://elixir.bootlin.com/linux/latest/source/net/ipv4/tcp_ipv4.c#L2081

> 
> TCP stack has no direct relation  with NAPI.
> It can run over loopback interface, no NAPI there.
> .
> 

      reply	other threads:[~2021-09-02  2:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4c6f14a-31dc-f1e1-3669-5b6721a4c87d@huawei.com \
    --to=linyunsheng@huawei.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@openeuler.org \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.