Skip to content

Use mem_cgroup_from_sk in homa_rpc_alloc_server - #26

Draft
randomizedcoder wants to merge 1 commit into
mainfrom
fix/rpc-memcg-without-config-memcg
Draft

randomizedcoder wants to merge 1 commit into
mainfrom
fix/rpc-memcg-without-config-memcg

Conversation

@randomizedcoder

@randomizedcoder randomizedcoder commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

struct sock has sk_memcg only when CONFIG_MEMCG is set. In a kernel without memory cgroups (x86_64 and i386 defconfig, for example), homa_rpc_alloc_server doesn't compile:

net/homa/homa_rpc.c:134:22: error: 'struct sock' has no member named 'sk_memcg'

The out-of-tree build only passes because distro kernels enable memcg.

Fix: read it with mem_cgroup_from_sk(). Under CONFIG_MEMCG that returns sk->sk_memcg; without it, it returns NULL, so the allocation takes the existing non-accounted path. Behaviour is unchanged when memcg is on.

Checked:

No test, since it's a build fix.

🤖 Generated with Claude Code

Since Linux 6.18, struct sock has an sk_memcg field only when
CONFIG_MEMCG is set, so homa_rpc_alloc_server failed to compile in
kernels without memory cgroups (such as x86_64 and i386 defconfig).
Use mem_cgroup_from_sk, which returns NULL in that case. That function
doesn't exist before 6.18, where sk_memcg is unconditional, so keep
reading the field there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@randomizedcoder
randomizedcoder force-pushed the fix/rpc-memcg-without-config-memcg branch from e550056 to 07b4cc6 Compare November 7, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant