On Wed, 2024-08-14 at 11:54 -0700, Andrii Nakryiko wrote: > Change stack_map_get_build_id_offset() which is used to convert stack > trace IP addresses into build ID+offset pairs. Right now this function > accepts an array of u64s as an input, and uses array of > struct bpf_stack_build_id as an output. > > This is problematic because u64 array is coming from > perf_callchain_entry, which is (non-sleepable) RCU protected, so once we > allows sleepable build ID fetching, this all breaks down. > > But its actually pretty easy to make stack_map_get_build_id_offset() > works with array of struct bpf_stack_build_id as both input and output. > Which is what this patch is doing, eliminating the dependency on > perf_callchain_entry. We require caller to fill out > bpf_stack_build_id.ip fields (all other can be left uninitialized), and > update in place as we do build ID resolution. > > We make sure to READ_ONCE() and cache locally current IP value as we > used it in a few places to find matching VMA and so on. Given this data > is directly accessible and modifiable by user's BPF code, we should make > sure to have a consistent view of it. > > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > --- Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx> [...]