The patch titled Subject: mm/rmap: add helper to restart pgtable walk on changes has been added to the -mm mm-unstable branch. Its filename is mm-rmap-add-helper-to-restart-pgtable-walk-on-changes.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-rmap-add-helper-to-restart-pgtable-walk-on-changes.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Lance Yang <ioworker0@xxxxxxxxx> Subject: mm/rmap: add helper to restart pgtable walk on changes Date: Mon, 10 Jun 2024 20:02:07 +0800 Introduce the page_vma_mapped_walk_restart() helper to handle scenarios where the page table walk needs to be restarted due to changes in the page table, such as when a PMD is split. It releases the PTL held during the previous walk and resets the state, allowing a new walk to start at the current address stored in pvmw->address. Link: https://lkml.kernel.org/r/20240610120209.66311-3-ioworker0@xxxxxxxxx Signed-off-by: Lance Yang <ioworker0@xxxxxxxxx> Suggested-by: David Hildenbrand <david@xxxxxxxxxx> Cc: Bang Li <libang.li@xxxxxxxxxxxx> Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> Cc: Fangrui Song <maskray@xxxxxxxxxx> Cc: Jeff Xie <xiehuan09@xxxxxxxxx> Cc: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Muchun Song <songmuchun@xxxxxxxxxxxxx> Cc: Peter Xu <peterx@xxxxxxxxxx> Cc: Ryan Roberts <ryan.roberts@xxxxxxx> Cc: SeongJae Park <sj@xxxxxxxxxx> Cc: Yin Fengwei <fengwei.yin@xxxxxxxxx> Cc: Zach O'Keefe <zokeefe@xxxxxxxxxx> Cc: Zi Yan <ziy@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/rmap.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) --- a/include/linux/rmap.h~mm-rmap-add-helper-to-restart-pgtable-walk-on-changes +++ a/include/linux/rmap.h @@ -703,6 +703,28 @@ static inline void page_vma_mapped_walk_ spin_unlock(pvmw->ptl); } +/** + * page_vma_mapped_walk_restart - Restart the page table walk. + * @pvmw: Pointer to struct page_vma_mapped_walk. + * + * It restarts the page table walk when changes occur in the page + * table, such as splitting a PMD. Ensures that the PTL held during + * the previous walk is released and resets the state to allow for + * a new walk starting at the current address stored in pvmw->address. + */ +static inline void +page_vma_mapped_walk_restart(struct page_vma_mapped_walk *pvmw) +{ + WARN_ON_ONCE(!pvmw->pmd); + WARN_ON_ONCE(!pvmw->ptl); + + if (pvmw->ptl) + spin_unlock(pvmw->ptl); + + pvmw->ptl = NULL; + pvmw->pmd = NULL; +} + bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw); /* _ Patches currently in -mm which might be from ioworker0@xxxxxxxxx are mm-rmap-remove-duplicated-exit-code-in-pagewalk-loop.patch mm-rmap-add-helper-to-restart-pgtable-walk-on-changes.patch mm-rmap-integrate-pmd-mapped-folio-splitting-into-pagewalk-loop.patch mm-vmscan-avoid-split-lazyfree-thp-during-shrink_folio_list.patch