From: Jiri Olsa <olsajiri@gmail.com>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
bpf@vger.kernel.org, linux-perf-users@vger.kernel.org,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
Hao Luo <haoluo@google.com>, Yafang Shao <laoar.shao@gmail.com>,
Quentin Monnet <qmo@kernel.org>
Subject: Re: [PATCH bpf-next 3/3] bpftool: Display ref_ctr_offset for uprobe link info
Date: Fri, 9 May 2025 17:30:44 +0200 [thread overview]
Message-ID: <aB4fpAlfNhshy5DA@krava> (raw)
In-Reply-To: <aBsgQw1kzJsRzM5p@krava>
On Wed, May 07, 2025 at 10:56:35AM +0200, Jiri Olsa wrote:
> On Tue, May 06, 2025 at 03:33:33PM -0700, Andrii Nakryiko wrote:
> > On Tue, May 6, 2025 at 6:58 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > >
> > > Adding support to display ref_ctr_offset in link output, like:
> > >
> > > # bpftool link
> > > ...
> > > 42: perf_event prog 174
> > > uprobe /proc/self/exe+0x102f13 cookie 3735928559 ref_ctr_offset 50500538
> >
> > let's use hex for ref_ctr_offset?
>
> I had that, then I saw cookie was dec ;-) either way is fine for me
>
> >
> > and also, why do we have bpf_cookie and cookie emitted? Are they different?
>
> hum, right.. so there's bpf_cookie retrieval from perf_link through the
> task_file iterator:
>
> cbdaf71f7e65 bpftool: Add bpf_cookie to link output
>
> I guess it was added before we decided to have bpf_link_info.perf_event
> interface, which seems easier to me
we could drop the bpf_cookie with attached patch, but should we worry
about loosing 'bpf_cookie' tag from json output (there will be just
'cookie' tag now with the same value)
jirka
---
diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
index 9eb764fe4cc8..ca8923425637 100644
--- a/tools/bpf/bpftool/main.h
+++ b/tools/bpf/bpftool/main.h
@@ -104,9 +104,7 @@ struct obj_ref {
struct obj_refs {
int ref_cnt;
- bool has_bpf_cookie;
struct obj_ref *refs;
- __u64 bpf_cookie;
};
struct btf;
diff --git a/tools/bpf/bpftool/pids.c b/tools/bpf/bpftool/pids.c
index 23f488cf1740..e81518dfc835 100644
--- a/tools/bpf/bpftool/pids.c
+++ b/tools/bpf/bpftool/pids.c
@@ -80,8 +80,6 @@ static void add_ref(struct hashmap *map, struct pid_iter_entry *e)
memcpy(ref->comm, e->comm, sizeof(ref->comm));
ref->comm[sizeof(ref->comm) - 1] = '\0';
refs->ref_cnt = 1;
- refs->has_bpf_cookie = e->has_bpf_cookie;
- refs->bpf_cookie = e->bpf_cookie;
err = hashmap__append(map, e->id, refs);
if (err)
@@ -214,9 +212,6 @@ void emit_obj_refs_json(struct hashmap *map, __u32 id,
if (refs->ref_cnt == 0)
break;
- if (refs->has_bpf_cookie)
- jsonw_lluint_field(json_writer, "bpf_cookie", refs->bpf_cookie);
-
jsonw_name(json_writer, "pids");
jsonw_start_array(json_writer);
for (i = 0; i < refs->ref_cnt; i++) {
@@ -246,9 +241,6 @@ void emit_obj_refs_plain(struct hashmap *map, __u32 id, const char *prefix)
if (refs->ref_cnt == 0)
break;
- if (refs->has_bpf_cookie)
- printf("\n\tbpf_cookie %llu", (unsigned long long) refs->bpf_cookie);
-
printf("%s", prefix);
for (i = 0; i < refs->ref_cnt; i++) {
struct obj_ref *ref = &refs->refs[i];
diff --git a/tools/bpf/bpftool/skeleton/pid_iter.bpf.c b/tools/bpf/bpftool/skeleton/pid_iter.bpf.c
index 948dde25034e..ea6d54f43425 100644
--- a/tools/bpf/bpftool/skeleton/pid_iter.bpf.c
+++ b/tools/bpf/bpftool/skeleton/pid_iter.bpf.c
@@ -15,19 +15,6 @@ enum bpf_obj_type {
BPF_OBJ_BTF,
};
-struct bpf_perf_link___local {
- struct bpf_link link;
- struct file *perf_file;
-} __attribute__((preserve_access_index));
-
-struct perf_event___local {
- u64 bpf_cookie;
-} __attribute__((preserve_access_index));
-
-enum bpf_link_type___local {
- BPF_LINK_TYPE_PERF_EVENT___local = 7,
-};
-
extern const void bpf_link_fops __ksym;
extern const void bpf_link_fops_poll __ksym __weak;
extern const void bpf_map_fops __ksym;
@@ -52,17 +39,6 @@ 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 __u64 get_bpf_cookie(struct bpf_link *link)
-{
- struct bpf_perf_link___local *perf_link;
- struct perf_event___local *event;
-
- perf_link = container_of(link, struct bpf_perf_link___local, link);
- event = BPF_CORE_READ(perf_link, perf_file, private_data);
- return BPF_CORE_READ(event, bpf_cookie);
-}
-
SEC("iter/task_file")
int iter(struct bpf_iter__task_file *ctx)
{
@@ -102,18 +78,6 @@ int iter(struct bpf_iter__task_file *ctx)
e.pid = task->tgid;
e.id = get_obj_id(file->private_data, obj_type);
- if (obj_type == BPF_OBJ_LINK &&
- bpf_core_enum_value_exists(enum bpf_link_type___local,
- BPF_LINK_TYPE_PERF_EVENT___local)) {
- struct bpf_link *link = (struct bpf_link *) file->private_data;
-
- if (BPF_CORE_READ(link, type) == bpf_core_enum_value(enum bpf_link_type___local,
- BPF_LINK_TYPE_PERF_EVENT___local)) {
- e.has_bpf_cookie = true;
- e.bpf_cookie = get_bpf_cookie(link);
- }
- }
-
bpf_probe_read_kernel_str(&e.comm, sizeof(e.comm),
task->group_leader->comm);
bpf_seq_write(ctx->meta->seq, &e, sizeof(e));
diff --git a/tools/bpf/bpftool/skeleton/pid_iter.h b/tools/bpf/bpftool/skeleton/pid_iter.h
index bbb570d4cca6..5692cf257adb 100644
--- a/tools/bpf/bpftool/skeleton/pid_iter.h
+++ b/tools/bpf/bpftool/skeleton/pid_iter.h
@@ -6,8 +6,6 @@
struct pid_iter_entry {
__u32 id;
int pid;
- __u64 bpf_cookie;
- bool has_bpf_cookie;
char comm[16];
};
next prev parent reply other threads:[~2025-05-09 15:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 13:57 [PATCH bpf-next 0/3] bpf: Retrieve ref_ctr_offset from uprobe perf link Jiri Olsa
2025-05-06 13:57 ` [PATCH bpf-next 1/3] bpf: Add support to retrieve ref_ctr_offset for " Jiri Olsa
2025-05-07 2:18 ` Yafang Shao
2025-05-06 13:57 ` [PATCH bpf-next 2/3] selftests/bpf: Add link info test for ref_ctr_offset retrieval Jiri Olsa
2025-05-07 2:26 ` Yafang Shao
2025-05-06 13:57 ` [PATCH bpf-next 3/3] bpftool: Display ref_ctr_offset for uprobe link info Jiri Olsa
2025-05-06 14:28 ` Quentin Monnet
2025-05-06 22:33 ` Andrii Nakryiko
2025-05-07 8:56 ` Jiri Olsa
2025-05-07 9:40 ` Quentin Monnet
2025-05-07 18:18 ` Andrii Nakryiko
2025-05-07 19:35 ` Quentin Monnet
2025-05-09 15:30 ` Jiri Olsa [this message]
2025-05-09 15:54 ` Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aB4fpAlfNhshy5DA@krava \
--to=olsajiri@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=laoar.shao@gmail.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=qmo@kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).