Commit 881241e8 authored by Naoya Horiguchi's avatar Naoya Horiguchi Committed by Sasha Levin

mm: soft-offline: fix num_poisoned_pages counting on concurrent events

[ Upstream commit 602498f9 ]

If multiple soft offline events hit one free page/hugepage concurrently,
soft_offline_page() can handle the free page/hugepage multiple times,
which makes num_poisoned_pages counter increased more than once.  This
patch fixes this wrong counting by checking TestSetPageHWPoison for normal
papes and by checking the return value of dequeue_hwpoisoned_huge_page()
for hugepages.
Signed-off-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Acked-by: default avatarDean Nelson <dnelson@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: <stable@vger.kernel.org>	[3.14+]
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 4e258a15
...@@ -1733,12 +1733,12 @@ int soft_offline_page(struct page *page, int flags) ...@@ -1733,12 +1733,12 @@ int soft_offline_page(struct page *page, int flags)
} else if (ret == 0) { /* for free pages */ } else if (ret == 0) { /* for free pages */
if (PageHuge(page)) { if (PageHuge(page)) {
set_page_hwpoison_huge_page(hpage); set_page_hwpoison_huge_page(hpage);
dequeue_hwpoisoned_huge_page(hpage); if (!dequeue_hwpoisoned_huge_page(hpage))
atomic_long_add(1 << compound_order(hpage), atomic_long_add(1 << compound_order(hpage),
&num_poisoned_pages); &num_poisoned_pages);
} else { } else {
SetPageHWPoison(page); if (!TestSetPageHWPoison(page))
atomic_long_inc(&num_poisoned_pages); atomic_long_inc(&num_poisoned_pages);
} }
} }
unset_migratetype_isolate(page, MIGRATE_MOVABLE); unset_migratetype_isolate(page, MIGRATE_MOVABLE);
......
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