Skip to content

Commit 8882095

Browse files
captain5050namhyung
authored andcommitted
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: Ian Rogers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 525a599 commit 8882095

File tree

14 files changed

+36
-80
lines changed

14 files changed

+36
-80
lines changed

tools/perf/arch/powerpc/util/event.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,6 @@
1111
#include "../../../util/debug.h"
1212
#include "../../../util/sample.h"
1313

14-
void arch_perf_parse_sample_weight(struct perf_sample *data,
15-
const __u64 *array, u64 type)
16-
{
17-
union perf_sample_weight weight;
18-
19-
weight.full = *array;
20-
if (type & PERF_SAMPLE_WEIGHT)
21-
data->weight = weight.full;
22-
else {
23-
data->weight = weight.var1_dw;
24-
data->ins_lat = weight.var2_w;
25-
data->p_stage_cyc = weight.var3_w;
26-
}
27-
}
28-
29-
void arch_perf_synthesize_sample_weight(const struct perf_sample *data,
30-
__u64 *array, u64 type)
31-
{
32-
*array = data->weight;
33-
34-
if (type & PERF_SAMPLE_WEIGHT_STRUCT) {
35-
*array &= 0xffffffff;
36-
*array |= ((u64)data->ins_lat << 32);
37-
}
38-
}
39-
4014
const char *arch_perf_header_entry(const char *se_header)
4115
{
4216
if (!strcmp(se_header, "Local INSTR Latency"))

tools/perf/arch/x86/tests/sample-parsing.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static bool samples_same(const struct perf_sample *s1,
2929
{
3030
if (type & PERF_SAMPLE_WEIGHT_STRUCT) {
3131
COMP(ins_lat);
32-
COMP(retire_lat);
32+
COMP(weight3);
3333
}
3434

3535
return true;
@@ -50,7 +50,7 @@ static int do_test(u64 sample_type)
5050
struct perf_sample sample = {
5151
.weight = 101,
5252
.ins_lat = 102,
53-
.retire_lat = 103,
53+
.weight3 = 103,
5454
};
5555
struct perf_sample sample_out;
5656
size_t i, sz, bufsz;

tools/perf/arch/x86/util/event.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -92,33 +92,6 @@ int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool,
9292

9393
#endif
9494

95-
void arch_perf_parse_sample_weight(struct perf_sample *data,
96-
const __u64 *array, u64 type)
97-
{
98-
union perf_sample_weight weight;
99-
100-
weight.full = *array;
101-
if (type & PERF_SAMPLE_WEIGHT)
102-
data->weight = weight.full;
103-
else {
104-
data->weight = weight.var1_dw;
105-
data->ins_lat = weight.var2_w;
106-
data->retire_lat = weight.var3_w;
107-
}
108-
}
109-
110-
void arch_perf_synthesize_sample_weight(const struct perf_sample *data,
111-
__u64 *array, u64 type)
112-
{
113-
*array = data->weight;
114-
115-
if (type & PERF_SAMPLE_WEIGHT_STRUCT) {
116-
*array &= 0xffffffff;
117-
*array |= ((u64)data->ins_lat << 32);
118-
*array |= ((u64)data->retire_lat << 48);
119-
}
120-
}
121-
12295
const char *arch_perf_header_entry(const char *se_header)
12396
{
12497
if (!strcmp(se_header, "Local Pipeline Stage Cycle"))

tools/perf/builtin-script.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2252,7 +2252,7 @@ static void process_event(struct perf_script *script,
22522252
fprintf(fp, "%16" PRIu16, sample->ins_lat);
22532253

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

22572257
if (PRINT_FIELD(CGROUP)) {
22582258
const char *cgrp_name;

tools/perf/util/dlfilter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ int dlfilter__do_filter_event(struct dlfilter *d,
513513
d->d_addr_al = &d_addr_al;
514514

515515
d_sample.size = sizeof(d_sample);
516+
d_sample.p_stage_cyc = sample->weight3;
516517
d_ip_al.size = 0; /* To indicate d_ip_al is not initialized */
517518
d_addr_al.size = 0; /* To indicate d_addr_al is not initialized */
518519

@@ -526,7 +527,6 @@ int dlfilter__do_filter_event(struct dlfilter *d,
526527
ASSIGN(period);
527528
ASSIGN(weight);
528529
ASSIGN(ins_lat);
529-
ASSIGN(p_stage_cyc);
530530
ASSIGN(transaction);
531531
ASSIGN(insn_cnt);
532532
ASSIGN(cyc_cnt);

tools/perf/util/event.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@ extern unsigned int proc_map_timeout;
391391
#define PAGE_SIZE_NAME_LEN 32
392392
char *get_page_size_name(u64 size, char *str);
393393

394-
void arch_perf_parse_sample_weight(struct perf_sample *data, const __u64 *array, u64 type);
395-
void arch_perf_synthesize_sample_weight(const struct perf_sample *data, __u64 *array, u64 type);
396394
const char *arch_perf_header_entry(const char *se_header);
397395
int arch_support_sort_key(const char *sort_key);
398396

tools/perf/util/evsel.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,11 +2880,18 @@ perf_event__check_size(union perf_event *event, unsigned int sample_size)
28802880
return 0;
28812881
}
28822882

2883-
void __weak arch_perf_parse_sample_weight(struct perf_sample *data,
2884-
const __u64 *array,
2885-
u64 type __maybe_unused)
2883+
static void perf_parse_sample_weight(struct perf_sample *data, const __u64 *array, u64 type)
28862884
{
2887-
data->weight = *array;
2885+
union perf_sample_weight weight;
2886+
2887+
weight.full = *array;
2888+
if (type & PERF_SAMPLE_WEIGHT_STRUCT) {
2889+
data->weight = weight.var1_dw;
2890+
data->ins_lat = weight.var2_w;
2891+
data->weight3 = weight.var3_w;
2892+
} else {
2893+
data->weight = weight.full;
2894+
}
28882895
}
28892896

28902897
u64 evsel__bitfield_swap_branch_flags(u64 value)
@@ -3270,7 +3277,7 @@ int evsel__parse_sample(struct evsel *evsel, union perf_event *event,
32703277

32713278
if (type & PERF_SAMPLE_WEIGHT_TYPE) {
32723279
OVERFLOW_CHECK_u64(array);
3273-
arch_perf_parse_sample_weight(data, array, type);
3280+
perf_parse_sample_weight(data, array, type);
32743281
array++;
32753282
}
32763283

tools/perf/util/hist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ __hists__add_entry(struct hists *hists,
829829
.period = sample->period,
830830
.weight1 = sample->weight,
831831
.weight2 = sample->ins_lat,
832-
.weight3 = sample->p_stage_cyc,
832+
.weight3 = sample->weight3,
833833
.latency = al->latency,
834834
},
835835
.parent = sym_parent,
@@ -846,7 +846,7 @@ __hists__add_entry(struct hists *hists,
846846
.time = hist_time(sample->time),
847847
.weight = sample->weight,
848848
.ins_lat = sample->ins_lat,
849-
.p_stage_cyc = sample->p_stage_cyc,
849+
.weight3 = sample->weight3,
850850
.simd_flags = sample->simd_flags,
851851
}, *he = hists__findnew_entry(hists, &entry, al, sample_self);
852852

tools/perf/util/hist.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ struct hist_entry {
255255
u64 code_page_size;
256256
u64 weight;
257257
u64 ins_lat;
258-
u64 p_stage_cyc;
258+
/** @weight3: On x86 holds retire_lat, on powerpc holds p_stage_cyc. */
259+
u64 weight3;
259260
s32 socket;
260261
s32 cpu;
261262
int parallelism;

tools/perf/util/intel-tpebs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
210210
* latency value will be used. Save the number of samples and the sum of
211211
* retire latency value for each event.
212212
*/
213-
t->last = sample->retire_lat;
214-
update_stats(&t->stats, sample->retire_lat);
213+
t->last = sample->weight3;
214+
update_stats(&t->stats, sample->weight3);
215215
mutex_unlock(tpebs_mtx_get());
216216
return 0;
217217
}

0 commit comments

Comments
 (0)