Improvement and fixes for BHRB
v2 cover Improvement and fixes for BHRB
(1) The first patch fixes a situation like this
Before patch:-
------------
./perf record -j any -e branch-misses:k ls
Error:
The sys_perf_event_open() syscall returned with 95 (Operation not supported) for event (branch-misses:k). /bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?
Here 'perf record' actually copies over ':k' filter request into BHRB privilege state filter config and our previous check in kernel would fail that.
After patch:-
-------------
/perf record -j any -e branch-misses:k ls
perf perf.data perf.data.old test-mmap-ring
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.002 MB perf.data (~102 samples) ]
(2) The second patch fixes context migration for BHRB filter configuration
Changes in V2
-------------
(1) Updated the comment section of the code
(2) Removed the informational print
(3) Updated the commit section of the first patch
Anshuman Khandual (2):
powerpc, perf: Ignore separate BHRB privilege state filter request powerpc, perf: BHRB filter configuration should follow the task
arch/powerpc/perf/core-book3s.c | 5 ++++- arch/powerpc/perf/power8-pmu.c | 12 ++++-------- 2 files changed, 8 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.11.7
PATCH v2 1/2 powerpc, perf: Ignore separate BHRB privilege state filter request
Completely ignore BHRB privilege state filter request as we are already configuring that with privilege state filtering attribute for the accompanying PMU event. This would help achieve cleaner user space interaction for BHRB.
This patch fixes a situation like this
Before patch:-
------------
./perf record -j any -e branch-misses:k ls
Error:
The sys_perf_event_open() syscall returned with 95 (Operation not supported) for event (branch-misses:k). /bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?
Here 'perf record' actually copies over ':k' filter request into BHRB privilege state filter config and our previous check in kernel would fail that.
After patch:-
-------------
./perf record -j any -e branch-misses:k ls
perf perf.data perf.data.old test-mmap-ring
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.002 MB perf.data (~102 samples) ]
--- arch/powerpc/perf/power8-pmu.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/powerpc/perf/power8-pmu.c +4 -8
@@ -525,16 +525,12 @@ static u64 power8_bhrb_filter_map(u64 branch_sample_type)u64 pmu_bhrb_filter =0 ;u64 br_privilege = branch_sample_type &ONLY_PLM ; -/* BHRB and regular PMU events share the same prvillege state +/* BHRB and regular PMU events share the same privilege state * filter configuration. BHRB is always recorded along with a -* regular PMU event. So privilege state filter criteria for BHRB -* and the companion PMU events has to be the same. As a default -* "perf record" tool sets all privillege bits ON when no filter -* criteria is provided in the command line. So as along as all -* privillege bits are ON or they are OFF, we are good to go. +* regular PMU event. As the privilege state filter is handled +* in the basic PMC configuration of the accompanying regular +* PMU event, we ignore any separate BHRB specific request. */ -if ((br_privilege !=7 ) && (br_privilege !=0 )) -return -1 ;/* No branch filter requested */ if (branch_sample_type &PERF_SAMPLE_BRANCH_ANY )
Signature · 1 line
1.7.11.7
Re: [PATCH V2 1/2] powerpc, perf: Ignore separate BHRB privilege state filter request
Quoted 4 lines · Anshuman Khandual
Completely ignore BHRB privilege state filter request as we are already configuring that with privilege state filtering attribute for the accompanying PMU event. This would help achieve cleaner user space interaction for BHRB.
Quoted 8 lines
=20
This patch fixes a situation like this
=20
Before patch:-
------------
./perf record -j any -e branch-misses:k ls
Error:
Thesys_perf_event_open()syscall returned with 95 (Operation not support=
ed) for event (branch-misses:k).
arch/powerpc/perf/power8-pm=
Quoted 20 lines
/bin/dmesgmay provide additional information.
NoCONFIG_PERF_EVENTS=3Dykernel support configured?
=20
Here 'perf record' actually copies over ':k' filter request into BHRB privilege state filter config and our previous check in kernel would fail that.
=20
After patch:-
-------------
./perf record -j any -e branch-misses:k ls
perf perf.data perf.data.old test-mmap-ring
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.002 MB perf.data (~102 samples) ] =20Signed-off-by Anshuman Khandual <[email protected]>--- arch/powerpc/perf/power8-pmu.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)=20
arch/powerpc/perf/power8-pm= renamed from arch/powerpc/perf/power8-pmu.c +0
-0
u.c
arch/powerpc/perf/power8-pmu.c static u64 power8_bhrb_filter_map(u64 branch_sample=
Quoted 4 lines
index f7d1c4f..3a58416 100644
arch/powerpc/perf/power8-pmu.c +0
-0@@ -525,16 +525,12 @@ static u64 power8_bhrb_filter_map(u64 branch_sample=
_type)
Quoted 7 lines
arch/powerpc/perf/power8-pmu.c +0
-0u64 pmu_bhrb_filter =3D 0; u64 br_privilege =3D branch_sample_type & ONLY_PLM;=20=20
arch/powerpc/perf/power8-pmu.c +1
-2-/* BHRB and regular PMU events share the same prvillege state +/* BHRB and regular PMU events share the same privilege state * filter configuration. BHRB is always recorded along with a -* regular PMU event. So privilege state filter criteria for BHRB
arch/powerpc/perf/power8-pmu.c static u64 power8_bhrb_filter_map(u64 branch_sample_type) · line 537
Quoted 10 lines
arch/powerpc/perf/power8-pmu.c +3
-6-* and the companion PMU events has to be the same. As a default -* "perf record" tool sets all privillege bits ON when no filter -* criteria is provided in the command line. So as along as all -* privillege bits are ON or they are OFF, we are good to go. +* regular PMU event. As the privilege state filter is handled +* in the basic PMC configuration of the accompanying regular +* PMU event, we ignore any separate BHRB specific request. */ - if ((br_privilege !=3D 7) && (br_privilege !=3D 0)) -return -1 ;
br_privilege is now unused which causes this compile error.
arch/powerpc/perf/power8-pmu.c:526:6: error: unused variable =E2=80=98br_pr= ivilege=E2=80=99 [-Werror=3Dunused-variable]
I assume since you didn't compile test this code, you also didn't runtime test it either?!!?!?!?
Mikey
Quoted 11 lines
=20=20
arch/powerpc/perf/power8-pmu.c +0
-1/* No branch filter requested */ if (branch_sample_type &PERF_SAMPLE_BRANCH_ANY ) --=201.7.11.7
=20
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
=20
Re: [PATCH V2 1/2] powerpc, perf: Ignore separate BHRB privilege state filter request
Quoted 58 lines · Michael Neuling
Quoted 43 lines · Anshuman Khandual
Completely ignore BHRB privilege state filter request as we are already configuring that with privilege state filtering attribute for the accompanying PMU event. This would help achieve cleaner user space interaction for BHRB.
This patch fixes a situation like this
Before patch:-
------------
./perf record -j any -e branch-misses:k ls
Error:
Thesys_perf_event_open()syscall returned with 95 (Operation not supported) for event (branch-misses:k)./bin/dmesgmay provide additional information.
NoCONFIG_PERF_EVENTS=ykernel support configured?Here 'perf record' actually copies over ':k' filter request into BHRB privilege state filter config and our previous check in kernel would fail that.
After patch:-
-------------
./perf record -j any -e branch-misses:k ls
perf perf.data perf.data.old test-mmap-ring
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.002 MB perf.data (~102 samples) ]Signed-off-by Anshuman Khandual <[email protected]>--- arch/powerpc/perf/power8-pmu.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)arch/powerpc/perf/power8-pmu.c +1
-2@@ -525,16 +525,12 @@ static u64 power8_bhrb_filter_map(u64 branch_sample_type)u64 pmu_bhrb_filter =0 ;u64 br_privilege = branch_sample_type &ONLY_PLM ; -/* BHRB and regular PMU events share the same prvillege state +/* BHRB and regular PMU events share the same privilege state * filter configuration. BHRB is always recorded along with a -* regular PMU event. So privilege state filter criteria for BHRB arch/powerpc/perf/power8-pmu.c static u64 power8_bhrb_filter_map(u64 branch_sample_type) · line 537
Quoted 10 lines
arch/powerpc/perf/power8-pmu.c +3
-6-* and the companion PMU events has to be the same. As a default -* "perf record" tool sets all privillege bits ON when no filter -* criteria is provided in the command line. So as along as all -* privillege bits are ON or they are OFF, we are good to go. +* regular PMU event. As the privilege state filter is handled +* in the basic PMC configuration of the accompanying regular +* PMU event, we ignore any separate BHRB specific request. */ -if ((br_privilege !=7 ) && (br_privilege !=0 )) -return -1 ;
br_privilegeis now unused which causes this compile error.
Quoted 4 lines
arch/powerpc/perf/power8-pmu.c:526:6: error: unused variable ‘br_privilege’ [-Werror=unused-variable]I assume since you didn't compile test this code, you also didn't runtime test it either?!!?!?!?
Always compile with the cross compiler "ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make" I copied over arch/powerpc/config/pseries_defconfig and compiled it. Some how it missed to be a 64 bit kernel config which resulted in shutting down compilation of arch/powerpc/perf/power8-pmu.c file. So never encountered this compiler warning message before. Will fix this.
Regards
Anshuman
Re: [PATCH V2 1/2] powerpc, perf: Ignore separate BHRB privilege state filter request
Quoted 8 lines · Anshuman Khandual
Quoted 7 lines · Michael Neuling
Anshuman Khandual <[email protected]> wrote:
=20Quoted 5 lines
Completely ignore BHRB privilege state filter request as we are already configuring that with privilege state filtering attribute for the accompanying PMU event. This would help achieve cleaner user space interaction for BHRB.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
This patch fixes a situation like this
Before patch:-
------------
./perf record -j any -e branch-misses:k ls
Error:
Thesys_perf_event_open()syscall returned with 95 (Operation not supp=
orted) for event (branch-misses:k).
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
/bin/dmesgmay provide additional information. NoCONFIG_PERF_EVENTS=3Dykernel support configured?Here 'perf record' actually copies over ':k' filter request into BHRB privilege state filter config and our previous check in kernel would fail that.
After patch:-
-------------
./perf record -j any -e branch-misses:k ls
perf perf.data perf.data.old test-mmap-ring
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.002 MB perf.data (~102 samples) ]
Quoted 6 lines
Quoted 6 lines
arch/powerpc/perf/power8=
Quoted 6 lines
Signed-off-by Anshuman Khandual <[email protected]>--- arch/powerpc/perf/power8-pmu.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)arch/powerpc/perf/power8= renamed from arch/powerpc/perf/power8-pmu.c +0
-0
-pmu.c
Quoted 4 lines
Quoted 4 lines
arch/powerpc/perf/power8-pmu.c static u64 power8_bhrb_filter_map(u64 branch_sam=
Quoted 4 lines
index f7d1c4f..3a58416 100644
arch/powerpc/perf/power8-pmu.c +0
-0@@ -525,16 +525,12 @@ static u64 power8_bhrb_filter_map(u64 branch_sam=
ple_type)
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
arch/powerpc/perf/power8-pmu.c +0
-0u64 pmu_bhrb_filter =3D 0; u64 br_privilege =3D branch_sample_type & ONLY_PLM;=20=20
arch/powerpc/perf/power8-pmu.c +3
-6-/* BHRB and regular PMU events share the same prvillege state +/* BHRB and regular PMU events share the same privilege state * filter configuration. BHRB is always recorded along with a -* regular PMU event. So privilege state filter criteria for BHRB -* and the companion PMU events has to be the same. As a default -* "perf record" tool sets all privillege bits ON when no filter -* criteria is provided in the command line. So as along as all -* privillege bits are ON or they are OFF, we are good to go. +* regular PMU event. As the privilege state filter is handled +* in the basic PMC configuration of the accompanying regular
Quoted 8 lines
Quoted 8 lines
arch/powerpc/perf/power8-pmu.c static u64 power8_bhrb_filter_map(u64 branch_sample_type) · line 537
Quoted 4 lines
arch/powerpc/perf/power8-pmu.c +1
-2+* PMU event, we ignore any separate BHRB specific request. */ - if ((br_privilege !=3D 7) && (br_privilege !=3D 0)) -return -1 ;=20
br_privilegeis now unused which causes this compile error. =20arch/powerpc/perf/power8-pmu.c:526:6: error: unused variable =E2=80=98b=
r_privilege=E2=80=99 [-Werror=3Dunused-variable]
Quoted 11 lines
Quoted 3 lines
=20
I assume since you didn't compile test this code, you also didn't runtime test it either?!!?!?!?=20
=20
Always compile with the cross compiler "ARCH=3Dpowerpc CROSS_COMPILE=3Dpowerpc64-linux-gnu- make" I copied overarch/powerpc/config/pseries_defconfigand compiled it. Some how it missed to be a 64 bit kernel config which resulted in shutting down compilation ofarch/powerpc/perf/power8-pmu.cfile. So never encountered this compiler warning message before. Will fix this.
I don't understand this at all... pseries_defconfig is a 64bit kernel.
BTW. you don't need to copy it. Just do "make pseries_defconfig && make vmlinux".
Mikey
PATCH v2 2/2 powerpc, perf: BHRB filter configuration should follow the task
In reply to Anshuman KhandualWhen the task moves around the system, the corresponding cpuhw per cpu strcuture should be popullated with the BHRB filter request value so that PMU could be configured appropriately with that during the next call into power_pmu_enable().
--- arch/powerpc/perf/core-book3s.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/perf/core-book3s.c +4 -1
@@ -1122,8 +1122,11 @@ nocheck: ret =0 ; out: -if (has_branch_stack (event)) +if (has_branch_stack (event)) {power_pmu_bhrb_enable (event); + cpuhw->bhrb_filter = ppmu->bhrb_filter_map ( + event->attr.branch_sample_type); + }perf_pmu_enable (event->pmu);local_irq_restore (flags);
Signature · 1 line
1.7.11.7