> On Mon, Mar 07, 2022 at 05:41:24PM -0800, Andrii Nakryiko wrote: > On Fri, Mar 4, 2022 at 6:36 AM Dmitrii Dolgov <9erthalion6@xxxxxxxxx> wrote: > > > > @@ -234,6 +239,9 @@ void emit_obj_refs_plain(struct hashmap *map, __u32 id, const char *prefix) > > if (refs->ref_cnt == 0) > > break; > > > > + if (refs->bpf_cookie_set) > > + printf("\n\tbpf_cookie %llu", refs->bpf_cookie); > > __u64 is not always %llu on all architectures. Best to cast it to > (unsigned long long) here to avoid compilation warnings. > > > @@ -38,6 +38,18 @@ static __always_inline __u32 get_obj_id(void *ent, enum bpf_obj_type type) > > } > > } > > > > +/* could be used only with BPF_LINK_TYPE_PERF_EVENT links */ > > +static __always_inline __u64 get_bpf_cookie(struct bpf_link *link) > > no need for __always_inline > > > +{ > > + struct bpf_perf_link *perf_link; > > + struct perf_event *event; > > + > > + perf_link = container_of(link, struct bpf_perf_link, link); > > + event = BPF_CORE_READ(perf_link, perf_file, private_data); > > + return BPF_CORE_READ(event, bpf_cookie); > > +} > > + > > + > > nit: why double empty line? > > > diff --git a/tools/bpf/bpftool/skeleton/pid_iter.h b/tools/bpf/bpftool/skeleton/pid_iter.h > > index 5692cf257adb..2676cece58d7 100644 > > --- a/tools/bpf/bpftool/skeleton/pid_iter.h > > +++ b/tools/bpf/bpftool/skeleton/pid_iter.h > > @@ -6,6 +6,8 @@ > > struct pid_iter_entry { > > __u32 id; > > int pid; > > + __u64 bpf_cookie; > > + bool bpf_cookie_set; > > naming nit: either "bpf_cookie_is_set" or "has_bpf_cookie"? > "bpf_cookie_set" is read either as a verb or as "a set of bpf_cookies" Yep, makes sense (this and the rest of the comments above), will post a new version with the cumulative changes soon.