aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/perf/util/bpf_skel/sample_filter.bpf.c
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2023-04-07 22:52:08 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-10 18:57:17 -0300
commit3a8b8fc3174891c4c12f5766d82184a82d4b2e3e (patch)
tree0c727e50b32d55247cc6bdad0a228978a38aaa48 /tools/perf/util/bpf_skel/sample_filter.bpf.c
parentperf lock contention: Support pre-5.14 kernels (diff)
downloadwireguard-linux-3a8b8fc3174891c4c12f5766d82184a82d4b2e3e.tar.xz
wireguard-linux-3a8b8fc3174891c4c12f5766d82184a82d4b2e3e.zip
perf bpf filter: Support pre-5.16 kernels where 'mem_hops' isn't in 'union perf_mem_data_src'
The 'mem_hops' bits were added in 5.16 with no prior equivalent. Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: bpf@vger.kernel.org Link: https://lore.kernel.org/r/20230408055208.1283832-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/bpf_skel/sample_filter.bpf.c')
-rw-r--r--tools/perf/util/bpf_skel/sample_filter.bpf.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/tools/perf/util/bpf_skel/sample_filter.bpf.c b/tools/perf/util/bpf_skel/sample_filter.bpf.c
index 57e3c67d6d37..cffe493af1ed 100644
--- a/tools/perf/util/bpf_skel/sample_filter.bpf.c
+++ b/tools/perf/util/bpf_skel/sample_filter.bpf.c
@@ -24,6 +24,24 @@ struct perf_sample_data___new {
__u64 sample_flags;
} __attribute__((preserve_access_index));
+/* new kernel perf_mem_data_src definition */
+union perf_mem_data_src__new {
+ __u64 val;
+ struct {
+ __u64 mem_op:5, /* type of opcode */
+ mem_lvl:14, /* memory hierarchy level */
+ mem_snoop:5, /* snoop mode */
+ mem_lock:2, /* lock instr */
+ mem_dtlb:7, /* tlb access */
+ mem_lvl_num:4, /* memory hierarchy level number */
+ mem_remote:1, /* remote */
+ mem_snoopx:2, /* snoop mode, ext */
+ mem_blk:3, /* access blocked */
+ mem_hops:3, /* hop level */
+ mem_rsvd:18;
+ };
+};
+
/* helper function to return the given perf sample data */
static inline __u64 perf_get_sample(struct bpf_perf_event_data_kern *kctx,
struct perf_bpf_filter_entry *entry)
@@ -89,8 +107,14 @@ static inline __u64 perf_get_sample(struct bpf_perf_event_data_kern *kctx,
return kctx->data->data_src.mem_dtlb;
if (entry->part == 7)
return kctx->data->data_src.mem_blk;
- if (entry->part == 8)
- return kctx->data->data_src.mem_hops;
+ if (entry->part == 8) {
+ union perf_mem_data_src__new *data = (void *)&kctx->data->data_src;
+
+ if (bpf_core_field_exists(data->mem_hops))
+ return data->mem_hops;
+
+ return 0;
+ }
/* return the whole word */
return kctx->data->data_src.val;
default: