aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/hugetlb.h4
-rw-r--r--mm/hugetlb.c29
-rw-r--r--mm/memory-failure.c6
3 files changed, 31 insertions, 8 deletions
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 9e51f77d44ca..796f30e00806 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -43,7 +43,7 @@ int hugetlb_reserve_pages(struct inode *inode, long from, long to,
43 struct vm_area_struct *vma, 43 struct vm_area_struct *vma,
44 int acctflags); 44 int acctflags);
45void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); 45void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed);
46void __isolate_hwpoisoned_huge_page(struct page *page); 46int dequeue_hwpoisoned_huge_page(struct page *page);
47void copy_huge_page(struct page *dst, struct page *src); 47void copy_huge_page(struct page *dst, struct page *src);
48 48
49extern unsigned long hugepages_treat_as_movable; 49extern unsigned long hugepages_treat_as_movable;
@@ -102,7 +102,7 @@ static inline void hugetlb_report_meminfo(struct seq_file *m)
102#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) 102#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
103#define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; }) 103#define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; })
104#define huge_pte_offset(mm, address) 0 104#define huge_pte_offset(mm, address) 0
105#define __isolate_hwpoisoned_huge_page(page) 0 105#define dequeue_hwpoisoned_huge_page(page) 0
106static inline void copy_huge_page(struct page *dst, struct page *src) 106static inline void copy_huge_page(struct page *dst, struct page *src)
107{ 107{
108} 108}
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 0fa9de8361bd..deb7bebefe68 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2955,18 +2955,39 @@ void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed)
2955 hugetlb_acct_memory(h, -(chg - freed)); 2955 hugetlb_acct_memory(h, -(chg - freed));
2956} 2956}
2957 2957
2958/* Should be called in hugetlb_lock */
2959static int is_hugepage_on_freelist(struct page *hpage)
2960{
2961 struct page *page;
2962 struct page *tmp;
2963 struct hstate *h = page_hstate(hpage);
2964 int nid = page_to_nid(hpage);
2965
2966 list_for_each_entry_safe(page, tmp, &h->hugepage_freelists[nid], lru)
2967 if (page == hpage)
2968 return 1;
2969 return 0;
2970}
2971
2972#ifdef CONFIG_MEMORY_FAILURE
2958/* 2973/*
2959 * This function is called from memory failure code. 2974 * This function is called from memory failure code.
2960 * Assume the caller holds page lock of the head page. 2975 * Assume the caller holds page lock of the head page.
2961 */ 2976 */
2962void __isolate_hwpoisoned_huge_page(struct page *hpage) 2977int dequeue_hwpoisoned_huge_page(struct page *hpage)
2963{ 2978{
2964 struct hstate *h = page_hstate(hpage); 2979 struct hstate *h = page_hstate(hpage);
2965 int nid = page_to_nid(hpage); 2980 int nid = page_to_nid(hpage);
2981 int ret = -EBUSY;
2966 2982
2967 spin_lock(&hugetlb_lock); 2983 spin_lock(&hugetlb_lock);
2968 list_del(&hpage->lru); 2984 if (is_hugepage_on_freelist(hpage)) {
2969 h->free_huge_pages--; 2985 list_del(&hpage->lru);
2970 h->free_huge_pages_node[nid]--; 2986 h->free_huge_pages--;
2987 h->free_huge_pages_node[nid]--;
2988 ret = 0;
2989 }
2971 spin_unlock(&hugetlb_lock); 2990 spin_unlock(&hugetlb_lock);
2991 return ret;
2972} 2992}
2993#endif
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 757f6b0accfe..5c7158a11592 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -698,6 +698,7 @@ static int me_swapcache_clean(struct page *p, unsigned long pfn)
698 */ 698 */
699static int me_huge_page(struct page *p, unsigned long pfn) 699static int me_huge_page(struct page *p, unsigned long pfn)
700{ 700{
701 int res = 0;
701 struct page *hpage = compound_head(p); 702 struct page *hpage = compound_head(p);
702 /* 703 /*
703 * We can safely recover from error on free or reserved (i.e. 704 * We can safely recover from error on free or reserved (i.e.
@@ -710,8 +711,9 @@ static int me_huge_page(struct page *p, unsigned long pfn)
710 * so there is no race between isolation and mapping/unmapping. 711 * so there is no race between isolation and mapping/unmapping.
711 */ 712 */
712 if (!(page_mapping(hpage) || PageAnon(hpage))) { 713 if (!(page_mapping(hpage) || PageAnon(hpage))) {
713 __isolate_hwpoisoned_huge_page(hpage); 714 res = dequeue_hwpoisoned_huge_page(hpage);
714 return RECOVERED; 715 if (!res)
716 return RECOVERED;
715 } 717 }
716 return DELAYED; 718 return DELAYED;
717} 719}