lkml.org 
[lkml]   [2023]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RESEND PATCH v7 04/10] mm: thp: Support allocation of anonymous small-sized THP
From
On 27/11/2023 03:41, Barry Song wrote:
>> + if ((nr_pages == 1 && vmf_pte_changed(vmf)) ||
>> + (nr_pages > 1 && !pte_range_none(vmf->pte, nr_pages))) {
>> + for (i = 0; i < nr_pages; i++)
>> + update_mmu_tlb(vma, addr + PAGE_SIZE * i, vmf->pte + i);
>> goto release;
>> }
>
> Hi Ryan,
> what has stopped nr_pages == 1 from using !pte_range_none(vmf->pte, 1)
> directly, then the code can become,
> + if (!pte_range_none(vmf->pte, nr_pages)) {
> + for (i = 0; i < nr_pages; i++)
> + update_mmu_tlb(vma, addr + PAGE_SIZE * i, vmf->pte + i);
> goto release;
> }
>
> for both 1 and > 1 cases?

We can get to do_anonymous_page() from 2 routes:

- page fault on unallocated memory (pte_none())
- page fault on uffd_wp pte marker

In the latter case, we guarrantee that we are only operating on nr_pages == 1
because when uffd is in the picture we need to preserve any uffd state per-pte.
It also means we can't just check the pte is none because in this case it is not
none, it has a pte marker so we need to check it hasn't changed.

I was previously abstracting this in vmf_pte_range_changed() but there were
complaints [1] about the semantic being different based on the number of pages,
so this was my attempt to make it more understandable.

[1] https://lore.kernel.org/linux-mm/a6fa0847-a950-4044-972c-e5dc8cbc7922@arm.com/

Thanks,
Ryan


>
> Thanks
> Barry
>

\
 
 \ /
  Last update: 2023-11-27 12:29    [W:0.082 / U:0.804 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site