Re: [PATCH v2] perf/core: Fix perf_mmap fail when CONFIG_PERF_USE_VMALLOC enabled

From: Peter Zijlstra
Date: Thu Apr 14 2022 - 11:46:27 EST


On Wed, Feb 09, 2022 at 09:54:17AM -0500, Zhipeng Xie wrote:
> This problem can be reproduced with CONFIG_PERF_USE_VMALLOC enabled on both
> x86_64 and aarch64 arch when using sysdig -B(using ebpf)[1].
> sysdig -B works fine after rebuilding the kernel with CONFIG_PERF_USE_VMALLOC
> disabled.
>
> I tracked it down to the if condition event->rb->nr_pages != nr_pages in
> perf_mmap is true when CONFIG_PERF_USE_VMALLOC is enabled where
> event->rb->nr_pages = 1 and nr_pages = 2048 resulting perf_mmap to return
> -EINVAL.This is because when CONFIG_PERF_USE_VMALLOC is enabled, rb->nr_pages
> is always equal to 1.
>
> Arch with CONFIG_PERF_USE_VMALLOC enabled by default:
> arc/arm/csky/mips/sh/sparc/xtensa
> Arch with CONFIG_PERF_USE_VMALLOC disabled by default:
> x86_64/aarch64/...
>
> Fix this problem by using data_page_nr.
>
> [1] https://github.com/draios/sysdig
>
> Signed-off-by: Zhipeng Xie <xiezhipeng1@xxxxxxxxxx>

Right; sorry for being tardy. Fix looks ok, but I tihnk it needs:

Fixes: 906010b2134e ("perf_event: Provide vmalloc() based mmap() backing")

Will go queue.