We have the simpler CONFIG_HWPOISON_ON_FREE :)
+#if defined(CONFIG_MEMORY_FAILURE)&& BITS_PER_LONG == 64
+PAGEFLAG(HWPoisonOnFree, hwpoison_on_free)Could define SETPAGEFLAG_NOOP(HWPoisonOnFree) too, for eliminating an
+TESTSCFLAG(HWPoisonOnFree, hwpoison_on_free)
+#define __PG_HWPOISON_ON_FREE (1UL<< PG_hwpoison_on_free)
+#else
+PAGEFLAG_FALSE(HWPoisonOnFree)
#ifdef in the .c file.
Ok.
}-EIO looks safer because HWPoisonOnFree does not guarantee success.
+
+ if (PageHWPoisonOnFree(page)) {
+ pr_info("soft_offline: %#lx: Delaying poision of unknown page %lx to free\n",
+ pfn, page->flags);
+ return -EIO; /* or 0? */
diff --git a/mm/page_alloc.c b/mm/page_alloc.chwpoison_page_on_free() seems to be undefined when
index a8cfa9c..519c24c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -564,6 +564,8 @@ static inline int free_pages_check(struct page *page)
(page->mapping != NULL) |
(atomic_read(&page->_count) != 0) |
(page->flags& PAGE_FLAGS_CHECK_AT_FREE))) {
+ if (PageHWPoisonOnFree(page))
+ hwpoison_page_on_free(page);
CONFIG_HWPOISON_ON_FREE is not defined.