Re: [RFC 2/4] perf: Pass pmu pointer to perf_paranoid_* helpers

From: Tvrtko Ursulin
Date: Tue Jul 03 2018 - 06:28:22 EST



Hi Ravi,

On 03/07/18 11:24, Ravi Bangoria wrote:
Hi Tvrtko,

@@ -199,7 +199,7 @@ static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp)
if (!(mmcra & MMCRA_SAMPLE_ENABLE) || sdar_valid)
*addrp = mfspr(SPRN_SDAR);
- if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN) &&
+ if (perf_paranoid_kernel(ppmu) && !capable(CAP_SYS_ADMIN) &&
is_kernel_addr(mfspr(SPRN_SDAR)))
*addrp = 0;
}

This patch fails for me on powerpc:

arch/powerpc/perf/core-book3s.c: In function âperf_get_data_addrâ:
arch/powerpc/perf/core-book3s.c:202:27: error: passing argument 1 of âperf_paranoid_kernelâ from incompatible pointer type [-Werror=incompatible-pointer-types]
if (perf_paranoid_kernel(ppmu) && !capable(CAP_SYS_ADMIN) &&
^~~~
In file included from arch/powerpc/perf/core-book3s.c:13:0:
./include/linux/perf_event.h:1191:20: note: expected âconst struct pmu *â but argument is of type âstruct power_pmu *â
static inline bool perf_paranoid_kernel(const struct pmu *pmu)
^~~~~~~~~~~~~~~~~~~~
arch/powerpc/perf/core-book3s.c: In function âpower_pmu_bhrb_readâ:
arch/powerpc/perf/core-book3s.c:470:8: error: too few arguments to function âperf_paranoid_kernelâ
if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN) &&
^~~~~~~~~~~~~~~~~~~~
In file included from arch/powerpc/perf/core-book3s.c:13:0:
./include/linux/perf_event.h:1191:20: note: declared here
static inline bool perf_paranoid_kernel(const struct pmu *pmu)
^~~~~~~~~~~~~~~~~~~~
CC net/ipv6/route.o

Yep, kbuild reported this as well. I will need to re-arrange the code a bit to a) pass the correct pointer in, and b) I missed one call-site as well.

I was holding of doing that until some more general feedback arrives.

Regards,

Tvrtko