__cgroup_bpf_detach(9)
π
__cgroup_bpf_detach β the kernel API manual, bestie edition β¨
Okay so real talk, we're in the Kernel API Manual today and the main character is __cgroup_bpf_detach(9). Yes, that's a mouthful, yes it's lowkey iconic, no we're not skipping anything. Sit down, grab a lil drink, let's get into it π
πΈ NAME πΈ
__cgroup_bpf_detach β detaches the program or the link from a cgroup, and then propagates the change to descendants. Like, the whole family tree gets the update, no cap.
β¨ SYNOPSIS β¨
int __cgroup_bpf_detach (struct cgroup *cgrp , struct bpf_prog *prog ,
struct bpf_cgroup_link *link , enum bpf_attach_type type , u64 revision
);
Copy it exactly, bestie, we do not freestyle signatures around here π
π ARGUMENTS π
cgrpβ the cgroup whose descendants we're gonna traverse. Think of it as the group chat you're sending the message to, and yes the whole thread reads it π«Άprogβ a program to detach, orNULL. That's it, that's the vibe.linkβ a link to detach, orNULL. Same deal, choose your fighter.typeβ the type of detach operation. Keeping it specified, periodt.revisionβ thebpf_prog_listrevision. Numbers matter, always.
π DESCRIPTION π
So here's the tea β: at most one of prog or link can be non-NULL. Not both. Never both. We don't do that here π
And this is the part where I have to be dramatic: it must be called with cgroup_mutex held. That's not a suggestion, that's not a cute optional extra, that's a requirement. Hold the mutex. Forever. Okay not forever but like, during the call. π₯
π¦ SEE ALSO π¦
Kernel file ./kernel/bpf/cgroup.c β go read it, it's giving main character energy:
cgroup_bpf_release(9)cgroup_bpf_release_fn(9)cgroup_bpf_inherit(9)__cgroup_bpf_attach(9)__cgroup_bpf_replace(9)purge_effective_progs(9)__cgroup_bpf_run_filter_skb(9)__cgroup_bpf_run_filter_sk(9)__cgroup_bpf_run_filter_sock_addr(9)__cgroup_bpf_run_filter_sock_ops(9)__cgroup_bpf_run_filter_sysctl(9)
π Sign-off π
That's the whole page, bestie, you ate π
β¨ This little gem lives in ./kernel/bpf, it's dated October 2026, and you can find it filed under __cgroup_bpf_detach(9). Go forth and detach responsibly π§π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms