From f3820ab6857a65b3be53f1ba301b0e2bcaf12753 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Thu, 22 Oct 2015 09:03:47 +1100 Subject: [PATCH] mm: skip huge zero page in MADV_FREE It is pointless to mark huge zero page as freeable. Let's skip it. Signed-off-by: Minchan Kim Signed-off-by: Andrew Morton --- mm/huge_memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 9f6834408c84..3dab6fa0b0bd 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1542,6 +1542,9 @@ int madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, struct page *page; pmd_t orig_pmd; + if (is_huge_zero_pmd(*pmd)) + goto out; + orig_pmd = pmdp_huge_get_and_clear(mm, addr, pmd); /* No hugepage in swapcache */ @@ -1553,6 +1556,7 @@ int madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, set_pmd_at(mm, addr, pmd, orig_pmd); tlb_remove_pmd_tlb_entry(tlb, pmd, addr); +out: spin_unlock(ptl); ret = 0; } -- 2.39.5