On 7/9/25 3:13 PM, Martin KaFai Lau wrote:
If I understand correctly, the kfunc implementation needs to look up the scx_ops instance (i.e., the struct_ops map) from the map->id/cookie. There is a similar map->id lookup in bpf_map_get_fd_by_id(), which requires acquiring a spin_lock. If performance is a concern, we can investigate whether it can be rcu-ified. From a quick glance, bpf_map_free_id() is called before call_rcu(). Note that bpf_struct_ops_map_free() will wait for an RCU grace period.
After looking at bpf_map_put more, not all BPF map frees wait for RCU. It may be cleaner to store the sched_ext_ops map in a separate (i.e., new) lookup data structure. That may also make it easier to ensure the looked up map is a struct_ops map (or in particular a sched_ext_ops).