diff options
author | Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> | 2015-09-08 18:03:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-08 18:35:28 -0400 |
commit | 8e30456b6c56029ecbb43b777519175e478adfbf (patch) | |
tree | df04df3e4f4d975d19acc0bf555fecd91b2e258d /mm/memory-failure.c | |
parent | 665d9da7f0a9bd80b64d0024630806e45c7ff7d7 (diff) |
mm/hwpoison: introduce num_poisoned_pages wrappers
num_poisoned_pages counter will be changed outside mm/memory-failure.c
by a subsequent patch, so this patch prepares wrappers to manipulate it.
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Tested-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memory-failure.c')
-rw-r--r-- | mm/memory-failure.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 5420d3819adf..393ea13b0754 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c | |||
@@ -1121,7 +1121,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags) | |||
1121 | nr_pages = 1 << compound_order(hpage); | 1121 | nr_pages = 1 << compound_order(hpage); |
1122 | else /* normal page or thp */ | 1122 | else /* normal page or thp */ |
1123 | nr_pages = 1; | 1123 | nr_pages = 1; |
1124 | atomic_long_add(nr_pages, &num_poisoned_pages); | 1124 | num_poisoned_pages_add(nr_pages); |
1125 | 1125 | ||
1126 | /* | 1126 | /* |
1127 | * We need/can do nothing about count=0 pages. | 1127 | * We need/can do nothing about count=0 pages. |
@@ -1149,7 +1149,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags) | |||
1149 | if (PageHWPoison(hpage)) { | 1149 | if (PageHWPoison(hpage)) { |
1150 | if ((hwpoison_filter(p) && TestClearPageHWPoison(p)) | 1150 | if ((hwpoison_filter(p) && TestClearPageHWPoison(p)) |
1151 | || (p != hpage && TestSetPageHWPoison(hpage))) { | 1151 | || (p != hpage && TestSetPageHWPoison(hpage))) { |
1152 | atomic_long_sub(nr_pages, &num_poisoned_pages); | 1152 | num_poisoned_pages_sub(nr_pages); |
1153 | unlock_page(hpage); | 1153 | unlock_page(hpage); |
1154 | return 0; | 1154 | return 0; |
1155 | } | 1155 | } |
@@ -1173,7 +1173,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags) | |||
1173 | else | 1173 | else |
1174 | pr_err("MCE: %#lx: thp split failed\n", pfn); | 1174 | pr_err("MCE: %#lx: thp split failed\n", pfn); |
1175 | if (TestClearPageHWPoison(p)) | 1175 | if (TestClearPageHWPoison(p)) |
1176 | atomic_long_sub(nr_pages, &num_poisoned_pages); | 1176 | num_poisoned_pages_sub(nr_pages); |
1177 | put_hwpoison_page(p); | 1177 | put_hwpoison_page(p); |
1178 | return -EBUSY; | 1178 | return -EBUSY; |
1179 | } | 1179 | } |
@@ -1233,14 +1233,14 @@ int memory_failure(unsigned long pfn, int trapno, int flags) | |||
1233 | */ | 1233 | */ |
1234 | if (!PageHWPoison(p)) { | 1234 | if (!PageHWPoison(p)) { |
1235 | printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn); | 1235 | printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn); |
1236 | atomic_long_sub(nr_pages, &num_poisoned_pages); | 1236 | num_poisoned_pages_sub(nr_pages); |
1237 | unlock_page(hpage); | 1237 | unlock_page(hpage); |
1238 | put_hwpoison_page(hpage); | 1238 | put_hwpoison_page(hpage); |
1239 | return 0; | 1239 | return 0; |
1240 | } | 1240 | } |
1241 | if (hwpoison_filter(p)) { | 1241 | if (hwpoison_filter(p)) { |
1242 | if (TestClearPageHWPoison(p)) | 1242 | if (TestClearPageHWPoison(p)) |
1243 | atomic_long_sub(nr_pages, &num_poisoned_pages); | 1243 | num_poisoned_pages_sub(nr_pages); |
1244 | unlock_page(hpage); | 1244 | unlock_page(hpage); |
1245 | put_hwpoison_page(hpage); | 1245 | put_hwpoison_page(hpage); |
1246 | return 0; | 1246 | return 0; |
@@ -1469,7 +1469,7 @@ int unpoison_memory(unsigned long pfn) | |||
1469 | return 0; | 1469 | return 0; |
1470 | } | 1470 | } |
1471 | if (TestClearPageHWPoison(p)) | 1471 | if (TestClearPageHWPoison(p)) |
1472 | atomic_long_dec(&num_poisoned_pages); | 1472 | num_poisoned_pages_dec(); |
1473 | pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn); | 1473 | pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn); |
1474 | return 0; | 1474 | return 0; |
1475 | } | 1475 | } |
@@ -1483,7 +1483,7 @@ int unpoison_memory(unsigned long pfn) | |||
1483 | */ | 1483 | */ |
1484 | if (TestClearPageHWPoison(page)) { | 1484 | if (TestClearPageHWPoison(page)) { |
1485 | pr_info("MCE: Software-unpoisoned page %#lx\n", pfn); | 1485 | pr_info("MCE: Software-unpoisoned page %#lx\n", pfn); |
1486 | atomic_long_sub(nr_pages, &num_poisoned_pages); | 1486 | num_poisoned_pages_sub(nr_pages); |
1487 | freeit = 1; | 1487 | freeit = 1; |
1488 | if (PageHuge(page)) | 1488 | if (PageHuge(page)) |
1489 | clear_page_hwpoison_huge_page(page); | 1489 | clear_page_hwpoison_huge_page(page); |
@@ -1619,11 +1619,10 @@ static int soft_offline_huge_page(struct page *page, int flags) | |||
1619 | if (PageHuge(page)) { | 1619 | if (PageHuge(page)) { |
1620 | set_page_hwpoison_huge_page(hpage); | 1620 | set_page_hwpoison_huge_page(hpage); |
1621 | dequeue_hwpoisoned_huge_page(hpage); | 1621 | dequeue_hwpoisoned_huge_page(hpage); |
1622 | atomic_long_add(1 << compound_order(hpage), | 1622 | num_poisoned_pages_add(1 << compound_order(hpage)); |
1623 | &num_poisoned_pages); | ||
1624 | } else { | 1623 | } else { |
1625 | SetPageHWPoison(page); | 1624 | SetPageHWPoison(page); |
1626 | atomic_long_inc(&num_poisoned_pages); | 1625 | num_poisoned_pages_inc(); |
1627 | } | 1626 | } |
1628 | } | 1627 | } |
1629 | return ret; | 1628 | return ret; |
@@ -1662,7 +1661,7 @@ static int __soft_offline_page(struct page *page, int flags) | |||
1662 | put_hwpoison_page(page); | 1661 | put_hwpoison_page(page); |
1663 | pr_info("soft_offline: %#lx: invalidated\n", pfn); | 1662 | pr_info("soft_offline: %#lx: invalidated\n", pfn); |
1664 | SetPageHWPoison(page); | 1663 | SetPageHWPoison(page); |
1665 | atomic_long_inc(&num_poisoned_pages); | 1664 | num_poisoned_pages_inc(); |
1666 | return 0; | 1665 | return 0; |
1667 | } | 1666 | } |
1668 | 1667 | ||
@@ -1683,7 +1682,7 @@ static int __soft_offline_page(struct page *page, int flags) | |||
1683 | page_is_file_cache(page)); | 1682 | page_is_file_cache(page)); |
1684 | list_add(&page->lru, &pagelist); | 1683 | list_add(&page->lru, &pagelist); |
1685 | if (!TestSetPageHWPoison(page)) | 1684 | if (!TestSetPageHWPoison(page)) |
1686 | atomic_long_inc(&num_poisoned_pages); | 1685 | num_poisoned_pages_dec(); |
1687 | ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, | 1686 | ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, |
1688 | MIGRATE_SYNC, MR_MEMORY_FAILURE); | 1687 | MIGRATE_SYNC, MR_MEMORY_FAILURE); |
1689 | if (ret) { | 1688 | if (ret) { |
@@ -1699,7 +1698,7 @@ static int __soft_offline_page(struct page *page, int flags) | |||
1699 | if (ret > 0) | 1698 | if (ret > 0) |
1700 | ret = -EIO; | 1699 | ret = -EIO; |
1701 | if (TestClearPageHWPoison(page)) | 1700 | if (TestClearPageHWPoison(page)) |
1702 | atomic_long_dec(&num_poisoned_pages); | 1701 | num_poisoned_pages_dec(); |
1703 | } | 1702 | } |
1704 | } else { | 1703 | } else { |
1705 | pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n", | 1704 | pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n", |
@@ -1765,11 +1764,10 @@ int soft_offline_page(struct page *page, int flags) | |||
1765 | if (PageHuge(page)) { | 1764 | if (PageHuge(page)) { |
1766 | set_page_hwpoison_huge_page(hpage); | 1765 | set_page_hwpoison_huge_page(hpage); |
1767 | if (!dequeue_hwpoisoned_huge_page(hpage)) | 1766 | if (!dequeue_hwpoisoned_huge_page(hpage)) |
1768 | atomic_long_add(1 << compound_order(hpage), | 1767 | num_poisoned_pages_add(1 << compound_order(hpage)); |
1769 | &num_poisoned_pages); | ||
1770 | } else { | 1768 | } else { |
1771 | if (!TestSetPageHWPoison(page)) | 1769 | if (!TestSetPageHWPoison(page)) |
1772 | atomic_long_inc(&num_poisoned_pages); | 1770 | num_poisoned_pages_inc(); |
1773 | } | 1771 | } |
1774 | } | 1772 | } |
1775 | return ret; | 1773 | return ret; |