Re: [PATCH] bpf, cgroup: fix cgroup struct_ops query for a second attach type

From: Alexei Starovoitov

Date: Thu Oct 01 2026 - 09:48:25 EST


On Wed, Sep 30, 2026 at 06:51 AM Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote:
> +#define cgroup_bpf_enabled_runtime(atype) \
> + static_key_enabled(&cgroup_bpf_enabled_key[atype])

[...]

> @@ -1448,7 +1449,7 @@ static int __cgroup_bpf_query(struct cgroup *cgrp, const union bpf_attr *attr,
> return -ENOENT;
> from_atype = to_atype = atype;
> flags = 0;
> - if (!cgroup_bpf_enabled(atype))
> + if (!cgroup_bpf_enabled_runtime(atype))
> goto skip_count;

No need for a new macro.
When the key is off nothing is attached, so progs[atype] and
effective[atype] are empty and the loop below leaves total_cnt at 0.
All other attach types go through that loop without such check.
Just drop the check and the skip_count label.

pw-bot: cr