Skip to content

Commit

Permalink
mm: madvise: use vm_normal_folio() in madvise_free_pte_range()
Browse files Browse the repository at this point in the history
There is already a vm_normal_folio(), use it to make
madvise_free_pte_range() only use a folio.

Link: https://lkml.kernel.org/r/20230112124028.16964-1-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Kefeng Wang authored and akpm00 committed Feb 3, 2023
1 parent 69bbb87 commit 4947ed9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
spinlock_t *ptl;
pte_t *orig_pte, *pte, ptent;
struct folio *folio;
struct page *page;
int nr_swap = 0;
unsigned long next;

Expand Down Expand Up @@ -658,10 +657,9 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
continue;
}

page = vm_normal_page(vma, addr, ptent);
if (!page || is_zone_device_page(page))
folio = vm_normal_folio(vma, addr, ptent);
if (!folio || folio_is_zone_device(folio))
continue;
folio = page_folio(page);

/*
* If pmd isn't transhuge but the folio is large and
Expand Down

0 comments on commit 4947ed9

Please sign in to comment.