]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cgroup: Add bpf prog revisions to struct cgroup_bpf
authorYonghong Song <yonghong.song@linux.dev>
Fri, 6 Jun 2025 16:31:36 +0000 (09:31 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 9 Jun 2025 23:17:11 +0000 (16:17 -0700)
One of key items in mprog API is revision for prog list. The revision
number will be increased if the prog list changed, e.g., attach, detach
or replace.

Add 'revisions' field to struct cgroup_bpf, representing revisions for
all cgroup related attachment types. The initial revision value is
set to 1, the same as kernel mprog implementations.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250606163136.2428732-1-yonghong.song@linux.dev
include/linux/bpf-cgroup-defs.h
kernel/cgroup/cgroup.c

index 0985221d54788fd2b58cbae7f597007043df66db..c9e6b26abab6d7932a7e785d640b2639df113bef 100644 (file)
@@ -63,6 +63,7 @@ struct cgroup_bpf {
         */
        struct hlist_head progs[MAX_CGROUP_BPF_ATTACH_TYPE];
        u8 flags[MAX_CGROUP_BPF_ATTACH_TYPE];
+       u64 revisions[MAX_CGROUP_BPF_ATTACH_TYPE];
 
        /* list of cgroup shared storages */
        struct list_head storages;
index a723b7dc6e4e2879d1ea6a8eebb5034c52569d0a..312c6a8b55bb73d2780ca4b3ed02669bb3062bb9 100644 (file)
@@ -2074,6 +2074,11 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
        for_each_subsys(ss, ssid)
                INIT_LIST_HEAD(&cgrp->e_csets[ssid]);
 
+#ifdef CONFIG_CGROUP_BPF
+       for (int i = 0; i < ARRAY_SIZE(cgrp->bpf.revisions); i++)
+               cgrp->bpf.revisions[i] = 1;
+#endif
+
        init_waitqueue_head(&cgrp->offline_waitq);
        INIT_WORK(&cgrp->release_agent_work, cgroup1_release_agent);
 }