Commit 54258324 authored by Jiri Olsa's avatar Jiri Olsa Committed by Alexei Starovoitov

bpftool: Display cookie for perf event link probes

Displaying cookie for perf event link probes, in plain mode:

  # bpftool link
  17: perf_event  prog 90
          kprobe ffffffff82b1c2b0 bpf_fentry_test1  cookie 3735928559
  18: perf_event  prog 90
          kretprobe ffffffff82b1c2b0 bpf_fentry_test1  cookie 3735928559
  20: perf_event  prog 92
          tracepoint sched_switch  cookie 3735928559
  21: perf_event  prog 93
          event software:page-faults  cookie 3735928559
  22: perf_event  prog 91
          uprobe /proc/self/exe+0xd703c  cookie 3735928559

And in json mode:

  # bpftool link -j | jq

  {
    "id": 30,
    "type": "perf_event",
    "prog_id": 160,
    "retprobe": false,
    "addr": 18446744071607272112,
    "func": "bpf_fentry_test1",
    "offset": 0,
    "missed": 0,
    "cookie": 3735928559
  }

  {
    "id": 33,
    "type": "perf_event",
    "prog_id": 162,
    "tracepoint": "sched_switch",
    "cookie": 3735928559
  }

  {
    "id": 34,
    "type": "perf_event",
    "prog_id": 163,
    "event_type": "software",
    "event_config": "page-faults",
    "cookie": 3735928559
  }

  {
    "id": 35,
    "type": "perf_event",
    "prog_id": 161,
    "retprobe": false,
    "file": "/proc/self/exe",
    "offset": 880700,
    "cookie": 3735928559
  }
Reviewed-by: default avatarQuentin Monnet <quentin@isovalent.com>
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarSong Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240119110505.400573-8-jolsa@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent b7896486
...@@ -334,6 +334,7 @@ show_perf_event_kprobe_json(struct bpf_link_info *info, json_writer_t *wtr) ...@@ -334,6 +334,7 @@ show_perf_event_kprobe_json(struct bpf_link_info *info, json_writer_t *wtr)
u64_to_ptr(info->perf_event.kprobe.func_name)); u64_to_ptr(info->perf_event.kprobe.func_name));
jsonw_uint_field(wtr, "offset", info->perf_event.kprobe.offset); jsonw_uint_field(wtr, "offset", info->perf_event.kprobe.offset);
jsonw_uint_field(wtr, "missed", info->perf_event.kprobe.missed); jsonw_uint_field(wtr, "missed", info->perf_event.kprobe.missed);
jsonw_uint_field(wtr, "cookie", info->perf_event.kprobe.cookie);
} }
static void static void
...@@ -343,6 +344,7 @@ show_perf_event_uprobe_json(struct bpf_link_info *info, json_writer_t *wtr) ...@@ -343,6 +344,7 @@ show_perf_event_uprobe_json(struct bpf_link_info *info, json_writer_t *wtr)
jsonw_string_field(wtr, "file", jsonw_string_field(wtr, "file",
u64_to_ptr(info->perf_event.uprobe.file_name)); u64_to_ptr(info->perf_event.uprobe.file_name));
jsonw_uint_field(wtr, "offset", info->perf_event.uprobe.offset); jsonw_uint_field(wtr, "offset", info->perf_event.uprobe.offset);
jsonw_uint_field(wtr, "cookie", info->perf_event.uprobe.cookie);
} }
static void static void
...@@ -350,6 +352,7 @@ show_perf_event_tracepoint_json(struct bpf_link_info *info, json_writer_t *wtr) ...@@ -350,6 +352,7 @@ show_perf_event_tracepoint_json(struct bpf_link_info *info, json_writer_t *wtr)
{ {
jsonw_string_field(wtr, "tracepoint", jsonw_string_field(wtr, "tracepoint",
u64_to_ptr(info->perf_event.tracepoint.tp_name)); u64_to_ptr(info->perf_event.tracepoint.tp_name));
jsonw_uint_field(wtr, "cookie", info->perf_event.tracepoint.cookie);
} }
static char *perf_config_hw_cache_str(__u64 config) static char *perf_config_hw_cache_str(__u64 config)
...@@ -426,6 +429,8 @@ show_perf_event_event_json(struct bpf_link_info *info, json_writer_t *wtr) ...@@ -426,6 +429,8 @@ show_perf_event_event_json(struct bpf_link_info *info, json_writer_t *wtr)
else else
jsonw_uint_field(wtr, "event_config", config); jsonw_uint_field(wtr, "event_config", config);
jsonw_uint_field(wtr, "cookie", info->perf_event.event.cookie);
if (type == PERF_TYPE_HW_CACHE && perf_config) if (type == PERF_TYPE_HW_CACHE && perf_config)
free((void *)perf_config); free((void *)perf_config);
} }
...@@ -754,6 +759,8 @@ static void show_perf_event_kprobe_plain(struct bpf_link_info *info) ...@@ -754,6 +759,8 @@ static void show_perf_event_kprobe_plain(struct bpf_link_info *info)
printf("+%#x", info->perf_event.kprobe.offset); printf("+%#x", info->perf_event.kprobe.offset);
if (info->perf_event.kprobe.missed) if (info->perf_event.kprobe.missed)
printf(" missed %llu", info->perf_event.kprobe.missed); printf(" missed %llu", info->perf_event.kprobe.missed);
if (info->perf_event.kprobe.cookie)
printf(" cookie %llu", info->perf_event.kprobe.cookie);
printf(" "); printf(" ");
} }
...@@ -770,6 +777,8 @@ static void show_perf_event_uprobe_plain(struct bpf_link_info *info) ...@@ -770,6 +777,8 @@ static void show_perf_event_uprobe_plain(struct bpf_link_info *info)
else else
printf("\n\tuprobe "); printf("\n\tuprobe ");
printf("%s+%#x ", buf, info->perf_event.uprobe.offset); printf("%s+%#x ", buf, info->perf_event.uprobe.offset);
if (info->perf_event.uprobe.cookie)
printf("cookie %llu ", info->perf_event.uprobe.cookie);
} }
static void show_perf_event_tracepoint_plain(struct bpf_link_info *info) static void show_perf_event_tracepoint_plain(struct bpf_link_info *info)
...@@ -781,6 +790,8 @@ static void show_perf_event_tracepoint_plain(struct bpf_link_info *info) ...@@ -781,6 +790,8 @@ static void show_perf_event_tracepoint_plain(struct bpf_link_info *info)
return; return;
printf("\n\ttracepoint %s ", buf); printf("\n\ttracepoint %s ", buf);
if (info->perf_event.tracepoint.cookie)
printf("cookie %llu ", info->perf_event.tracepoint.cookie);
} }
static void show_perf_event_event_plain(struct bpf_link_info *info) static void show_perf_event_event_plain(struct bpf_link_info *info)
...@@ -802,6 +813,9 @@ static void show_perf_event_event_plain(struct bpf_link_info *info) ...@@ -802,6 +813,9 @@ static void show_perf_event_event_plain(struct bpf_link_info *info)
else else
printf("%llu ", config); printf("%llu ", config);
if (info->perf_event.event.cookie)
printf("cookie %llu ", info->perf_event.event.cookie);
if (type == PERF_TYPE_HW_CACHE && perf_config) if (type == PERF_TYPE_HW_CACHE && perf_config)
free((void *)perf_config); free((void *)perf_config);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment