Re: [PATCH v8 02/23] mm: Teach core mm about pte markers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Alistair,

On Tue, Apr 12, 2022 at 11:22:01AM +1000, Alistair Popple wrote:
> I've been reviewing existing pte_none() call sites and noticed the following:
> 
> From khugepaged_scan_pmd():
> 
> pte_t pteval = *_pte;
> if (is_swap_pte(pteval)) {
>     if (++unmapped <= khugepaged_max_ptes_swap) {
>         /*
> * Always be strict with uffd-wp
> * enabled swap entries.  Please see
> * comment below for pte_uffd_wp().
>          */
>         if (pte_swp_uffd_wp(pteval)) {
>             result = SCAN_PTE_UFFD_WP;
>             goto out_unmap;
>         }
>         continue;
>     } else {
>         result = SCAN_EXCEED_SWAP_PTE;
>         count_vm_event(THP_SCAN_EXCEED_SWAP_PTE);
>         goto out_unmap;
>     }
> }
> if (pte_none(pteval) || is_zero_pfn(pte_pfn(pteval))) {
>     if (!userfaultfd_armed(vma) &&
>         ++none_or_zero <= khugepaged_max_ptes_none) {
>         continue;
>     } else {
>         result = SCAN_EXCEED_NONE_PTE;
>         count_vm_event(THP_SCAN_EXCEED_NONE_PTE);
>         goto out_unmap;
>     }
> }
> 
> I think the above could encounter a marker PTE right? So the behviour would be
> wrong in that case. As I understand things the is_swap_pte() path will be taken
> rather than pte_none() but in the absence of any special handling shouldn't
> marker PTE's mostly be treated as pte_none() here?
> 
> I think you need to s/pte_none/pte_none_mostly/ here and swap the order of
> conditionals around.

Isn't khugepaged_scan_pmd() only for anonymous?

The shmem side is covered by khugepaged_scan_file(), imho.  We definitely
don't want to collapse shmem vma ranges that has uffd-wp registered, and
that's actually handled explicilty in "mm/khugepaged: Don't recycle vma
pgtable if uffd-wp registered".  Please feel free to have a look.

Thanks,

-- 
Peter Xu





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux