Hello.
On Tue, Aug 12, 2025 at 05:58:19PM +0000, Kuniyuki Iwashima [off-list ref] wrote:
When sk_alloc() allocates a socket, mem_cgroup_sk_alloc() sets
sk->sk_memcg based on the current task.
MPTCP subflow socket creation is triggered from userspace or
an in-kernel worker.
I somewhat remembered
d752a4986532c ("net: memcg: late association of sock to memcg")
but IIUC this MPTCP codepath, the socket would never be visible to
userspace nor manipulated from a proper process context, so there is no
option to defer the association in similar fashion, correct?
Then, I wonder whether this isn't a scenario for
o = set_active_memcg(sk->sk_memcg);
newsk = sk_alloc();
...
set_active_memcg(o);
i.e. utilize the existing remote charging infra instead of introducing
specific mem_cgroup_sk_inherit() helper.
Regards,
Michal