Re: [PATCHv2 1/2] mm/memory: Do not populate page table entries beyond i_size

From: David Hildenbrand
Date: Mon Oct 27 2025 - 05:35:13 EST


On 24.10.25 21:32, Kirill A. Shutemov wrote:


On Fri, Oct 24, 2025, at 16:42, David Hildenbrand wrote:
On 23.10.25 11:32, Kiryl Shutsemau wrote:
addr0 = addr - start * PAGE_SIZE;
if (folio_within_vma(folio, vmf->vma) &&
- (addr0 & PMD_MASK) == ((addr0 + folio_size(folio) - 1) & PMD_MASK)) {
+ (addr0 & PMD_MASK) == ((addr0 + folio_size(folio) - 1) & PMD_MASK) &&

Isn't this just testing whether addr0 is aligned to folio_size(folio)?
(given that we don't support folios > PMD_SIZE), like

IS_ALIGNED(addr0, folio_size(folio))

Actually, no. VMA can be not aligned to folio_size().

Ah, I missed that we can also have folio sizes besides PMD_SIZE here.

So it's all about testing whether the complete folio would be mapped by a single page table.

(a helper would be nice, but cannot immediately come up with a good name)

--
Cheers

David / dhildenb