netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Kuniyuki Iwashima <kuniyu@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Shakeel Butt <shakeel.butt@linux.dev>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Neal Cardwell <ncardwell@google.com>,
	Willem de Bruijn <willemb@google.com>,
	Mina Almasry <almasrymina@google.com>,
	Kuniyuki Iwashima <kuni1840@gmail.com>,
	bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v10 bpf-next/net 2/6] net-memcg: Allow decoupling memcg from global protocol memory accounting.
Date: Sat, 27 Sep 2025 07:49:45 -0700	[thread overview]
Message-ID: <f81fa440-4a89-4d80-9707-86db76141969@linux.dev> (raw)
In-Reply-To: <CAAVpQUDxSwjegw1UgieGOF+YGF=j2_FK=M1ZEKP1KGdtCdEBkw@mail.gmail.com>

On 9/25/25 3:40 PM, Kuniyuki Iwashima wrote:
> On Fri, Sep 19, 2025 at 10:25 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>>
>> On Sat, Sep 20, 2025 at 12:07:16AM +0000, Kuniyuki Iwashima wrote:
>>> Some protocols (e.g., TCP, UDP) implement memory accounting for socket
>>> buffers and charge memory to per-protocol global counters pointed to by
>>> sk->sk_proto->memory_allocated.
>>>
>>> If a socket has sk->sk_memcg, this memory is also charged to memcg as
>>> "sock" in memory.stat.
>>>
>>> We do not need to pay costs for two orthogonal memory accounting
>>> mechanisms.  A microbenchmark result is in the subsequent bpf patch.
>>>
>>> Let's decouple sockets under memcg from the global per-protocol memory
>>> accounting if mem_cgroup_sk_exclusive() returns true.
>>>
>>> Note that this does NOT disable memcg, but rather the per-protocol one.
>>>
>>> mem_cgroup_sk_exclusive() starts to return true in the following patches,
>>> and then, the per-protocol memory accounting will be skipped.
>>>
>>> In __inet_accept(), we need to reclaim counts that are already charged
>>> for child sockets because we do not allocate sk->sk_memcg until accept().
>>>
>>> trace_sock_exceed_buf_limit() will always show 0 as accounted for the
>>> memcg-exclusive sockets, but this can be obtained in memory.stat.
>>>
>>> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
>>> Nacked-by: Johannes Weiner <hannes@cmpxchg.org>

The patch cannot move on (i.e. land or respin) until the NACK concern is resolved.

>>
>> This looks good to me now, let's ask Johannes to take a look again and if
>> he still has any concerns.
>>
>> Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
> 
> Hi Johannes,
> 
> It would be really appreciated if you have a look again.
> 

Hi Johannes,

Can you take a look if the clarified reason in the commit message has addressed 
the concern ?

Thanks,
Martin

  reply	other threads:[~2025-09-27 14:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-20  0:07 [PATCH v10 bpf-next/net 0/6] bpf: Allow decoupling memcg from sk->sk_prot->memory_allocated Kuniyuki Iwashima
2025-09-20  0:07 ` [PATCH v10 bpf-next/net 1/6] tcp: Save lock_sock() for memcg in inet_csk_accept() Kuniyuki Iwashima
2025-09-20  0:07 ` [PATCH v10 bpf-next/net 2/6] net-memcg: Allow decoupling memcg from global protocol memory accounting Kuniyuki Iwashima
2025-09-20  5:25   ` Shakeel Butt
2025-09-25 22:40     ` Kuniyuki Iwashima
2025-09-27 14:49       ` Martin KaFai Lau [this message]
2025-09-20  0:07 ` [PATCH v10 bpf-next/net 3/6] net-memcg: Introduce net.core.memcg_exclusive sysctl Kuniyuki Iwashima
2025-09-20  5:35   ` Shakeel Butt
2025-09-20  6:22     ` Kuniyuki Iwashima
2025-09-23  0:54   ` Shakeel Butt
2025-09-23  1:03     ` Kuniyuki Iwashima
2025-09-23  1:26       ` Kuniyuki Iwashima
2025-09-25 22:52   ` Shakeel Butt
2025-09-20  0:07 ` [PATCH v10 bpf-next/net 4/6] bpf: Support bpf_setsockopt() for BPF_CGROUP_INET_SOCK_CREATE Kuniyuki Iwashima
2025-09-20  0:07 ` [PATCH v10 bpf-next/net 5/6] bpf: Introduce SK_BPF_MEMCG_FLAGS and SK_BPF_MEMCG_EXCLUSIVE Kuniyuki Iwashima
2025-09-20  0:07 ` [PATCH v10 bpf-next/net 6/6] selftest: bpf: Add test for SK_MEMCG_EXCLUSIVE Kuniyuki Iwashima

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=f81fa440-4a89-4d80-9707-86db76141969@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=almasrymina@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=kuniyu@google.com \
    --cc=mhocko@kernel.org \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=roman.gushchin@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=shakeel.butt@linux.dev \
    --cc=willemb@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).