From: Punit Agrawal Date: Thu, 6 Jul 2017 22:39:53 +0000 (-0700) Subject: mm: rmap: use correct helper when poisoning hugepages X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=5fd27b8e7dbcab0dc5a1346305679ba4bcc20977;p=openwrt%2Fstaging%2Fblogic.git mm: rmap: use correct helper when poisoning hugepages Using set_pte_at() does not do the right thing when putting down HWPOISON swap entries for hugepages on architectures that support contiguous ptes. Fix this problem by using set_huge_swap_pte_at() which was introduced to fix exactly this problem. Link: http://lkml.kernel.org/r/20170522133604.11392-7-punit.agrawal@arm.com Signed-off-by: Punit Agrawal Acked-by: Steve Capper Cc: "Kirill A. Shutemov" Cc: Catalin Marinas Cc: Will Deacon Cc: Naoya Horiguchi Cc: Mike Kravetz Cc: Mark Rutland Cc: Hillf Danton Cc: Aneesh Kumar K.V Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/rmap.c b/mm/rmap.c index 130c238fe384..b255743351e5 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1367,15 +1367,18 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, update_hiwater_rss(mm); if (PageHWPoison(page) && !(flags & TTU_IGNORE_HWPOISON)) { + pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); if (PageHuge(page)) { int nr = 1 << compound_order(page); hugetlb_count_sub(nr, mm); + set_huge_swap_pte_at(mm, address, + pvmw.pte, pteval, + vma_mmu_pagesize(vma)); } else { dec_mm_counter(mm, mm_counter(page)); + set_pte_at(mm, address, pvmw.pte, pteval); } - pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); - set_pte_at(mm, address, pvmw.pte, pteval); } else if (pte_unused(pteval)) { /* * The guest indicated that the page content is of no