On Fri, Oct 11, 2024 at 12:41 PM Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> wrote: > > On Fri, Oct 11, 2024 at 11:44 AM Alexei Starovoitov > <alexei.starovoitov@xxxxxxxxx> wrote: > > > > On Thu, Oct 10, 2024 at 4:25 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote: > > > > > > +struct bpf_iter__kmem_cache { > > > + __bpf_md_ptr(struct bpf_iter_meta *, meta); > > > + __bpf_md_ptr(struct kmem_cache *, s); > > > +}; BTW, do we want/need to define an open-coded iterator version of this, so that this iteration can be done from other BPF programs? Seems like it has to be a sleepable BPF program, but that's probably fine? > > > > Just noticed this. > > Not your fault. You're copy pasting from bpf_iter__*. > > It looks like tech debt. > > > > Andrii, Song, > > > > do you remember why all iters are using this? > > I don't *know*, but I suspect we are doing this because of 32-bit host > architecture. BPF-side is always 64-bit, so to make memory layout > inside the kernel and in BPF programs compatible we have to do this > for pointers, no? > > > __bpf_md_ptr() wrap was necessary in uapi/bpf.h, > > but this is kernel iters that go into vmlinux.h > > It should be fine to remove them all and > > progs wouldn't need to do the ugly dance of: > > > > #define bpf_iter__ksym bpf_iter__ksym___not_used > > #include "vmlinux.h" > > #undef bpf_iter__ksym > > I don't think __bpf_md_ptr is why we are doing this ___not_used dance. > At some point we probably didn't want to rely on having the very > latest vmlinux.h available in BPF selftests, so we chose to define > local versions of all relevant context types. > > I think we can drop all that ___not_used dance regardless (and remove > local definitions in progs/bpf_iter.h).