perf test: Test case 27 fails on s390 and non-x86 platforms
PATCH 1/1 perf test: Test case 27 fails on s390 and non-x86 platforms
Executing perf test 27 fails on s390:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: FAILED!
[root@t35lp46 perf]#
The root cause is
commit c7444297fd3769 ("perf test: Support PERF_SAMPLE_WEIGHT_STRUCT") This commit introduced a test case for PERF_SAMPLE_WEIGHT_STRUCT but does not adjust non-x86 weak linkage functions.
The error is in test__sample_parsing() --> do_test()
Function do_test() defines two structures of type struct perf_sample named sample and sample_out. The first sets member sample.ins_lat = 117
Structure sample_out is constructed dynamically using functions perf_event__synthesize_sample() and evsel__parse_sample(). Both functions have an x86 specific function version which sets member ins_lat. The weak common functions do not set member ins_lat.
Later in function samples_same() both data in variable sample and sample_out are compared. The comparison fails because sample.ins_lat is 117 and samples_out.ins_lat is 0, the weak functions never set member ins_lat.
Output after:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: Ok
[root@t35lp46 perf]#
Fixes:
commit c7444297fd3769 ("perf test: Support PERF_SAMPLE_WEIGHT_STRUCT")
--- tools/perf/util/evsel.c | 8 +++++--- tools/perf/util/synthetic-events.c | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-)
tools/perf/util/evsel.c +5 -3
@@ -2106,10 +2106,12 @@ perf_event__check_size(union perf_event *event, unsigned int sample_size) }void __weak arch_perf_parse_sample_weight (struct perf_sample *data, -const __u64 *array, -u64 type__maybe_unused ) +const __u64 *array,u64 type) { - data->weight = *array; +if (type &PERF_SAMPLE_WEIGHT ) + data->weight = *array &0xffffffff ; +if (type &PERF_SAMPLE_WEIGHT_STRUCT ) + data->ins_lat = (*array >>32 ) &0xffff ; } int evsel__parse_sample(struct evsel *evsel, union perf_event *event,
tools/perf/util/synthetic-events.c +5 -1
@@ -1507,9 +1507,13 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, }void __weak arch_perf_synthesize_sample_weight (const struct perf_sample *data, -__u64 *array,u64 type__maybe_unused ) +__u64 *array,u64 type) { *array = data->weight; +if (type &PERF_SAMPLE_WEIGHT_STRUCT ) { + *array &=0xffffffff ; + *array |= ((u64 )data->ins_lat <<32 ); + } } int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format,
Signature · 1 line
2.29.2
+ Athira Rajeev
Quoted 13 lines · Thomas Richter
Executing perf test 27 fails on s390:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: FAILED!
[root@t35lp46 perf]#The root cause is
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT") This commit introduced a test case forPERF_SAMPLE_WEIGHT_STRUCTbut does not adjust non-x86 weak linkage functions.
Quoted 9 lines
The error is in
test__sample_parsing()-->do_test()
Functiondo_test()defines two structures of type structperf_samplenamed sample andsample_out. The first sets member sample.ins_lat = 117Structure
sample_outis constructed dynamically using functionsperf_event__synthesize_sample()andevsel__parse_sample(). Both functions have an x86 specific function version which sets memberins_lat. The weak common functions do not set memberins_lat.
I don't think Power supports the instruction latency. As a request from Athira Rajeev, I moved the PERF_SAMPLE_WEIGHT_STRUCT to the X86 specific codes.
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/
I don't think we want to add the ins_lat back in the weak common functions.
Could you please update the perf test and don't apply the PERF_SAMPLE_WEIGHT_STRUCT for the non-X86 platform?
Quoted 12 lines
Later in function
samples_same()both data in variable sample andsample_outare compared. The comparison fails because sample.ins_lat is 117 and samples_out.ins_lat is 0, the weak functions never set memberins_lat.Output after:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: Ok
[root@t35lp46 perf]#
Quoted 2 lines
Fixes:
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT")
I think the regression should start from
commit fbefe9c2f87f ("perf tools: Support arch specific PERF_SAMPLE_WEIGHT_STRUCT processing")
Thanks,
Kan
Quoted 47 lines
Signed-off-by Thomas Richter <[email protected]>--- tools/perf/util/evsel.c | 8 +++++--- tools/perf/util/synthetic-events.c | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-)tools/perf/util/evsel.c +5
-3@@ -2106,10 +2106,12 @@ perf_event__check_size(union perf_event *event, unsigned int sample_size) }void __weak arch_perf_parse_sample_weight (struct perf_sample *data, -const __u64 *array, -u64 type__maybe_unused ) +const __u64 *array,u64 type) { - data->weight = *array; +if (type &PERF_SAMPLE_WEIGHT ) + data->weight = *array &0xffffffff ; +if (type &PERF_SAMPLE_WEIGHT_STRUCT ) + data->ins_lat = (*array >>32 ) &0xffff ; } int evsel__parse_sample(struct evsel *evsel, union perf_event *event,tools/perf/util/synthetic-events.c +5
-1@@ -1507,9 +1507,13 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, }void __weak arch_perf_synthesize_sample_weight (const struct perf_sample *data, -__u64 *array,u64 type__maybe_unused ) +__u64 *array,u64 type) { *array = data->weight; +if (type &PERF_SAMPLE_WEIGHT_STRUCT ) { + *array &=0xffffffff ; + *array |= ((u64 )data->ins_lat <<32 ); + } } int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format,
Quoted 27 lines · Kan
+ Athira Rajeev
Quoted 13 lines · Thomas Richter
Executing perf test 27 fails on s390:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: FAILED!
[root@t35lp46 perf]#The root cause is
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT") This commit introduced a test case forPERF_SAMPLE_WEIGHT_STRUCTbut does not adjust non-x86 weak linkage functions.Quoted 9 lines
The error is in
test__sample_parsing()-->do_test()
Functiondo_test()defines two structures of type structperf_samplenamed sample andsample_out. The first sets member sample.ins_lat = 117Structure
sample_outis constructed dynamically using functionsperf_event__synthesize_sample()andevsel__parse_sample(). Both functions have an x86 specific function version which sets memberins_lat. The weak common functions do not set memberins_lat.
Quoted 7 lines
I don't think Power supports the instruction latency. As a request from Athira Rajeev, I moved the
PERF_SAMPLE_WEIGHT_STRUCTto the X86 specific codes.
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/I don't think we want to add the
ins_latback in the weak common functions.Could you please update the perf test and don't apply the
PERF_SAMPLE_WEIGHT_STRUCTfor the non-X86 platform?
I used offical linux git tree
[root@t35lp46 perf]# git tag | fgrep 5.12
v5.12-rc1
[root@t35lp46 perf]#
So this change is in the pipe. I do not plan to revert individual patches.
Quoted 17 lines
Quoted 14 lines
Later in function
samples_same()both data in variable sample andsample_outare compared. The comparison fails because sample.ins_lat is 117 and samples_out.ins_lat is 0, the weak functions never set memberins_lat.Output after:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: Ok
[root@t35lp46 perf]#Quoted 2 lines
Fixes:
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT")
Quoted 6 lines
I think the regression should start from
commitfbefe9c2f87f("perf tools: Support arch specificPERF_SAMPLE_WEIGHT_STRUCTprocessing")Thanks,
Kan
Kan,
I do not follow you. Your commit c7444297fd3769d10c7ffb52c81d71503b3e268f adds this line
@@ -242,6 +245,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)
.cgroup = 114,
.data_page_size = 115,
.code_page_size = 116,+ .ins_lat = 117,
And this assignment 117 breaks the test. As mentioned before, member ins_lat is never touched by the weak functions.
Signature · 5 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Quoted 34 lines · Thomas Richter
Quoted 33 lines · Kan
+ Athira Rajeev
Quoted 13 lines · Thomas Richter
Executing perf test 27 fails on s390:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: FAILED!
[root@t35lp46 perf]#The root cause is
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT") This commit introduced a test case forPERF_SAMPLE_WEIGHT_STRUCTbut does not adjust non-x86 weak linkage functions.Quoted 9 lines
The error is in
test__sample_parsing()-->do_test()
Functiondo_test()defines two structures of type structperf_samplenamed sample andsample_out. The first sets member sample.ins_lat = 117Structure
sample_outis constructed dynamically using functionsperf_event__synthesize_sample()andevsel__parse_sample(). Both functions have an x86 specific function version which sets memberins_lat. The weak common functions do not set memberins_lat.I don't think Power supports the instruction latency. As a request from Athira Rajeev, I moved the
PERF_SAMPLE_WEIGHT_STRUCTto the X86 specific codes.
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/I don't think we want to add the
ins_latback in the weak common functions.
Quoted 8 lines
Quoted 1 line
Could you please update the perf test and don't apply the
PERF_SAMPLE_WEIGHT_STRUCTfor the non-X86 platform?I used offical linux git tree
[root@t35lp46 perf]# git tag | fgrep 5.12
v5.12-rc1
[root@t35lp46 perf]#So this change is in the pipe. I do not plan to revert individual patches.
No, we shouldn't revert the patch.
I mean can you fix the issue in perf test?
Don't test ins_lat or PERF_SAMPLE_WEIGHT_STRUCT for a non-X86 platform.
Quoted 35 lines
Quoted 17 lines
Quoted 14 lines
Later in function
samples_same()both data in variable sample andsample_outare compared. The comparison fails because sample.ins_lat is 117 and samples_out.ins_lat is 0, the weak functions never set memberins_lat.Output after:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: Ok
[root@t35lp46 perf]#Quoted 2 lines
Fixes:
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT")Quoted 6 lines
I think the regression should start from
commitfbefe9c2f87f("perf tools: Support arch specificPERF_SAMPLE_WEIGHT_STRUCTprocessing")Thanks,
KanKan,
I do not follow you. Your commit
c7444297fd3769d10c7ffb52c81d71503b3e268fadds this line(quoted diff) +1
-0@@ -242,6 +245,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .cgroup = 114, .data_page_size = 115, .code_page_size = 116, + .ins_lat = 117,
Quoted 3 lines
And this assignment 117 breaks the test. As mentioned before, member
ins_latis never touched by the weak functions.
Here is the timeline for the patches.
1. The commit c7444297fd3769 and other SPR patches are merged at 2021-02-08. At that time, I don't think we have this issue. perf test should work well.
2. Athira Rajeev told me that Power doesn't support instruction latency. So I submitted a patch which create weak functions and move the ins_lat into X86 specific.
3. The patch (commit fbefe9c2f87f) was finally merged at 2021-02-18. We should observe the perf test at this time.
As my understanding, "Fixes" should log the commit where an issue starts to be observed. If someone tries to backport the fix later, they have an idea where to put it.
Thanks,
Kan
Quoted 44 lines · Kan
Quoted 41 lines · Thomas Richter
Quoted 27 lines · Kan
+ Athira Rajeev
Quoted 13 lines · Thomas Richter
Executing perf test 27 fails on s390:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: FAILED!
[root@t35lp46 perf]#The root cause is
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT") This commit introduced a test case forPERF_SAMPLE_WEIGHT_STRUCTbut does not adjust non-x86 weak linkage functions.Quoted 9 lines
The error is in
test__sample_parsing()-->do_test()
Functiondo_test()defines two structures of type structperf_samplenamed sample andsample_out. The first sets member sample.ins_lat = 117Structure
sample_outis constructed dynamically using functionsperf_event__synthesize_sample()andevsel__parse_sample(). Both functions have an x86 specific function version which sets memberins_lat. The weak common functions do not set memberins_lat.Quoted 7 lines
I don't think Power supports the instruction latency. As a request from Athira Rajeev, I moved the
PERF_SAMPLE_WEIGHT_STRUCTto the X86 specific codes.
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/I don't think we want to add the
ins_latback in the weak common functions.Could you please update the perf test and don't apply the
PERF_SAMPLE_WEIGHT_STRUCTfor the non-X86 platform?I used offical linux git tree
[root@t35lp46 perf]# git tag | fgrep 5.12
v5.12-rc1
[root@t35lp46 perf]#
Quoted 5 lines
Quoted 1 line
So this change is in the pipe. I do not plan to revert individual patches.
No, we shouldn't revert the patch.
I mean can you fix the issue in perf test?
Don't testins_latorPERF_SAMPLE_WEIGHT_STRUCTfor a non-X86 platform.
That would be very ugly code. We would end up in conditional compiles like #ifdef __s390x__
#endif
and other architectes like ARM/POWER etc come along. This is something I want to avoid.
And this fix only touches perf, not the kernel.
Quoted 35 lines
Quoted 35 lines
Quoted 17 lines
Quoted 14 lines
Later in function
samples_same()both data in variable sample andsample_outare compared. The comparison fails because sample.ins_lat is 117 and samples_out.ins_lat is 0, the weak functions never set memberins_lat.Output after:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: Ok
[root@t35lp46 perf]#Quoted 2 lines
Fixes:
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT")Quoted 6 lines
I think the regression should start from
commitfbefe9c2f87f("perf tools: Support arch specificPERF_SAMPLE_WEIGHT_STRUCTprocessing")Thanks,
KanKan,
I do not follow you. Your commit
c7444297fd3769d10c7ffb52c81d71503b3e268fadds this line(quoted diff) +1
-0@@ -242,6 +245,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .cgroup = 114, .data_page_size = 115, .code_page_size = 116, + .ins_lat = 117,
Quoted 7 lines
Quoted 3 lines
And this assignment 117 breaks the test. As mentioned before, member
ins_latis never touched by the weak functions.Here is the timeline for the patches.
1. The commit
c7444297fd3769and other SPR patches are merged at 2021-02-08. At that time, I don't think we have this issue. perf test should work well.
Nope, that line above 'ins_lat = 117.' breaks the test. Comment it out and it works well!!! That function do_test() is common code executed on all architectures. Take it out and it is tested nowhere.
The whole purpose of this test test__sample_parsing() --> do_test() is to convert a perf_sample structure into the perf_event structure and back again. The test checks if this convertion works in both directions. See perf_event__synthesize_sample() which flattens an perf_sample structure named sample into an byte stream. Function evsel__parse_sample() takes that byte stream and creates a struct perf_sample named sample_out.perf_event__synthesize_sample() has as input sample.ins_lat with value 117. And evsel__parse_sample() creates samples_out with sample_out.ins_lat value 0. So the test breaks. Thats why we need to set ins_lat in both functions.
Quoted 3 lines
2. Athira Rajeev told me that Power doesn't support instruction latency. So I submitted a patch which create weak functions and move the
ins_latinto X86 specific.
3. The patch (commitfbefe9c2f87f) was finally merged at 2021-02-18. We should observe the perf test at this time.
I just looked at this patch.
As far I as understand the code, the weak functions just set sample member weight and do not touch member ins_lat. Sample member weight is a 64 bit value.
It is used when sample_type has bit PERF_SAMPLE_WEIGHT set.
What we need is sample member ins_lat being set. This is the case when sample_type has bit PERF_SAMPLE_WEIGHT_STRUCT set. On x86 the sample member weight is split into a lower 32bit value containing weight value and an upper 32 bit value containing ins_lat value. x86 hardware obviously does not provide larger values.
We need to do the same for non_x86 platforms. Otherwise member ins_lat is never set and the test fails. Since the weak functions are only called when architecture specific functions are not available, that hardware is not there to support this. So why don't we use this
procedure when we run into the weak functions where is is no hardware support anyway???
Quoted 5 lines
As my understanding, "Fixes" should log the commit where an issue starts to be observed. If someone tries to backport the fix later, they have an idea where to put it.
Thanks,
Kan
Thanks Thomas
Signature · 5 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Quoted 47 lines · Thomas Richter
Quoted 46 lines · Kan
Quoted 42 lines · Thomas Richter
Quoted 27 lines · Kan
+ Athira Rajeev
Quoted 13 lines · Thomas Richter
Executing perf test 27 fails on s390:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: FAILED!
[root@t35lp46 perf]#The root cause is
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT") This commit introduced a test case forPERF_SAMPLE_WEIGHT_STRUCTbut does not adjust non-x86 weak linkage functions.Quoted 9 lines
The error is in
test__sample_parsing()-->do_test()
Functiondo_test()defines two structures of type structperf_samplenamed sample andsample_out. The first sets member sample.ins_lat = 117Structure
sample_outis constructed dynamically using functionsperf_event__synthesize_sample()andevsel__parse_sample(). Both functions have an x86 specific function version which sets memberins_lat. The weak common functions do not set memberins_lat.Quoted 7 lines
I don't think Power supports the instruction latency. As a request from Athira Rajeev, I moved the
PERF_SAMPLE_WEIGHT_STRUCTto the X86 specific codes.
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/I don't think we want to add the
ins_latback in the weak common functions.Could you please update the perf test and don't apply the
PERF_SAMPLE_WEIGHT_STRUCTfor the non-X86 platform?I used offical linux git tree
[root@t35lp46 perf]# git tag | fgrep 5.12
v5.12-rc1
[root@t35lp46 perf]#So this change is in the pipe. I do not plan to revert individual patches.
Quoted 9 lines
Quoted 3 lines
No, we shouldn't revert the patch.
I mean can you fix the issue in perf test?
Don't testins_latorPERF_SAMPLE_WEIGHT_STRUCTfor a non-X86 platform.That would be very ugly code. We would end up in conditional compiles like #ifdef
__s390x__
#endif
and other architectes like ARM/POWER etc come along. This is something I want to avoid.
The ins_lat is a model specific variable. Maybe we should move it to the arch specific test.
Quoted 1 line
And this fix only touches perf, not the kernel.
The patch changes the behavior of the PERF_SAMPLE_WEIGHT. The high 32 bit will be dropped. It should bring some problems if the high 32 bit contains valid information.
Quoted 42 lines
Quoted 42 lines
Quoted 36 lines
Quoted 18 lines
Quoted 15 lines
Later in function
samples_same()both data in variable sample andsample_outare compared. The comparison fails because sample.ins_lat is 117 and samples_out.ins_lat is 0, the weak functions never set memberins_lat.Output after:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: Ok
[root@t35lp46 perf]#Quoted 2 lines
Fixes:
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT")Quoted 6 lines
I think the regression should start from
commitfbefe9c2f87f("perf tools: Support arch specificPERF_SAMPLE_WEIGHT_STRUCTprocessing")Thanks,
KanKan,
I do not follow you. Your commit
c7444297fd3769d10c7ffb52c81d71503b3e268fadds this line(quoted diff) +1
-0@@ -242,6 +245,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .cgroup = 114, .data_page_size = 115, .code_page_size = 116, + .ins_lat = 117,Quoted 3 lines
And this assignment 117 breaks the test. As mentioned before, member
ins_latis never touched by the weak functions.Here is the timeline for the patches.
Quoted 3 lines
Quoted 1 line
1. The commit
c7444297fd3769and other SPR patches are merged at 2021-02-08. At that time, I don't think we have this issue. perf test should work well.Nope, that line above '
ins_lat= 117.' breaks the test. Comment it out and it works well!!!
If you revert the commit fbefe9c2f87f, perf test should work well too.
The root cause of the issue is that the commit fbefe9c2f87f change the ins_lat to a model-specific variable, but perf test still verify the variable in the generic test.
The below patch moves the PERF_SAMPLE_WEIGHT test into a X86 specific test.
Does it work for you?
--- tools/perf/arch/x86/include/arch-tests.h | 1 + tools/perf/arch/x86/tests/Build | 1 + tools/perf/arch/x86/tests/arch-tests.c | 4 + tools/perf/arch/x86/tests/sample-parsing.c | 125 +++++++++++++++++++++++++++++ tools/perf/tests/sample-parsing.c | 4 - 5 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 tools/perf/arch/x86/tests/sample-parsing.c
tools/perf/arch/x86/include/arch-tests.h +1 -0
@@ -10,6 +10,7 @@ int test__rdpmc(struct test *test __maybe_unused, int subtest);int test__insn_x86 (struct test *test__maybe_unused ,int subtest);int test__intel_pt_pkt_decoder (struct test *test,int subtest);int test__bp_modify (struct test *test,int subtest); +int test__x86_sample_parsing (struct test *test,int subtest);#ifdef HAVE_DWARF_UNWIND_SUPPORT struct thread ;
tools/perf/arch/x86/tests/Build +1 -0
@@ -3,5 +3,6 @@ perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o perf-y += arch-tests.o perf-y += rdpmc.o +perf-y += sample-parsing.o perf-$(CONFIG_AUXTRACE) += insn-x86.o intel-pt-pkt-decoder-test.o perf-$(CONFIG_X86_64) += bp-modify.o
tools/perf/arch/x86/tests/arch-tests.c +4 -0
@@ -31,6 +31,10 @@ struct test arch_tests[] = { },#endif { + .desc = "x86 Sample parsing", + .func = test__x86_sample_parsing, + }, + { .func = NULL, },
tools/perf/arch/x86/tests/sample-parsing.c new file +116 -0
116 lines not on this page · raw message
The test
+ * checks sample format bits separately and together. If the test passes %0 is
+ * returned, otherwise %-1 is returned.
+ *
+ * For now, PERF_SAMPLE_WEIGHT_STRUCT is the only X86 specific sample type.
+ */
+int test__x86_sample_parsing(struct test *test __maybe_unused, int subtest __maybe_unused) +{
+ return do_test(PERF_SAMPLE_WEIGHT_STRUCT, 0);
+}
tools/perf/tests/sample-parsing.c +0 -4
@@ -129,9 +129,6 @@ static bool samples_same(const struct perf_sample *s1,if (type &PERF_SAMPLE_WEIGHT )COMP (weight); -if (type &PERF_SAMPLE_WEIGHT_STRUCT ) -COMP (ins_lat); -if (type &PERF_SAMPLE_DATA_SRC )COMP (data_src);
@@ -245,7 +242,6 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .cgroup = 114, .data_page_size = 115, .code_page_size = 116, - .ins_lat = 117, .aux_sample = { .size = sizeof(aux_data), .data = (void *)aux_data,
Signature · 5 lines
2.7.4 Thanks, Kan
Quoted 39 lines · Kan
Quoted 32 lines · Thomas Richter
Quoted 31 lines · Kan
Quoted 28 lines · Thomas Richter
Quoted 27 lines · Kan
+ Athira Rajeev
Quoted 22 lines · Thomas Richter
Executing perf test 27 fails on s390:
[root@t35lp46 perf]# ./perf test -Fv 27 27: Sample parsing --- start --- ---- end ---- Sample parsing: FAILED! [root@t35lp46 perf]#The root cause is
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT") This commit introduced a test case forPERF_SAMPLE_WEIGHT_STRUCTbut does not adjust non-x86 weak linkage functions.The error is in
test__sample_parsing()-->do_test()
Functiondo_test()defines two structures of type structperf_samplenamed sample andsample_out. The first sets member sample.ins_lat = 117Structure
sample_outis constructed dynamically using functionsperf_event__synthesize_sample()andevsel__parse_sample(). Both functions have an x86 specific function version which sets memberins_lat. The weak common functions do not set memberins_lat.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
I don't think Power supports the instruction latency. As a request from Athira Rajeev, I moved the
PERF_SAMPLE_WEIGHT_STRUCTto the X86 specific codes.
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/I don't think we want to add the
ins_latback in the weak common functions.
Hi Kan Liang,
Yes, presently in powerpc we are not using PERF_SAMPLE_WEIGHT_STRUCT.
But I am working on a patch set to expose some of the pipeline stalls details using PERF_SAMPLE_WEIGHT_STRUCT,
by using the two 16-bit fields of sample weight. I could use the same "ins_lat" field and then use an arch specific header string while displaying with "perf report”. I will be sharing an RFC patch on this soon.
But I believe it is good to keep the weak function "arch_perf_parse_sample_weight" if we want to create different field for 'weight->var2_w' in future.
Thanks
Athira
Quoted 283 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
Could you please update the perf test and don't apply the
PERF_SAMPLE_WEIGHT_STRUCTfor the non-X86 platform?I used offical linux git tree
[root@t35lp46 perf]# git tag | fgrep 5.12
v5.12-rc1
[root@t35lp46 perf]#So this change is in the pipe. I do not plan to revert individual patches.
Quoted 7 lines
Quoted 3 lines
No, we shouldn't revert the patch.
I mean can you fix the issue in perf test?
Don't testins_latorPERF_SAMPLE_WEIGHT_STRUCTfor a non-X86 platform.That would be very ugly code. We would end up in conditional compiles like #ifdef
__s390x__
#endif
and other architectes like ARM/POWER etc come along. This is something I want to avoid.The
ins_latis a model specific variable. Maybe we should move it to the arch specific test.Quoted 1 line
And this fix only touches perf, not the kernel.
The patch changes the behavior of the
PERF_SAMPLE_WEIGHT. The high 32 bit will be dropped. It should bring some problems if the high 32 bit contains valid information.Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 17 lines
Quoted 12 lines
Later in function
samples_same()both data in variable sample andsample_outare compared. The comparison fails because sample.ins_lat is 117 and samples_out.ins_lat is 0, the weak functions never set memberins_lat.Output after:
[root@t35lp46 perf]# ./perf test -Fv 27 27: Sample parsing --- start --- ---- end ---- Sample parsing: OkQuoted 4 lines
[root@t35lp46 perf]#
Fixes:
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT")Quoted 6 lines
I think the regression should start from
commitfbefe9c2f87f("perf tools: Support arch specificPERF_SAMPLE_WEIGHT_STRUCTprocessing")Thanks,
KanKan,
I do not follow you. Your commit
c7444297fd3769d10c7ffb52c81d71503b3e268fadds this linetools/perf/tests/sample-parsing.c +1
-0@@ -242,6 +245,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .cgroup = 114, .data_page_size = 115, .code_page_size = 116, + .ins_lat = 117,Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
And this assignment 117 breaks the test. As mentioned before, member
ins_latis never touched by the weak functions.Here is the timeline for the patches.
1. The commit
c7444297fd3769and other SPR patches are merged at 2021-02-08. At that time, I don't think we have this issue. perf test should work well.Nope, that line above '
ins_lat= 117.' breaks the test. Comment it out and it works well!!!If you revert the commit
fbefe9c2f87f, perf test should work well too.The root cause of the issue is that the commit
fbefe9c2f87fchange theins_latto a model-specific variable, but perf test still verify the variable in the generic test.The below patch moves the
PERF_SAMPLE_WEIGHTtest into a X86 specific test.Does it work for you?
---
tools/perf/arch/x86/include/arch-tests.h | 1 + tools/perf/arch/x86/tests/Build | 1 + tools/perf/arch/x86/tests/arch-tests.c | 4 + tools/perf/arch/x86/tests/sample-parsing.c | 125 +++++++++++++++++++++++++++++ tools/perf/tests/sample-parsing.c | 4 - 5 files changed, 131 insertions(+), 4 deletions(-)create mode 100644
tools/perf/arch/x86/tests/sample-parsing.ctools/perf/arch/x86/include/arch-tests.h +1
-0@@ -10,6 +10,7 @@ int test__rdpmc(struct test *test __maybe_unused, int subtest);int test__insn_x86 (struct test *test__maybe_unused ,int subtest);int test__intel_pt_pkt_decoder (struct test *test,int subtest);int test__bp_modify (struct test *test,int subtest); +int test__x86_sample_parsing (struct test *test,int subtest);#ifdef HAVE_DWARF_UNWIND_SUPPORT struct thread ;tools/perf/arch/x86/tests/Build +0
-0@@ -3,5 +3,6 @@ perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.operf-y += arch-tests.o
perf-y += rdpmc.o
+perf-y += sample-parsing.o
perf-$(CONFIG_AUXTRACE) += insn-x86.o intel-pt-pkt-decoder-test.o perf-$(CONFIG_X86_64) += bp-modify.otools/perf/arch/x86/tests/arch-tests.c +4
-0@@ -31,6 +31,10 @@ struct test arch_tests[] = { },#endif { + .desc = "x86 Sample parsing", + .func = test__x86_sample_parsing, + }, + { .func = NULL, },tools/perf/arch/x86/tests/sample-parsing.c new file +125
-0@@ -0,0 +1,125 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <stdbool.h> +#include <inttypes.h> +#include <stdlib.h> +#include <string.h> +#include <linux/bitops.h> +#include <linux/kernel.h> +#include <linux/types.h> + +#include "map_symbol.h" +#include "branch.h" +#include "event.h" +#include "evsel.h" +#include "debug.h" +#include "util/synthetic-events.h" + +#include "tests/tests.h" +#include "arch-tests.h" + +#define COMP (m) do { \ + if (s1->m != s2->m) { \ + pr_debug("Samples differ at '"#m"'\n"); \ + return false; \ + } \ +} while (0) + +static bool samples_same (const struct perf_sample *s1, +const struct perf_sample *s2, +u64 type) +{ +if (type &PERF_SAMPLE_WEIGHT_STRUCT ) +COMP (ins_lat); + +return true; +} + +static int do_test (u64 sample_type,u64 read_format) +{ +struct evsel evsel = { + .needs_swap = false, + .core = { + . attr = { + .sample_type = sample_type, + .read_format = read_format, + }, + }, + }; +union perf_event *event; +struct perf_sample sample = { + .weight =101 , + .ins_lat =102 , + }; +struct perf_sample sample_out; +size_t i, sz, bufsz; +int err, ret =-1 ; + + sz =perf_event__sample_event_size (&sample, sample_type, read_format); + bufsz = sz +4096 ;/* Add a bit for overrun checking */ + event =malloc (bufsz); +if (!event) { +pr_debug ("malloc failed\n" ); +return -1 ; + } + +memset (event,0xff , bufsz); + event->header.type =PERF_RECORD_SAMPLE ; + event->header.misc =0 ; + event->header.size = sz; + + err =perf_event__synthesize_sample (event, sample_type, read_format, + &sample); +if (err) { +pr_debug ("%s failed for sample_type %#" PRIx64", error %d\n" , +"perf_event__synthesize_sample" , sample_type, err); + goto out_free; + } + +/* The data does not contain 0xff so we use that to check the size */ +for (i = bufsz; i >0 ; i--) { +if (*(i -1 + (u8 *)event) !=0xff ) +break ; + } +if (i != sz) { +pr_debug ("Event size mismatch: actual %zu vs expected %zu\n" , + i, sz); + goto out_free; + } + + evsel.sample_size =__evsel__sample_size (sample_type); + + err =evsel__parse_sample (&evsel, event, &sample_out); +if (err) { +pr_debug ("%s failed for sample_type %#" PRIx64", error %d\n" , +"evsel__parse_sample" , sample_type, err); + goto out_free; + } + +if (!samples_same (&sample, &sample_out, sample_type)) { +pr_debug ("parsing failed for sample_type %#" PRIx64"\n" , + sample_type); + goto out_free; + } + + ret =0 ; +out_free: +free (event); +if (ret && read_format) +pr_debug ("read_format %#" PRIx64"\n" , read_format); +return ret; +} + +/** +* test__x86_sample_parsing - test X86 specific sample parsing +* +* This function implements a test that synthesizes a sample event, parses it +* and then checks that the parsed sample matches the original sample. The test +* checks sample format bits separately and together. If the test passes %0 is +* returned, otherwise %-1 is returned. +* +* For now, PERF_SAMPLE_WEIGHT_STRUCT is the only X86 specific sample type. +*/ +int test__x86_sample_parsing (struct test *test__maybe_unused ,int subtest__maybe_unused ) +{ +return do_test (PERF_SAMPLE_WEIGHT_STRUCT ,0 ); +}tools/perf/tests/sample-parsing.c +0
-4@@ -129,9 +129,6 @@ static bool samples_same(const struct perf_sample *s1,if (type &PERF_SAMPLE_WEIGHT )COMP (weight); -if (type &PERF_SAMPLE_WEIGHT_STRUCT ) -COMP (ins_lat); -if (type &PERF_SAMPLE_DATA_SRC )COMP (data_src);@@ -245,7 +242,6 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .cgroup = 114, .data_page_size = 115, .code_page_size = 116, - .ins_lat = 117, .aux_sample = { .size = sizeof(aux_data), .data = (void *)aux_data,Signature · 5 lines
2.7.4 Thanks, Kan
Quoted 314 lines · Kan
Quoted 47 lines · Thomas Richter
Quoted 46 lines · Kan
Quoted 42 lines · Thomas Richter
Quoted 27 lines · Kan
+ Athira Rajeev
Quoted 13 lines · Thomas Richter
Executing perf test 27 fails on s390:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: FAILED!
[root@t35lp46 perf]#The root cause is
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT") This commit introduced a test case forPERF_SAMPLE_WEIGHT_STRUCTbut does not adjust non-x86 weak linkage functions.Quoted 9 lines
The error is in
test__sample_parsing()-->do_test()
Functiondo_test()defines two structures of type structperf_samplenamed sample andsample_out. The first sets member sample.ins_lat = 117Structure
sample_outis constructed dynamically using functionsperf_event__synthesize_sample()andevsel__parse_sample(). Both functions have an x86 specific function version which sets memberins_lat. The weak common functions do not set memberins_lat.Quoted 7 lines
I don't think Power supports the instruction latency. As a request from Athira Rajeev, I moved the
PERF_SAMPLE_WEIGHT_STRUCTto the X86 specific codes.
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/I don't think we want to add the
ins_latback in the weak common functions.Could you please update the perf test and don't apply the
PERF_SAMPLE_WEIGHT_STRUCTfor the non-X86 platform?I used offical linux git tree
[root@t35lp46 perf]# git tag | fgrep 5.12
v5.12-rc1
[root@t35lp46 perf]#So this change is in the pipe. I do not plan to revert individual patches.
Quoted 9 lines
Quoted 3 lines
No, we shouldn't revert the patch.
I mean can you fix the issue in perf test?
Don't testins_latorPERF_SAMPLE_WEIGHT_STRUCTfor a non-X86 platform.That would be very ugly code. We would end up in conditional compiles like #ifdef
__s390x__
#endif
and other architectes like ARM/POWER etc come along. This is something I want to avoid.The
ins_latis a model specific variable. Maybe we should move it to the arch specific test.Quoted 1 line
And this fix only touches perf, not the kernel.
The patch changes the behavior of the
PERF_SAMPLE_WEIGHT. The high 32 bit will be dropped. It should bring some problems if the high 32 bit contains valid information.Quoted 42 lines
Quoted 42 lines
Quoted 36 lines
Quoted 18 lines
Quoted 15 lines
Later in function
samples_same()both data in variable sample andsample_outare compared. The comparison fails because sample.ins_lat is 117 and samples_out.ins_lat is 0, the weak functions never set memberins_lat.Output after:
[root@t35lp46 perf]# ./perf test -Fv 27
27: Sample parsing
--- start ---
---- end ----
Sample parsing: Ok
[root@t35lp46 perf]#Quoted 2 lines
Fixes:
commitc7444297fd3769("perf test: SupportPERF_SAMPLE_WEIGHT_STRUCT")Quoted 6 lines
I think the regression should start from
commitfbefe9c2f87f("perf tools: Support arch specificPERF_SAMPLE_WEIGHT_STRUCTprocessing")Thanks,
KanKan,
I do not follow you. Your commit
c7444297fd3769d10c7ffb52c81d71503b3e268fadds this linetools/perf/tests/sample-parsing.c +1
-0@@ -242,6 +245,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .cgroup = 114, .data_page_size = 115, .code_page_size = 116, + .ins_lat = 117,Quoted 3 lines
And this assignment 117 breaks the test. As mentioned before, member
ins_latis never touched by the weak functions.Here is the timeline for the patches.
Quoted 3 lines
Quoted 1 line
1. The commit
c7444297fd3769and other SPR patches are merged at 2021-02-08. At that time, I don't think we have this issue. perf test should work well.Nope, that line above '
ins_lat= 117.' breaks the test. Comment it out and it works well!!!If you revert the commit
fbefe9c2f87f, perf test should work well too.The root cause of the issue is that the commit
fbefe9c2f87fchange theins_latto a model-specific variable, but perf test still verify the variable in the generic test.The below patch moves the
PERF_SAMPLE_WEIGHTtest into a X86 specific test.Does it work for you?
---
tools/perf/arch/x86/include/arch-tests.h | 1 + tools/perf/arch/x86/tests/Build | 1 + tools/perf/arch/x86/tests/arch-tests.c | 4 +tools/perf/arch/x86/tests/sample-parsing.c| 125 +++++++++++++++++++++++++++++ tools/perf/tests/sample-parsing.c | 4 -5 files changed, 131 insertions(+), 4 deletions(-)create mode 100644
tools/perf/arch/x86/tests/sample-parsing.ctools/perf/arch/x86/include/arch-tests.h +1
-0@@ -10,6 +10,7 @@ int test__rdpmc(struct test *test __maybe_unused, int subtest); int test__insn_x86(struct test *test __maybe_unused, int subtest); int test__intel_pt_pkt_decoder(struct test *test, int subtest); int test__bp_modify(struct test *test, int subtest); +int test__x86_sample_parsing (struct test *test,int subtest); #ifdef HAVE_DWARF_UNWIND_SUPPORT struct thread;tools/perf/arch/x86/tests/Build +0
-0@@ -3,5 +3,6 @@ perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.operf-y += arch-tests.o
perf-y += rdpmc.o
+perf-y += sample-parsing.o
perf-$(CONFIG_AUXTRACE) += insn-x86.o intel-pt-pkt-decoder-test.o perf-$(CONFIG_X86_64) += bp-modify.otools/perf/arch/x86/tests/arch-tests.c +4
-0@@ -31,6 +31,10 @@ struct test arch_tests[] = { }, #endif { + .desc = "x86 Sample parsing", + .func = test__x86_sample_parsing, + }, + { .func = NULL, },tools/perf/arch/x86/tests/sample-parsing.c new file +125
-0@@ -0,0 +1,125 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <stdbool.h> +#include <inttypes.h> +#include <stdlib.h> +#include <string.h> +#include <linux/bitops.h> +#include <linux/kernel.h> +#include <linux/types.h> + +#include "map_symbol.h" +#include "branch.h" +#include "event.h" +#include "evsel.h" +#include "debug.h" +#include "util/synthetic-events.h" + +#include "tests/tests.h" +#include "arch-tests.h" + +#define COMP (m) do { \ + if (s1->m != s2->m) { \ + pr_debug("Samples differ at '"#m"'\n"); \ + return false; \ + } \ +} while (0) + +static bool samples_same (const struct perf_sample *s1, + const struct perf_sample *s2, + u64 type) +{ + if (type & PERF_SAMPLE_WEIGHT_STRUCT) + COMP(ins_lat); + + return true; +} + +static int do_test (u64 sample_type,u64 read_format) +{ + struct evsel evsel = { + .needs_swap = false, + .core = { + . attr = { + .sample_type = sample_type, + .read_format = read_format, + }, + }, + }; + union perf_event *event; + struct perf_sample sample = { + .weight = 101, + .ins_lat = 102, + }; + struct perf_sample sample_out; + size_t i, sz, bufsz; + int err, ret = -1; + + sz = perf_event__sample_event_size(&sample, sample_type, read_format); + bufsz = sz + 4096; /* Add a bit for overrun checking */ + event = malloc(bufsz); + if (!event) { + pr_debug("malloc failed\n"); + return -1; + } + + memset(event, 0xff, bufsz); + event->header.type = PERF_RECORD_SAMPLE; + event->header.misc = 0; + event->header.size = sz; + + err = perf_event__synthesize_sample(event, sample_type, read_format, + &sample); + if (err) { + pr_debug("%s failed for sample_type %#"PRIx64", error %d\n", + "perf_event__synthesize_sample", sample_type, err); + goto out_free; + } + + /* The data does not contain 0xff so we use that to check the size */ + for (i = bufsz; i > 0; i--) { + if (*(i - 1 + (u8 *)event) != 0xff) + break; + } + if (i != sz) { + pr_debug("Event size mismatch: actual %zu vs expected %zu\n", + i, sz); + goto out_free; + } + + evsel.sample_size = __evsel__sample_size(sample_type); + + err = evsel__parse_sample(&evsel, event, &sample_out); + if (err) { + pr_debug("%s failed for sample_type %#"PRIx64", error %d\n", + "evsel__parse_sample", sample_type, err); + goto out_free; + } + + if (!samples_same(&sample, &sample_out, sample_type)) { + pr_debug("parsing failed for sample_type %#"PRIx64"\n", + sample_type); + goto out_free; + } + + ret = 0; +out_free: + free(event); + if (ret && read_format) + pr_debug("read_format %#"PRIx64"\n", read_format); + return ret; +} + +/** +* test__x86_sample_parsing - test X86 specific sample parsing +* +* This function implements a test that synthesizes a sample event, parses it +* and then checks that the parsed sample matches the original sample. The test +* checks sample format bits separately and together. If the test passes %0 is +* returned, otherwise %-1 is returned. +* +* For now, PERF_SAMPLE_WEIGHT_STRUCT is the only X86 specific sample type. +*/ +int test__x86_sample_parsing (struct test *test__maybe_unused ,int subtest__maybe_unused ) +{ + return do_test(PERF_SAMPLE_WEIGHT_STRUCT, 0); +}tools/perf/tests/sample-parsing.c +0
-3@@ -129,9 +129,6 @@ static bool samples_same(const struct perf_sample *s1, if (type & PERF_SAMPLE_WEIGHT) COMP(weight); - if (type & PERF_SAMPLE_WEIGHT_STRUCT) - COMP(ins_lat); - if (type & PERF_SAMPLE_DATA_SRC) COMP(data_src);
tools/perf/tests/sample-parsing.c static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) · line 247
Quoted 7 lines
tools/perf/tests/sample-parsing.c +0
-1@@ -245,7 +242,6 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .cgroup = 114, .data_page_size = 115, .code_page_size = 116, - .ins_lat = 117, .aux_sample = { .size = sizeof(aux_data), .data = (void *)aux_data,
Thanks Kan,
I had several issues applying your patch:
(Stripping trailing CRs from patch; use --binary to disable.) patching file tools/perf/arch/x86/tests/sample-parsing.c
patch: **** malformed patch at line 421: parses it
...
[root@t35lp46 perf]# ./perf test -F 27
27: Sample parsing : Ok
[root@t35lp46 perf]#
But as you can see, after applying your patch, the test works fine on non-x86 platforms.
You have my Tested-by:
Please submit it to the mailing list.
Signature · 5 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294