[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAVpQUDxSwjegw1UgieGOF+YGF=j2_FK=M1ZEKP1KGdtCdEBkw@mail.gmail.com>
Date: Thu, 25 Sep 2025 15:40:50 -0700
From: Kuniyuki Iwashima <kuniyu@...gle.com>
To: Johannes Weiner <hannes@...xchg.org>, Shakeel Butt <shakeel.butt@...ux.dev>
Cc: Alexei Starovoitov <ast@...nel.org>, Andrii Nakryiko <andrii@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Martin KaFai Lau <martin.lau@...ux.dev>,
John Fastabend <john.fastabend@...il.com>, Stanislav Fomichev <sdf@...ichev.me>,
Michal Hocko <mhocko@...nel.org>, Roman Gushchin <roman.gushchin@...ux.dev>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Neal Cardwell <ncardwell@...gle.com>, Willem de Bruijn <willemb@...gle.com>,
Mina Almasry <almasrymina@...gle.com>, Kuniyuki Iwashima <kuni1840@...il.com>, bpf@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [PATCH v10 bpf-next/net 2/6] net-memcg: Allow decoupling memcg
from global protocol memory accounting.
On Fri, Sep 19, 2025 at 10:25 PM Shakeel Butt <shakeel.butt@...ux.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@...gle.com>
> > Nacked-by: Johannes Weiner <hannes@...xchg.org>
>
> 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@...ux.dev>
Hi Johannes,
It would be really appreciated if you have a look again.
Thank you.
Powered by blists - more mailing lists