From: Naoya Horiguchi Date: Wed, 20 Feb 2013 02:14:33 +0000 (+1100) Subject: mm/memory-failure.c: fix wrong num_poisoned_pages in handling memory error on thp X-Git-Tag: next-20130220~1^2~483 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=14b8f1615b7657a6d0f76e23d9891fb5272c45b4;p=karo-tx-linux.git mm/memory-failure.c: fix wrong num_poisoned_pages in handling memory error on thp num_poisoned_pages counts up the number of pages isolated by memory errors. But for thp, only one subpage is isolated because memory error handler splits it, so it's wrong to add (1 << compound_trans_order). Signed-off-by: Naoya Horiguchi Cc: Andi Kleen Cc: Tony Luck Cc: Wu Fengguang Signed-off-by: Andrew Morton --- diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9cab165fd668..9b1e5e7078a1 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1039,7 +1039,17 @@ int memory_failure(unsigned long pfn, int trapno, int flags) return 0; } - nr_pages = 1 << compound_trans_order(hpage); + /* + * Currently errors on hugetlbfs pages are contained in hugepage + * unit, so nr_pages should be 1 << compound_order. OTOH when + * errors are on transparent hugepages, they are supposed to be + * split and error containment is done in normal page unit. + * So nr_pages should be one in this case. + */ + if (PageHuge(p)) + nr_pages = 1 << compound_order(hpage); + else /* normal page or thp */ + nr_pages = 1; atomic_long_add(nr_pages, &num_poisoned_pages); /*