On Tue, 2024-02-27 at 15:16 -0800, Kui-Feng Lee wrote: [...] > > So, it appears that with shadow types users would have more or less > > convenient way to disable / enable related BPF programs > > (the references to programs are available, but reference counting > > would have to be implemented by user using some additional data > > structure, if needed). > > > > I don't see a way to reconcile shadow types with this autoload/autocreate toggling > > => my last two patches would have to be dropped. > > How about to update autoload according to the value of autocreate of > maps before loading the programs? For example, update autoload in > bpf_map__init_kern_struct_ops()? This can be done, but it would have to be a separate pass: first scanning all maps and setting up reference counters for programs, then scanning all programs and disabling those unused. I can do that in v2, thank you for the suggestion. Still, this overlaps a bit with shadow types. Do you have an idea if such auto-toggling would be helpful from libbpf users point of view?