Skip to content

Commit 602498f

Browse files
Naoya Horiguchitorvalds
authored andcommitted
mm: soft-offline: fix num_poisoned_pages counting on concurrent events
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: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Acked-by: Dean Nelson <dnelson@redhat.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: <stable@vger.kernel.org> [3.14+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4d61ff6 commit 602498f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mm/memory-failure.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,12 +1777,12 @@ int soft_offline_page(struct page *page, int flags)
17771777
} else if (ret == 0) { /* for free pages */
17781778
if (PageHuge(page)) {
17791779
set_page_hwpoison_huge_page(hpage);
1780-
dequeue_hwpoisoned_huge_page(hpage);
1781-
atomic_long_add(1 << compound_order(hpage),
1780+
if (!dequeue_hwpoisoned_huge_page(hpage))
1781+
atomic_long_add(1 << compound_order(hpage),
17821782
&num_poisoned_pages);
17831783
} else {
1784-
SetPageHWPoison(page);
1785-
atomic_long_inc(&num_poisoned_pages);
1784+
if (!TestSetPageHWPoison(page))
1785+
atomic_long_inc(&num_poisoned_pages);
17861786
}
17871787
}
17881788
unset_migratetype_isolate(page, MIGRATE_MOVABLE);

0 commit comments

Comments
 (0)