netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@google.com>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	 John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	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 3/6] net-memcg: Introduce net.core.memcg_exclusive sysctl.
Date: Mon, 22 Sep 2025 18:26:33 -0700	[thread overview]
Message-ID: <CAAVpQUA+6BQhCt01AgEnST3=K46jbeRpPvYMrk_Fu8OhtHrP7A@mail.gmail.com> (raw)
In-Reply-To: <CAAVpQUBZSK6ptrRgruj0BGXBqDUOu3MKYKfD9FkWFn55OduwOw@mail.gmail.com>

On Mon, Sep 22, 2025 at 6:03 PM Kuniyuki Iwashima <kuniyu@google.com> wrote:
>
> On Mon, Sep 22, 2025 at 5:54 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
> > On Sat, Sep 20, 2025 at 12:07:17AM +0000, Kuniyuki Iwashima wrote:
> > > diff --git a/net/core/sock.c b/net/core/sock.c
> > > index 814966309b0e..348e599c3fbc 100644
> > > --- a/net/core/sock.c
> > > +++ b/net/core/sock.c
> > > @@ -2519,6 +2519,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
> > >  #ifdef CONFIG_MEMCG
> > >       /* sk->sk_memcg will be populated at accept() time */
> > >       newsk->sk_memcg = NULL;
> > > +     mem_cgroup_sk_set_flags(newsk, mem_cgroup_sk_get_flags(sk));
> >
> > Why do you need to set the flag here? Will doing in __inet_accept only
> > be too late i.e. protocol accounting would have happened?

Oh no, this is because I used newsk in __inet_accept(), and
we can use sock->sk in __inet_accept() and remove the inheritance
in sk_clone_lock() like this,

flags = mem_cgroup_sk_get_flags(sock->sk);

but I think using newsk reduces one cache miss.  Also, we touch the
parent sk_memcg during sock_copy() in sk_clone_lock().

  reply	other threads:[~2025-09-23  1:26 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
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 [this message]
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='CAAVpQUA+6BQhCt01AgEnST3=K46jbeRpPvYMrk_Fu8OhtHrP7A@mail.gmail.com' \
    --to=kuniyu@google.com \
    --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=martin.lau@linux.dev \
    --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).