Commit 8882095b authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim
Browse files

perf sample: Remove arch notion of sample parsing



By definition arch sample parsing and synthesis will inhibit certain
kinds of cross-platform record then analysis (report, script,
etc.). Remove arch_perf_parse_sample_weight and
arch_perf_synthesize_sample_weight replacing with a common
implementation. Combine perf_sample p_stage_cyc and retire_lat as
weight3 to capture the differing uses regardless of compiled for
architecture.

Signed-off-by: default avatarIan Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250724163302.596743-21-irogers@google.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 525a599b
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
@@ -11,32 +11,6 @@
#include "../../../util/debug.h"
#include "../../../util/sample.h"

void arch_perf_parse_sample_weight(struct perf_sample *data,
				   const __u64 *array, u64 type)
{
	union perf_sample_weight weight;

	weight.full = *array;
	if (type & PERF_SAMPLE_WEIGHT)
		data->weight = weight.full;
	else {
		data->weight = weight.var1_dw;
		data->ins_lat = weight.var2_w;
		data->p_stage_cyc = weight.var3_w;
	}
}

void arch_perf_synthesize_sample_weight(const struct perf_sample *data,
					__u64 *array, u64 type)
{
	*array = data->weight;

	if (type & PERF_SAMPLE_WEIGHT_STRUCT) {
		*array &= 0xffffffff;
		*array |= ((u64)data->ins_lat << 32);
	}
}

const char *arch_perf_header_entry(const char *se_header)
{
	if (!strcmp(se_header, "Local INSTR Latency"))
+2 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ static bool samples_same(const struct perf_sample *s1,
{
	if (type & PERF_SAMPLE_WEIGHT_STRUCT) {
		COMP(ins_lat);
		COMP(retire_lat);
		COMP(weight3);
	}

	return true;
@@ -50,7 +50,7 @@ static int do_test(u64 sample_type)
	struct perf_sample sample = {
		.weight		= 101,
		.ins_lat        = 102,
		.retire_lat     = 103,
		.weight3	= 103,
	};
	struct perf_sample sample_out;
	size_t i, sz, bufsz;
+0 −27
Original line number Diff line number Diff line
@@ -92,33 +92,6 @@ int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool,

#endif

void arch_perf_parse_sample_weight(struct perf_sample *data,
				   const __u64 *array, u64 type)
{
	union perf_sample_weight weight;

	weight.full = *array;
	if (type & PERF_SAMPLE_WEIGHT)
		data->weight = weight.full;
	else {
		data->weight = weight.var1_dw;
		data->ins_lat = weight.var2_w;
		data->retire_lat = weight.var3_w;
	}
}

void arch_perf_synthesize_sample_weight(const struct perf_sample *data,
					__u64 *array, u64 type)
{
	*array = data->weight;

	if (type & PERF_SAMPLE_WEIGHT_STRUCT) {
		*array &= 0xffffffff;
		*array |= ((u64)data->ins_lat << 32);
		*array |= ((u64)data->retire_lat << 48);
	}
}

const char *arch_perf_header_entry(const char *se_header)
{
	if (!strcmp(se_header, "Local Pipeline Stage Cycle"))
+1 −1
Original line number Diff line number Diff line
@@ -2252,7 +2252,7 @@ static void process_event(struct perf_script *script,
		fprintf(fp, "%16" PRIu16, sample->ins_lat);

	if (PRINT_FIELD(RETIRE_LAT))
		fprintf(fp, "%16" PRIu16, sample->retire_lat);
		fprintf(fp, "%16" PRIu16, sample->weight3);

	if (PRINT_FIELD(CGROUP)) {
		const char *cgrp_name;
+1 −1
Original line number Diff line number Diff line
@@ -513,6 +513,7 @@ int dlfilter__do_filter_event(struct dlfilter *d,
	d->d_addr_al   = &d_addr_al;

	d_sample.size  = sizeof(d_sample);
	d_sample.p_stage_cyc = sample->weight3;
	d_ip_al.size   = 0; /* To indicate d_ip_al is not initialized */
	d_addr_al.size = 0; /* To indicate d_addr_al is not initialized */

@@ -526,7 +527,6 @@ int dlfilter__do_filter_event(struct dlfilter *d,
	ASSIGN(period);
	ASSIGN(weight);
	ASSIGN(ins_lat);
	ASSIGN(p_stage_cyc);
	ASSIGN(transaction);
	ASSIGN(insn_cnt);
	ASSIGN(cyc_cnt);
Loading