lkml.org 
[lkml]   [2022]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] mm: thp: don't have to lock page anymore when splitting PMD
On Mon, 7 Mar 2022 16:03:12 -0800 Yang Shi <shy828301@gmail.com> wrote:

> On Mon, Mar 7, 2022 at 3:43 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> > @@ -2133,8 +2133,6 @@ void __split_huge_pmd(struct vm_area_str
> > {
> > spinlock_t *ptl;
> > struct mmu_notifier_range range;
> > - bool do_unlock_folio = false;
> > - pmd_t _pmd;
> >
> > mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm,
> > address & HPAGE_PMD_MASK,
> > @@ -2153,42 +2151,14 @@ void __split_huge_pmd(struct vm_area_str
> > goto out;
> > }
> >
> > -repeat:
> > if (pmd_trans_huge(*pmd)) {
> > - if (!folio) {
> > + if (!folio)
> > folio = page_folio(pmd_page(*pmd));
>
> We could remove the "if (pmd_trans_huge(*pmd))" section since folio is
> actually not used afterward at all.

>
> ...
>
>
> With the above if removed, this could be changed to:
>
> if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd) ||
> is_pmd_migration_entry(*pmd))
> __split_huge_pmd_locked(vma, pmd, range.start, freeze);
>

OK, looks sane. Can someone please test all this?

--- a/mm/huge_memory.c~mm-huge_memory-remove-stale-locking-logic-from-__split_huge_pmd-fix
+++ a/mm/huge_memory.c
@@ -2151,12 +2151,10 @@ void __split_huge_pmd(struct vm_area_str
goto out;
}

- if (pmd_trans_huge(*pmd)) {
- if (!folio)
- folio = page_folio(pmd_page(*pmd));
- } else if (!(pmd_devmap(*pmd) || is_pmd_migration_entry(*pmd)))
- goto out;
- __split_huge_pmd_locked(vma, pmd, range.start, freeze);
+ if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd) ||
+ is_pmd_migration_entry(*pmd)))
+ __split_huge_pmd_locked(vma, pmd, range.start, freeze);
+
out:
spin_unlock(ptl);
/*
_
\
 
 \ /
  Last update: 2022-03-08 01:51    [W:0.059 / U:0.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site