Re: [PATCH bpf-next v4 2/4] bpf: Dissociate struct_ops progs before the grace period of the map

From: Alexei Starovoitov

Date: Fri Oct 16 2026 - 15:12:49 EST


On Fri, Oct 16, 2026 at 10:59 AM Qiliang Yuan <odys.yuan@xxxxxxxxx> wrote:

> - map->free_after_mult_rcu_gp = st_ops_desc->st_ops->free_after_mult_rcu_gp;
> + /*
> + * A prog dissociated in map_free_pre_rcu() may still run the struct_ops
> + * from a bpf_wq callback or a sleepable prog, under RCU tasks trace.
> + */
> + map->free_after_mult_rcu_gp = true;
> map->free_after_rcu_gp = true;

In v3 thread you asked whether to leave it to each struct_ops.
No. The owner of struct_ops cannot know whether a non-sleepable prog
starts bpf_wq.

bpf_map_put() checks free_after_mult_rcu_gp first,
so free_after_rcu_gp = true is dead now. Drop it.
st_ops->free_after_mult_rcu_gp only picks the gp for cgroup prog array
after this patch. Update its comment in struct bpf_struct_ops.

pw-bot: cr