]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
memory-hotplug: update mce_bad_pages when removing the memory
authorWen Congyang <wency@cn.fujitsu.com>
Thu, 25 Oct 2012 01:14:50 +0000 (12:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 25 Oct 2012 03:14:38 +0000 (14:14 +1100)
When we hotremove a memory device, we will free the memory to store struct
page.  If the page is hwpoisoned page, we should decrease mce_bad_pages.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Jiang Liu <liuj97@gmail.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/sparse.c

index fac95f2888f2d1fbe923fd83ff7d43786ac89c58..24072e435bf82014686c43335d1f3b6ef53b41de 100644 (file)
@@ -773,6 +773,23 @@ out:
        return ret;
 }
 
+#ifdef CONFIG_MEMORY_FAILURE
+static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
+{
+       int i;
+
+       if (!memmap)
+               return;
+
+       for (i = 0; i < PAGES_PER_SECTION; i++) {
+               if (PageHWPoison(&memmap[i])) {
+                       atomic_long_sub(1, &mce_bad_pages);
+                       ClearPageHWPoison(&memmap[i]);
+               }
+       }
+}
+#endif
+
 void sparse_remove_one_section(struct zone *zone, struct mem_section *ms)
 {
        struct page *memmap = NULL;
@@ -786,6 +803,10 @@ void sparse_remove_one_section(struct zone *zone, struct mem_section *ms)
                ms->pageblock_flags = NULL;
        }
 
+#ifdef CONFIG_MEMORY_FAILURE
+       clear_hwpoisoned_pages(memmap, PAGES_PER_SECTION);
+#endif
+
        free_section_usemap(memmap, usemap);
 }
 #endif