On Wed, Aug 23, 2023 at 10:53 AM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > On Wed, Aug 23, 2023 at 10:14 AM Andrii Nakryiko > <andrii.nakryiko@xxxxxxxxx> wrote: > > > > > Long term we need to think how to extend bpf ISA with alloca. > > > > To be frank, I'm not following how alloca is relevant here. We don't > > have anything dynamically sized on the stack. > > > > Unless you envision protocol where we have a separate function to get > > size of iter struct, then alloca enough space, then pass that to > > bpf_iter_xxx_new()? Not sure whether this is statically verifiable, > > but given it's long-term, we can put it on backburner for now. > > With alloca bpf_for_each() macro can allocate whatever stack necessary. > > In other words: > > struct bpf_iter_task_vma *it; > > it = bpf_alloca(bpf_core_type_size(struct bpf_iter_task_vma)); > bpf_for_each2(task_vma, it, ...) { .. } ah, I see, not a dedicated kfunc, just CO-RE relocation. Makes sense. > > While struct bpf_iter_task_vma can come from vmlinux.h > > size of kern data struct is CO-RE-able, so no worries about increase > in size due to maple tree or lockdep on/off. > And no concern of failing allocation at run-time. > (the verifier would reject big stack alloc at load time). yep, makes sense, the size will be statically known to the verifier. I was overcomplicating this in my mind with extra kfunc.