The patch titled Subject: mm/huge_memory: use helper touch_pmd in huge_pmd_set_accessed has been added to the -mm mm-unstable branch. Its filename is mm-huge_memory-use-helper-touch_pmd-in-huge_pmd_set_accessed.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-huge_memory-use-helper-touch_pmd-in-huge_pmd_set_accessed.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: Miaohe Lin <linmiaohe@xxxxxxxxxx> Subject: mm/huge_memory: use helper touch_pmd in huge_pmd_set_accessed Date: Mon, 4 Jul 2022 21:21:50 +0800 Use helper touch_pmd to set pmd accessed to simplify the code and improve the readability. No functional change intended. Link: https://lkml.kernel.org/r/20220704132201.14611-6-linmiaohe@xxxxxxxxxx Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Reviewed-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Yang Shi <shy828301@xxxxxxxxx> Cc: Zach O'Keefe <zokeefe@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/huge_memory.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) --- a/mm/huge_memory.c~mm-huge_memory-use-helper-touch_pmd-in-huge_pmd_set_accessed +++ a/mm/huge_memory.c @@ -1120,15 +1120,15 @@ EXPORT_SYMBOL_GPL(vmf_insert_pfn_pud_pro #endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ static void touch_pmd(struct vm_area_struct *vma, unsigned long addr, - pmd_t *pmd, int flags) + pmd_t *pmd, bool write) { pmd_t _pmd; _pmd = pmd_mkyoung(*pmd); - if (flags & FOLL_WRITE) + if (write) _pmd = pmd_mkdirty(_pmd); if (pmdp_set_access_flags(vma, addr & HPAGE_PMD_MASK, - pmd, _pmd, flags & FOLL_WRITE)) + pmd, _pmd, write)) update_mmu_cache_pmd(vma, addr, pmd); } @@ -1161,7 +1161,7 @@ struct page *follow_devmap_pmd(struct vm return NULL; if (flags & FOLL_TOUCH) - touch_pmd(vma, addr, pmd, flags); + touch_pmd(vma, addr, pmd, flags & FOLL_WRITE); /* * device mapped pages can only be returned if the @@ -1398,21 +1398,13 @@ unlock: void huge_pmd_set_accessed(struct vm_fault *vmf) { - pmd_t entry; - unsigned long haddr; bool write = vmf->flags & FAULT_FLAG_WRITE; - pmd_t orig_pmd = vmf->orig_pmd; vmf->ptl = pmd_lock(vmf->vma->vm_mm, vmf->pmd); - if (unlikely(!pmd_same(*vmf->pmd, orig_pmd))) + if (unlikely(!pmd_same(*vmf->pmd, vmf->orig_pmd))) goto unlock; - entry = pmd_mkyoung(orig_pmd); - if (write) - entry = pmd_mkdirty(entry); - haddr = vmf->address & HPAGE_PMD_MASK; - if (pmdp_set_access_flags(vmf->vma, haddr, vmf->pmd, entry, write)) - update_mmu_cache_pmd(vmf->vma, vmf->address, vmf->pmd); + touch_pmd(vmf->vma, vmf->address, vmf->pmd, write); unlock: spin_unlock(vmf->ptl); @@ -1548,7 +1540,7 @@ struct page *follow_trans_huge_pmd(struc return ERR_PTR(-ENOMEM); if (flags & FOLL_TOUCH) - touch_pmd(vma, addr, pmd, flags); + touch_pmd(vma, addr, pmd, flags & FOLL_WRITE); page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT; VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), page); _ Patches currently in -mm which might be from linmiaohe@xxxxxxxxxx are mm-page_alloc-minor-clean-up-for-memmap_init_compound.patch mm-mmapc-fix-missing-call-to-vm_unacct_memory-in-mmap_region.patch filemap-minor-cleanup-for-filemap_write_and_wait_range.patch mm-huge_memory-use-flush_pmd_tlb_range-in-move_huge_pmd.patch mm-huge_memory-access-vm_page_prot-with-read_once-in-remove_migration_pmd.patch mm-huge_memory-fix-comment-of-__pud_trans_huge_lock.patch mm-huge_memory-use-helper-touch_pud-in-huge_pud_set_accessed.patch mm-huge_memory-use-helper-touch_pmd-in-huge_pmd_set_accessed.patch mm-huge_memory-rename-mmun_start-to-haddr-in-remove_migration_pmd.patch mm-huge_memory-use-helper-function-vma_lookup-in-split_huge_pages_pid.patch mm-huge_memory-use-helper-macro-__attr_rw.patch mm-huge_memory-fix-comment-in-zap_huge_pud.patch mm-huge_memory-check-pmd_present-first-in-is_huge_zero_pmd.patch mm-huge_memory-try-to-free-subpage-in-swapcache-when-possible.patch mm-huge_memory-minor-cleanup-for-split_huge_pages_all.patch mm-huge_memory-fix-comment-of-page_deferred_list.patch mm-huge_memory-correct-comment-of-prep_transhuge_page.patch mm-huge_memory-comment-the-subtly-logic-in-__split_huge_pmd.patch mm-huge_memory-use-helper-macro-is_err_or_null-in-split_huge_pages_pid.patch