On Sun, Jul 27, 2025 at 4:32 PM Daniel Borkmann <daniel@xxxxxxxxxxxxx> wrote: > > Move them into bpf.h given we also need them in core code, add also > for_each_cgroup_storage_type_cond() which we'll be using in a > subsequent change. > > Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx> > --- > include/linux/bpf-cgroup.h | 3 --- > include/linux/bpf.h | 20 ++++++++++++-------- > 2 files changed, 12 insertions(+), 11 deletions(-) > > diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h > index 082ccd8ad96b..d1f01d1168a1 100644 > --- a/include/linux/bpf-cgroup.h > +++ b/include/linux/bpf-cgroup.h > @@ -77,9 +77,6 @@ to_cgroup_bpf_attach_type(enum bpf_attach_type attach_type) > extern struct static_key_false cgroup_bpf_enabled_key[MAX_CGROUP_BPF_ATTACH_TYPE]; > #define cgroup_bpf_enabled(atype) static_branch_unlikely(&cgroup_bpf_enabled_key[atype]) > > -#define for_each_cgroup_storage_type(stype) \ > - for (stype = 0; stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++) > - > struct bpf_cgroup_storage_map; > > struct bpf_storage_buffer { > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > index a87646cc5398..a41dff574327 100644 > --- a/include/linux/bpf.h > +++ b/include/linux/bpf.h > @@ -208,6 +208,18 @@ enum btf_field_type { > BPF_RES_SPIN_LOCK = (1 << 12), > }; > > +enum bpf_cgroup_storage_type { > + BPF_CGROUP_STORAGE_SHARED, > + BPF_CGROUP_STORAGE_PERCPU, > + __BPF_CGROUP_STORAGE_MAX > +#define MAX_BPF_CGROUP_STORAGE_TYPE __BPF_CGROUP_STORAGE_MAX > +}; > + > +#define for_each_cgroup_storage_type(stype) \ > + for (stype = 0; stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++) > +#define for_each_cgroup_storage_type_cond(stype, cond) \ > + for (stype = 0; (cond) && stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++) > + tbh I don't like this hidden condition. It makes usage of this macro harder to follow. Just open coded it in the callsite ? Unrelated to the patch, but Dual #define for_each_cgroup_storage_type for CONFIG_CGROUP_BPF vs not is ugly. I don't understand why we added it. I see no harm doing it once since enum bpf_cgroup_storage_type is unconditional. -- pw-bot: cr