From: Wen Congyang <we...@cn.fujitsu.com> 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.
CC: David Rientjes <rient...@google.com> CC: Jiang Liu <liu...@gmail.com> CC: Len Brown <len.br...@intel.com> CC: Benjamin Herrenschmidt <b...@kernel.crashing.org> CC: Paul Mackerras <pau...@samba.org> CC: Christoph Lameter <c...@linux.com> Cc: Minchan Kim <minchan....@gmail.com> CC: Andrew Morton <a...@linux-foundation.org> CC: KOSAKI Motohiro <kosaki.motoh...@jp.fujitsu.com> CC: Yasuaki Ishimatsu <isimatu.yasu...@jp.fujitsu.com> Signed-off-by: Wen Congyang <we...@cn.fujitsu.com> --- mm/sparse.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index fac95f2..24072e4 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 -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/