Re: [PATCH V6 01/16] perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE

Liang, Kan
2020-08-12T13:40:00Z

On 8/10/2020 6:47 PM, Peter Zijlstra wrote:
> On Mon, Aug 10, 2020 at 06:38:35PM -0400, Liang, Kan wrote:
>> On 8/10/2020 5:47 PM, Dave Hansen wrote:
>
>>> It's probably best if we very carefully define up front what is getting
>>> reported here. For instance, I believe we already have some fun cases
>>> with huge tmpfs where a compound page is mapped with 4k PTEs. Kirill
>>> also found a few drivers doing this as well. I think there were also
>>> some weird cases for ARM hugetlbfs where there were multiple hardware
>>> page table entries mapping a single hugetlbfs page. These would be
>>> cases where compound_head() size would be greater than the size of the
>>> leaf paging structure entry.
>>>
>>> This is also why we have KerelPageSize and MMUPageSize in /proc/$pid/smaps.
>>>
>>> So, is this returning the kernel software page size or the MMU size?
>>>
>>
>> This tries to return the kernel software page size. I will add a commit to
>> the function. For the above cases, I think they can be detected by
>> PageCompound(page). The current code should already cover them. Is my
>> understanding correct?
>
> But the rationale for the whole feature was to measure and possibly
> drive large page promotion/demotion, which requires the mmu page-size.

Yes, the MMU page-size is better here.

I still have some questions regarding MMUPageSize VS. KerelPageSize.
Could you please clarify?

I checked the show_smap code in fs/proc/task_mmu.c. We defined a __weak
function for vma_mmu_pagesize(), which invokes vma_kernel_pagesize().
The comments also say that "In the majority of cases, the page size used
by the kernel matches the MMU size. On architectures where it differs,
an architecture-specific 'strong' version of this symbol is required."
I searched the vma_mmu_pagesize(). It seems that PowerPC is the only one
that defines a 'strong' function. In other words, the MMUPageSize and
KerelPageSize are the same for X86. However, it seems not true for the
above compound page cases. Is it a bug for smaps? Or am I missed anything?

Thanks,
Kan