mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-22 02:20:40 +00:00
mm: hugetlb: cleanup duplicated code in unmapping vm range
Fix code duplication in __unmap_hugepage_range(), such as pte_page() and huge_pte_none(). Signed-off-by: Hillf Danton <dhillf@gmail.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
934e18b5cb
commit
6629326b89
1 changed files with 11 additions and 14 deletions
25
mm/hugetlb.c
25
mm/hugetlb.c
|
@ -2331,16 +2331,23 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
|
||||||
if (huge_pmd_unshare(mm, &address, ptep))
|
if (huge_pmd_unshare(mm, &address, ptep))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
pte = huge_ptep_get(ptep);
|
||||||
|
if (huge_pte_none(pte))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HWPoisoned hugepage is already unmapped and dropped reference
|
||||||
|
*/
|
||||||
|
if (unlikely(is_hugetlb_entry_hwpoisoned(pte)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
page = pte_page(pte);
|
||||||
/*
|
/*
|
||||||
* If a reference page is supplied, it is because a specific
|
* If a reference page is supplied, it is because a specific
|
||||||
* page is being unmapped, not a range. Ensure the page we
|
* page is being unmapped, not a range. Ensure the page we
|
||||||
* are about to unmap is the actual page of interest.
|
* are about to unmap is the actual page of interest.
|
||||||
*/
|
*/
|
||||||
if (ref_page) {
|
if (ref_page) {
|
||||||
pte = huge_ptep_get(ptep);
|
|
||||||
if (huge_pte_none(pte))
|
|
||||||
continue;
|
|
||||||
page = pte_page(pte);
|
|
||||||
if (page != ref_page)
|
if (page != ref_page)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -2353,16 +2360,6 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
|
||||||
}
|
}
|
||||||
|
|
||||||
pte = huge_ptep_get_and_clear(mm, address, ptep);
|
pte = huge_ptep_get_and_clear(mm, address, ptep);
|
||||||
if (huge_pte_none(pte))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* HWPoisoned hugepage is already unmapped and dropped reference
|
|
||||||
*/
|
|
||||||
if (unlikely(is_hugetlb_entry_hwpoisoned(pte)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
page = pte_page(pte);
|
|
||||||
if (pte_dirty(pte))
|
if (pte_dirty(pte))
|
||||||
set_page_dirty(page);
|
set_page_dirty(page);
|
||||||
list_add(&page->lru, &page_list);
|
list_add(&page->lru, &page_list);
|
||||||
|
|
Loading…
Reference in a new issue