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? 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.