From 1c6c5f8b3bb4fc9247d0cf05179174da6c121af7 Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Thu, 25 Oct 2012 12:14:50 +1100 Subject: [PATCH] memory-hotplug: update mce_bad_pages when removing the memory 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 Cc: David Rientjes Cc: Jiang Liu Cc: Len Brown Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Christoph Lameter Cc: Minchan Kim Cc: KOSAKI Motohiro Cc: Yasuaki Ishimatsu Cc: Dave Hansen Cc: Mel Gorman Signed-off-by: Andrew Morton --- mm/sparse.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mm/sparse.c b/mm/sparse.c index fac95f2888f2..24072e435bf8 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -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 -- 2.39.5