lkml.org 
[lkml]   [2020]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V9 1/4] perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE
On Wed, Nov 11, 2020 at 03:30:22PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 11, 2020 at 01:43:57PM +0100, Peter Zijlstra wrote:
> > + if (pud_leaf(pud)) {
> > #ifdef pud_page
> > - page = pud_page(*pud);
> > - if (PageHuge(page))
> > - return page_size(compound_head(page));
> > + if (!pud_devmap(pud)) {
> > + page = pud_page(pud);
> > + if (PageHuge(page))
> > + return page_size(compound_head(page));
> > + }
> > #endif
> > return 1ULL << PUD_SHIFT;
>
> This confuses me. Why only special-case hugetlbfs pages here? Should
> they really be treated differently from THP?

Do we have non-pagetable aligned THP ? I thought THP was always PUD
sized.

> If you want to consider that we might be mapping a page that's twice
> as big as a PUD entry and this is only half of it, then the simple way
> is:
>
> if (pud_leaf(pud)) {
> #ifdef pud_page
> page = compound_head(pud_page(*pud));
> return page_size(page);
> #else
> return 1ULL << PUD_SHIFT;
> #endif
> }
>
> Also, what's up with the special-casing of devmap pages here? Did the
> devmap people fuck up their compound pages? If so, they should fix their
> shit, not expect the rest of the kernel to work around this brokenness.

Well, the PTE code we have today (in tip/perf/core) is:

pte = pte_offset_map(pmd, addr);
if (!pte_present(*pte)) {
pte_unmap(pte);
return 0;
}

page = pte_page(*pte);
if (PageHuge(page)) {
u64 size = page_size(compound_head(page));
pte_unmap(pte);
return size;
}

pte_unmap(pte);
return PAGE_SIZE;

and that's crashing in PageHuge()'s PageCompound() test. Clearly I
should be checking pte_special() here (as well as all the READ_ONCE()s I
added in the patch you just commented on). But I wasn't quite sure about
devmap and paranoia won.

You're saying devmap should be valid compound pages? Then I can remove
all that and only keep pte_special().

\
 
 \ /
  Last update: 2020-11-11 16:53    [W:0.089 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site