Commit 5fe653e9 authored by Miaohe Lin's avatar Miaohe Lin Committed by akpm

mm/huge_memory: use helper touch_pud in huge_pud_set_accessed

Use helper touch_pud to set pud accessed to simplify the code and improve
the readability. No functional change intended.

Link: https://lkml.kernel.org/r/20220704132201.14611-5-linmiaohe@huawei.comSigned-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent d965e390
...@@ -1184,15 +1184,15 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, ...@@ -1184,15 +1184,15 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
static void touch_pud(struct vm_area_struct *vma, unsigned long addr, static void touch_pud(struct vm_area_struct *vma, unsigned long addr,
pud_t *pud, int flags) pud_t *pud, bool write)
{ {
pud_t _pud; pud_t _pud;
_pud = pud_mkyoung(*pud); _pud = pud_mkyoung(*pud);
if (flags & FOLL_WRITE) if (write)
_pud = pud_mkdirty(_pud); _pud = pud_mkdirty(_pud);
if (pudp_set_access_flags(vma, addr & HPAGE_PUD_MASK, if (pudp_set_access_flags(vma, addr & HPAGE_PUD_MASK,
pud, _pud, flags & FOLL_WRITE)) pud, _pud, write))
update_mmu_cache_pud(vma, addr, pud); update_mmu_cache_pud(vma, addr, pud);
} }
...@@ -1219,7 +1219,7 @@ struct page *follow_devmap_pud(struct vm_area_struct *vma, unsigned long addr, ...@@ -1219,7 +1219,7 @@ struct page *follow_devmap_pud(struct vm_area_struct *vma, unsigned long addr,
return NULL; return NULL;
if (flags & FOLL_TOUCH) if (flags & FOLL_TOUCH)
touch_pud(vma, addr, pud, flags); touch_pud(vma, addr, pud, flags & FOLL_WRITE);
/* /*
* device mapped pages can only be returned if the * device mapped pages can only be returned if the
...@@ -1284,21 +1284,13 @@ int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm, ...@@ -1284,21 +1284,13 @@ int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm,
void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud) void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud)
{ {
pud_t entry;
unsigned long haddr;
bool write = vmf->flags & FAULT_FLAG_WRITE; bool write = vmf->flags & FAULT_FLAG_WRITE;
vmf->ptl = pud_lock(vmf->vma->vm_mm, vmf->pud); vmf->ptl = pud_lock(vmf->vma->vm_mm, vmf->pud);
if (unlikely(!pud_same(*vmf->pud, orig_pud))) if (unlikely(!pud_same(*vmf->pud, orig_pud)))
goto unlock; goto unlock;
entry = pud_mkyoung(orig_pud); touch_pud(vmf->vma, vmf->address, vmf->pud, write);
if (write)
entry = pud_mkdirty(entry);
haddr = vmf->address & HPAGE_PUD_MASK;
if (pudp_set_access_flags(vmf->vma, haddr, vmf->pud, entry, write))
update_mmu_cache_pud(vmf->vma, vmf->address, vmf->pud);
unlock: unlock:
spin_unlock(vmf->ptl); spin_unlock(vmf->ptl);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment