Commit 665d9da7 authored by Wanpeng Li's avatar Wanpeng Li Committed by Linus Torvalds

mm/hwpoison: replace most of put_page in memory error handling by put_hwpoison_page

Replace most instances of put_page() in memory error handling with
put_hwpoison_page().
Signed-off-by: default avatarWanpeng Li <wanpeng.li@hotmail.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent be91748f
...@@ -1174,9 +1174,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags) ...@@ -1174,9 +1174,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
pr_err("MCE: %#lx: thp split failed\n", pfn); pr_err("MCE: %#lx: thp split failed\n", pfn);
if (TestClearPageHWPoison(p)) if (TestClearPageHWPoison(p))
atomic_long_sub(nr_pages, &num_poisoned_pages); atomic_long_sub(nr_pages, &num_poisoned_pages);
put_page(p); put_hwpoison_page(p);
if (p != hpage)
put_page(hpage);
return -EBUSY; return -EBUSY;
} }
VM_BUG_ON_PAGE(!page_count(p), p); VM_BUG_ON_PAGE(!page_count(p), p);
...@@ -1237,14 +1235,14 @@ int memory_failure(unsigned long pfn, int trapno, int flags) ...@@ -1237,14 +1235,14 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn); printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn);
atomic_long_sub(nr_pages, &num_poisoned_pages); atomic_long_sub(nr_pages, &num_poisoned_pages);
unlock_page(hpage); unlock_page(hpage);
put_page(hpage); put_hwpoison_page(hpage);
return 0; return 0;
} }
if (hwpoison_filter(p)) { if (hwpoison_filter(p)) {
if (TestClearPageHWPoison(p)) if (TestClearPageHWPoison(p))
atomic_long_sub(nr_pages, &num_poisoned_pages); atomic_long_sub(nr_pages, &num_poisoned_pages);
unlock_page(hpage); unlock_page(hpage);
put_page(hpage); put_hwpoison_page(hpage);
return 0; return 0;
} }
...@@ -1258,7 +1256,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags) ...@@ -1258,7 +1256,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
if (PageHuge(p) && PageTail(p) && TestSetPageHWPoison(hpage)) { if (PageHuge(p) && PageTail(p) && TestSetPageHWPoison(hpage)) {
action_result(pfn, MF_MSG_POISONED_HUGE, MF_IGNORED); action_result(pfn, MF_MSG_POISONED_HUGE, MF_IGNORED);
unlock_page(hpage); unlock_page(hpage);
put_page(hpage); put_hwpoison_page(hpage);
return 0; return 0;
} }
/* /*
...@@ -1492,9 +1490,9 @@ int unpoison_memory(unsigned long pfn) ...@@ -1492,9 +1490,9 @@ int unpoison_memory(unsigned long pfn)
} }
unlock_page(page); unlock_page(page);
put_page(page); put_hwpoison_page(page);
if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1))
put_page(page); put_hwpoison_page(page);
return 0; return 0;
} }
...@@ -1554,7 +1552,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) ...@@ -1554,7 +1552,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags)
/* /*
* Try to free it. * Try to free it.
*/ */
put_page(page); put_hwpoison_page(page);
shake_page(page, 1); shake_page(page, 1);
/* /*
...@@ -1563,7 +1561,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) ...@@ -1563,7 +1561,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags)
ret = __get_any_page(page, pfn, 0); ret = __get_any_page(page, pfn, 0);
if (!PageLRU(page)) { if (!PageLRU(page)) {
/* Drop page reference which is from __get_any_page() */ /* Drop page reference which is from __get_any_page() */
put_page(page); put_hwpoison_page(page);
pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n", pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n",
pfn, page->flags); pfn, page->flags);
return -EIO; return -EIO;
...@@ -1586,7 +1584,7 @@ static int soft_offline_huge_page(struct page *page, int flags) ...@@ -1586,7 +1584,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
lock_page(hpage); lock_page(hpage);
if (PageHWPoison(hpage)) { if (PageHWPoison(hpage)) {
unlock_page(hpage); unlock_page(hpage);
put_page(hpage); put_hwpoison_page(hpage);
pr_info("soft offline: %#lx hugepage already poisoned\n", pfn); pr_info("soft offline: %#lx hugepage already poisoned\n", pfn);
return -EBUSY; return -EBUSY;
} }
...@@ -1597,7 +1595,7 @@ static int soft_offline_huge_page(struct page *page, int flags) ...@@ -1597,7 +1595,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
* get_any_page() and isolate_huge_page() takes a refcount each, * get_any_page() and isolate_huge_page() takes a refcount each,
* so need to drop one here. * so need to drop one here.
*/ */
put_page(hpage); put_hwpoison_page(hpage);
if (!ret) { if (!ret) {
pr_info("soft offline: %#lx hugepage failed to isolate\n", pfn); pr_info("soft offline: %#lx hugepage failed to isolate\n", pfn);
return -EBUSY; return -EBUSY;
...@@ -1646,7 +1644,7 @@ static int __soft_offline_page(struct page *page, int flags) ...@@ -1646,7 +1644,7 @@ static int __soft_offline_page(struct page *page, int flags)
wait_on_page_writeback(page); wait_on_page_writeback(page);
if (PageHWPoison(page)) { if (PageHWPoison(page)) {
unlock_page(page); unlock_page(page);
put_page(page); put_hwpoison_page(page);
pr_info("soft offline: %#lx page already poisoned\n", pfn); pr_info("soft offline: %#lx page already poisoned\n", pfn);
return -EBUSY; return -EBUSY;
} }
...@@ -1661,7 +1659,7 @@ static int __soft_offline_page(struct page *page, int flags) ...@@ -1661,7 +1659,7 @@ static int __soft_offline_page(struct page *page, int flags)
* would need to fix isolation locking first. * would need to fix isolation locking first.
*/ */
if (ret == 1) { if (ret == 1) {
put_page(page); put_hwpoison_page(page);
pr_info("soft_offline: %#lx: invalidated\n", pfn); pr_info("soft_offline: %#lx: invalidated\n", pfn);
SetPageHWPoison(page); SetPageHWPoison(page);
atomic_long_inc(&num_poisoned_pages); atomic_long_inc(&num_poisoned_pages);
...@@ -1678,7 +1676,7 @@ static int __soft_offline_page(struct page *page, int flags) ...@@ -1678,7 +1676,7 @@ static int __soft_offline_page(struct page *page, int flags)
* Drop page reference which is came from get_any_page() * Drop page reference which is came from get_any_page()
* successful isolate_lru_page() already took another one. * successful isolate_lru_page() already took another one.
*/ */
put_page(page); put_hwpoison_page(page);
if (!ret) { if (!ret) {
LIST_HEAD(pagelist); LIST_HEAD(pagelist);
inc_zone_page_state(page, NR_ISOLATED_ANON + inc_zone_page_state(page, NR_ISOLATED_ANON +
...@@ -1741,7 +1739,7 @@ int soft_offline_page(struct page *page, int flags) ...@@ -1741,7 +1739,7 @@ int soft_offline_page(struct page *page, int flags)
if (PageHWPoison(page)) { if (PageHWPoison(page)) {
pr_info("soft offline: %#lx page already poisoned\n", pfn); pr_info("soft offline: %#lx page already poisoned\n", pfn);
if (flags & MF_COUNT_INCREASED) if (flags & MF_COUNT_INCREASED)
put_page(page); put_hwpoison_page(page);
return -EBUSY; return -EBUSY;
} }
if (!PageHuge(page) && PageTransHuge(hpage)) { if (!PageHuge(page) && PageTransHuge(hpage)) {
...@@ -1749,7 +1747,7 @@ int soft_offline_page(struct page *page, int flags) ...@@ -1749,7 +1747,7 @@ int soft_offline_page(struct page *page, int flags)
pr_info("soft offline: %#lx: failed to split THP\n", pr_info("soft offline: %#lx: failed to split THP\n",
pfn); pfn);
if (flags & MF_COUNT_INCREASED) if (flags & MF_COUNT_INCREASED)
put_page(page); put_hwpoison_page(page);
return -EBUSY; return -EBUSY;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment