Re: [PATCH] perf/x86/intel: Drop kernel samples even though :u is specified

From: Mark Rutland
Date: Mon May 22 2017 - 04:46:18 EST


On Mon, May 22, 2017 at 10:12:22AM +0800, Jin, Yao wrote:
> Hi Peter,
>
> Maybe it's not very easy to move the skid checking to generic code
> because we don't have a common kernel_ip() available to determine if
> ip is a kernel address.
>
> I was trying to move kernel_ip() from arch/x86/events/perf_event.h
> to generic code, but some difficulties I have:
>
> For example, in new kernel_ip(), we may use many
> conditional-compilation for all arch, for example:
>
> #ifdef CONFIG_X86_32
> return ip > PAGE_OFFSET;
> #endif
>
> #ifdef CONFIG_X86_64
> return (long)ip < 0;
> #endif
>
> #ifdef CONFIG_ARM....
> ......
> #ifdef CONFIG_MIPS....
> ......
>
> But the code is being ugly and hard to maintain. And frankly I don't
> know kernel address space for all arch.
>
> Any idea? Could we just do at x86 side this time?

Can we not check user_mode(regs) for all architectures?

!user_mode(regs) implies a kernel sample.

Thanks,
Mark.