On Fri, Jun 19, 2020 at 6:31 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote: > > On Thu, Jun 18, 2020 at 09:35:10PM -0700, Andrii Nakryiko wrote: > > On Tue, Jun 16, 2020 at 3:07 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote: > > > > > > Adding d_path helper function that returns full path > > > for give 'struct path' object, which needs to be the > > > kernel BTF 'path' object. > > > > > > The helper calls directly d_path function. > > > > > > Updating also bpf.h tools uapi header and adding > > > 'path' to bpf_helpers_doc.py script. > > > > > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > > > --- > > > include/linux/bpf.h | 4 ++++ > > > include/uapi/linux/bpf.h | 14 ++++++++++++- > > > kernel/bpf/btf_ids.c | 11 ++++++++++ > > > kernel/trace/bpf_trace.c | 38 ++++++++++++++++++++++++++++++++++ > > > scripts/bpf_helpers_doc.py | 2 ++ > > > tools/include/uapi/linux/bpf.h | 14 ++++++++++++- > > > 6 files changed, 81 insertions(+), 2 deletions(-) > > > > > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > > > index a94e85c2ec50..d35265b6c574 100644 > > > --- a/include/linux/bpf.h > > > +++ b/include/linux/bpf.h > > > @@ -1752,5 +1752,9 @@ extern int bpf_skb_output_btf_ids[]; > > > extern int bpf_seq_printf_btf_ids[]; > > > extern int bpf_seq_write_btf_ids[]; > > > extern int bpf_xdp_output_btf_ids[]; > > > +extern int bpf_d_path_btf_ids[]; > > > + > > > +extern int btf_whitelist_d_path[]; > > > +extern int btf_whitelist_d_path_cnt; > > > > So with suggestion from previous patch, this would be declared as: > > > > extern const struct btf_id_set btf_whitelist_d_path; > > yes > > SNIP > > > > /* integer value in 'imm' field of BPF_CALL instruction selects which helper > > > * function eBPF program intends to call > > > diff --git a/kernel/bpf/btf_ids.c b/kernel/bpf/btf_ids.c > > > index d8d0df162f04..853c8fd59b06 100644 > > > --- a/kernel/bpf/btf_ids.c > > > +++ b/kernel/bpf/btf_ids.c > > > @@ -13,3 +13,14 @@ BTF_ID(struct, seq_file) > > > > > > BTF_ID_LIST(bpf_xdp_output_btf_ids) > > > BTF_ID(struct, xdp_buff) > > > + > > > +BTF_ID_LIST(bpf_d_path_btf_ids) > > > +BTF_ID(struct, path) > > > + > > > +BTF_WHITELIST_ENTRY(btf_whitelist_d_path) > > > +BTF_ID(func, vfs_truncate) > > > +BTF_ID(func, vfs_fallocate) > > > +BTF_ID(func, dentry_open) > > > +BTF_ID(func, vfs_getattr) > > > +BTF_ID(func, filp_close) > > > +BTF_WHITELIST_END(btf_whitelist_d_path) > > > > Oh, so that's why you added btf_ids.c. Do you think centralizing all > > those BTF ID lists in one file is going to be more convenient? I lean > > towards keeping them closer to where they are used, as it was with all > > those helper BTF IDS. But I wonder what others think... > > either way works for me, but then BTF_ID_* macros needs to go > to include/linux/btf_ids.h header right? > given it's internal API, I'd probably just put it in include/linux/btf.h or include/linux/bpf.h, don't think we need extra header just for these > jirka > > > > > > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c > > > index c1866d76041f..0ff5d8434d40 100644 > > > --- a/kernel/trace/bpf_trace.c > > > +++ b/kernel/trace/bpf_trace.c > > > @@ -1016,6 +1016,42 @@ static const struct bpf_func_proto bpf_send_signal_thread_proto = { > > > .arg1_type = ARG_ANYTHING, > > > }; > > > > > > > [...] > > >