perf/core: Fix arch_perf_get_page_size()
authorPeter Zijlstra <peterz@infradead.org>
Wed, 11 Nov 2020 12:43:57 +0000 (13:43 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 3 Dec 2020 09:14:51 +0000 (10:14 +0100)
commit8af26be062721e52eba1550caf50b712f774c5fd
tree3927b7054821e97bc397f3a34e64db1e19ee08b4
parent560dabbdf68bb15f9e241af8f828b1c8c38d6c6f
perf/core: Fix arch_perf_get_page_size()

The (new) page-table walker in arch_perf_get_page_size() is broken in
various ways. Specifically while it is used in a lockless manner, it
doesn't depend on CONFIG_HAVE_FAST_GUP nor uses the proper _lockless
offset methods, nor is careful to only read each entry only once.

Also the hugetlb support is broken due to calling pte_page() without
first checking pte_special().

Rewrite the whole thing to be a proper lockless page-table walker and
employ the new pXX_leaf_size() pgtable functions to determine the
pagetable size without looking at the page-frames.

Fixes: 51b646b2d9f8 ("perf,mm: Handle non-page-table-aligned hugetlbfs")
Fixes: 8d97e71811aa ("perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Link: https://lkml.kernel.org/r/20201126124207.GM3040@hirez.programming.kicks-ass.net
kernel/events/core.c