The free pages in the buddy system may well have no PG_buddy set. Introduce is_free_buddy_page() for detecting them reliably. Signed-off-by: Wu Fengguang --- mm/internal.h | 3 +++ mm/memory-failure.c | 24 +++++++++--------------- mm/page_alloc.c | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 15 deletions(-) --- sound-2.6.orig/mm/memory-failure.c +++ sound-2.6/mm/memory-failure.c @@ -324,15 +324,15 @@ struct hwpoison_control { * Do nothing, try to be lucky and not touch this instead. For a few cases we * could be more sophisticated. */ -static int me_kernel(struct hwpoison_control *hpc) +static int me_slab(struct hwpoison_control *hpc) { return DELAYED; } /* - * Already poisoned page. + * Reserved kernel page. */ -static int me_ignore(struct hwpoison_control *hpc) +static int me_reserved(struct hwpoison_control *hpc) { return IGNORED; } @@ -347,14 +347,6 @@ static int me_unknown(struct hwpoison_co } /* - * Free memory - */ -static int me_free(struct hwpoison_control *hpc) -{ - return DELAYED; -} - -/* * Clean (or cleaned) page cache page. */ static int me_pagecache_clean(struct hwpoison_control *hpc) @@ -539,15 +531,14 @@ static struct page_state { char *msg; int (*action)(struct hwpoison_control *hpc); } error_states[] = { - { reserved, reserved, "reserved kernel", me_ignore }, - { buddy, buddy, "free kernel", me_free }, + { reserved, reserved, "reserved kernel", me_reserved }, /* * Could in theory check if slab page is free or if we can drop * currently unused objects without touching them. But just * treat it as standard kernel for now. */ - { slab, slab, "kernel slab", me_kernel }, + { slab, slab, "kernel slab", me_slab }, #ifdef CONFIG_PAGEFLAGS_EXTENDED { head, head, "huge", me_huge_page }, @@ -756,7 +747,10 @@ void memory_failure(unsigned long pfn, i * that may make page_freeze_refs()/page_unfreeze_refs() mismatch. */ if (!get_page_unless_zero(p)) { - action_result(&hpc, "free or high order kernel", IGNORED); + if (is_free_buddy_page(p)) + action_result(&hpc, "free buddy", DELAYED); + else + action_result(&hpc, "high order kernel", IGNORED); return; } --- sound-2.6.orig/mm/internal.h +++ sound-2.6/mm/internal.h @@ -49,6 +49,9 @@ extern void putback_lru_page(struct page extern unsigned long highest_memmap_pfn; extern void __free_pages_bootmem(struct page *page, unsigned int order); extern void prep_compound_page(struct page *page, unsigned long order); +#ifdef CONFIG_MEMORY_FAILURE +extern bool is_free_buddy_page(struct page *page); +#endif /* --- sound-2.6.orig/mm/page_alloc.c +++ sound-2.6/mm/page_alloc.c @@ -4966,3 +4966,19 @@ __offline_isolated_pages(unsigned long s spin_unlock_irqrestore(&zone->lock, flags); } #endif + +#ifdef CONFIG_MEMORY_FAILURE +bool is_free_buddy_page(struct page *page) +{ + int pfn = page_to_pfn(page); + int order; + + for (order = 0; order < MAX_ORDER; order++) { + struct page *page_head = page - (pfn & ((1 << order) - 1)); + + if (PageBuddy(page_head) && page_order(page_head) >= order) + return true; + } + return false; +} +#endif -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/