1
linux/arch/powerpc/perf
Kajol Jain ad86d7ee43 powerpc/hv-gpci: Fix the H_GET_PERF_COUNTER_INFO hcall return value checks
Running event hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/
in one of the system throws below error:

 ---Logs---
 # perf list | grep hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles
  hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=?/[Kernel PMU event]

 # perf stat -v -e hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/ sleep 2
Using CPUID 00800200
Control descriptor is not initialized
Warning:
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/ event is not supported by the kernel.
failed to read counter hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/

 Performance counter stats for 'system wide':

   <not supported>      hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/

       2.000700771 seconds time elapsed

The above error is because of the hcall failure as required
permission "Enable Performance Information Collection" is not set.
Based on current code, single_gpci_request function did not check the
error type incase hcall fails and by default returns EINVAL. But we can
have other reasons for hcall failures like H_AUTHORITY/H_PARAMETER with
detail_rc as GEN_BUF_TOO_SMALL, for which we need to act accordingly.

Fix this issue by adding new checks in the single_gpci_request and
h_gpci_event_init functions.

Result after fix patch changes:

 # perf stat -e hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/ sleep 2
Error:
No permission to enable hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/ event.

Fixes: 220a0c609a ("powerpc/perf: Add support for the hv gpci (get performance counter info) interface")
Reported-by: Akanksha J N <akanksha@linux.ibm.com>
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240229122847.101162-1-kjain@linux.ibm.com
2024-03-03 23:05:21 +11:00
..
req-gen
8xx-pmu.c
bhrb.S
callchain_32.c
callchain_64.c
callchain.c
callchain.h
core-book3s.c powerpc: Use user_mode() macro when possible 2024-02-22 21:55:33 +11:00
core-fsl-emb.c
e500-pmu.c
e6500-pmu.c
generic-compat-pmu.c
hv-24x7-catalog.h
hv-24x7-domains.h
hv-24x7.c
hv-24x7.h
hv-common.c
hv-common.h
hv-gpci-requests.h
hv-gpci.c powerpc/hv-gpci: Fix the H_GET_PERF_COUNTER_INFO hcall return value checks 2024-03-03 23:05:21 +11:00
hv-gpci.h
imc-pmu.c
internal.h powerpc/perf: Power11 Performance Monitoring support 2024-02-21 23:11:00 +11:00
isa207-common.c
isa207-common.h
Makefile
mpc7450-pmu.c
perf_regs.c
power5-pmu.c
power5+-pmu.c
power6-pmu.c
power7-events-list.h
power7-pmu.c
power8-events-list.h
power8-pmu.c
power9-events-list.h
power9-pmu.c
power10-events-list.h
power10-pmu.c powerpc/perf: Power11 Performance Monitoring support 2024-02-21 23:11:00 +11:00
ppc970-pmu.c