bpf_task_under_cgroup(9)
π bpf_task_under_cgroup(9) β kernel API manual, but make it make sense
okay so bestie, this is a page from the Kernel API Manual (that's the manual name, cute) β and it's all about one little kfunc that answers a very specific question for you. Let's go π
β¨ NAME β¨
bpf_task_under_cgroup β the kfunc that wraps task_under_cgroup_hierarchy() for you, so you can test whether a task belongs to a cgroup's ancestry π
That's the whole job. It's a vibe check for cgroup family trees, no cap.
πΈ SYNOPSIS πΈ
__bpf_kfunc long bpf_task_under_cgroup (struct task_struct *task ,
struct cgroup *ancestor );
look at her. two pointers, one long. she's iconic and she's not doing extra credit π₯
π¦ ARGUMENTS π¦
taskβ the task you're testing π like, the one you're asking aboutancestorβ a possible ancestor of that task's cgroup π³ the "is this your grandma" candidate
π DESCRIPTION π
so here's the tea β: it tests whether task's default cgroup hierarchy is a descendant of ancestor.
and before you ask β yes, it follows all the same rules as cgroup_is_descendant, exactly, no remix, no creative liberties. and important: it only applies to the default hierarchy. default only, bestie, don't come at it with anything else π
π SEE ALSO π
this next part is literally the whole group chat, i'm not kidding. all of these are waiting for you in the kernel file ./kernel/bpf/helpers.c:
bpf_obj_new(9)bpf_percpu_obj_new(9)bpf_obj_drop(9)bpf_percpu_obj_drop(9)bpf_refcount_acquire(9)bpf_list_push_front(9)bpf_list_push_back(9)bpf_rbtree_add(9)bpf_task_acquire(9)bpf_task_release(9)bpf_cgroup_acquire(9)bpf_cgroup_release(9)bpf_cgroup_ancestor(9)bpf_cgroup_from_id(9)bpf_task_get_cgroup1(9)bpf_task_from_pid(9)bpf_task_from_vpid(9)bpf_dynptr_slice(9)bpf_dynptr_slice_rdwr(9)bpf_dynptr_copy(9)bpf_dynptr_memset(9)bpf_iter_bits_new(9)bpf_iter_bits_next(9)bpf_iter_bits_destroy(9)bpf_copy_from_user_str(9)bpf_copy_from_user_task_str(9)bpf_strcmp(9)bpf_strcasecmp(9)bpf_strnchr(9)bpf_strchr(9)bpf_strchrnul(9)bpf_strrchr(9)bpf_strnlen(9)bpf_strlen(9)bpf_strspn(9)bpf_strcspn(9)bpf_strstr(9)bpf_strcasestr(9)bpf_strnstr(9)bpf_strncasestr(9)bpf_lookup_user_key(9)bpf_lookup_system_key(9)bpf_key_put(9)bpf_verify_pkcs7_signature(9)bpf_task_work_schedule_signal(9)bpf_task_work_schedule_resume(9)bpf_timer_cancel_async(9)
like i said. the entire group chat. say hi to all of them for me π«Ά
sign-off time π§ this page lives in ./kernel/bpf, it's dated October 2026, and yeah β it's bpf_task_under_cgroup(9) all the way down. mwah π periodt. β
π¦ 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