OSDN Git Service

perf bpf filter: Add more weight sample data support
authorNamhyung Kim <namhyung@kernel.org>
Tue, 14 Mar 2023 23:42:33 +0000 (16:42 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 15 Mar 2023 14:08:36 +0000 (11:08 -0300)
The weight data consists of a couple of fields with the
PERF_SAMPLE_WEIGHT_STRUCT.  Add weight{1,2,3} term to select them
separately.  Also add their aliases like 'ins_lat', 'p_stage_cyc' and
'retire_lat'.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Clark <james.clark@arm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Song Liu <song@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20230314234237.3008956-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/bpf-filter.l
tools/perf/util/bpf_skel/sample_filter.bpf.c

index ec12fc4..419f923 100644 (file)
@@ -71,6 +71,12 @@ addr         { return sample(PERF_SAMPLE_ADDR); }
 period         { return sample(PERF_SAMPLE_PERIOD); }
 txn            { return sample(PERF_SAMPLE_TRANSACTION); }
 weight         { return sample(PERF_SAMPLE_WEIGHT); }
+weight1                { return sample_part(PERF_SAMPLE_WEIGHT_STRUCT, 1); }
+weight2                { return sample_part(PERF_SAMPLE_WEIGHT_STRUCT, 2); }
+weight3                { return sample_part(PERF_SAMPLE_WEIGHT_STRUCT, 3); }
+ins_lat                { return sample_part(PERF_SAMPLE_WEIGHT_STRUCT, 2); } /* alias for weight2 */
+p_stage_cyc    { return sample_part(PERF_SAMPLE_WEIGHT_STRUCT, 3); } /* alias for weight3 */
+retire_lat     { return sample_part(PERF_SAMPLE_WEIGHT_STRUCT, 3); } /* alias for weight3 */
 phys_addr      { return sample(PERF_SAMPLE_PHYS_ADDR); }
 code_pgsz      { return sample(PERF_SAMPLE_CODE_PAGE_SIZE); }
 data_pgsz      { return sample(PERF_SAMPLE_DATA_PAGE_SIZE); }
index dddf38c..d930401 100644 (file)
@@ -54,6 +54,14 @@ static inline __u64 perf_get_sample(struct bpf_perf_event_data_kern *kctx,
                return kctx->data->period;
        case PERF_SAMPLE_TRANSACTION:
                return kctx->data->txn;
+       case PERF_SAMPLE_WEIGHT_STRUCT:
+               if (entry->part == 1)
+                       return kctx->data->weight.var1_dw;
+               if (entry->part == 2)
+                       return kctx->data->weight.var2_w;
+               if (entry->part == 3)
+                       return kctx->data->weight.var3_w;
+               /* fall through */
        case PERF_SAMPLE_WEIGHT:
                return kctx->data->weight.full;
        case PERF_SAMPLE_PHYS_ADDR: