Commit f7cc67ae authored by Miaohe Lin's avatar Miaohe Lin Committed by akpm

mm/madvise: minor cleanup for swapin_walk_pmd_entry()

Passing index to pte_offset_map_lock() directly so the below calculation
can be avoided. Rename orig_pte to ptep as it's not changed. Also use
helper is_swap_pte() to improve the readability. No functional change
intended.

[akpm@linux-foundation.org: reduce scope of `ptep']
Link: https://lkml.kernel.org/r/20220618090527.37843-1-linmiaohe@huawei.comSigned-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent dc2628f3
...@@ -195,7 +195,6 @@ static int madvise_update_vma(struct vm_area_struct *vma, ...@@ -195,7 +195,6 @@ static int madvise_update_vma(struct vm_area_struct *vma,
static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start, static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start,
unsigned long end, struct mm_walk *walk) unsigned long end, struct mm_walk *walk)
{ {
pte_t *orig_pte;
struct vm_area_struct *vma = walk->private; struct vm_area_struct *vma = walk->private;
unsigned long index; unsigned long index;
struct swap_iocb *splug = NULL; struct swap_iocb *splug = NULL;
...@@ -208,12 +207,13 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start, ...@@ -208,12 +207,13 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start,
swp_entry_t entry; swp_entry_t entry;
struct page *page; struct page *page;
spinlock_t *ptl; spinlock_t *ptl;
pte_t *ptep;
orig_pte = pte_offset_map_lock(vma->vm_mm, pmd, start, &ptl); ptep = pte_offset_map_lock(vma->vm_mm, pmd, index, &ptl);
pte = *(orig_pte + ((index - start) / PAGE_SIZE)); pte = *ptep;
pte_unmap_unlock(orig_pte, ptl); pte_unmap_unlock(ptep, ptl);
if (pte_present(pte) || pte_none(pte)) if (!is_swap_pte(pte))
continue; continue;
entry = pte_to_swp_entry(pte); entry = pte_to_swp_entry(pte);
if (unlikely(non_swap_entry(entry))) if (unlikely(non_swap_entry(entry)))
......
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