]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/page_alloc: add missing is_migrate_isolate() check in set_page_guard()
authorMiaohe Lin <linmiaohe@huawei.com>
Fri, 16 Sep 2022 07:22:49 +0000 (15:22 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 3 Oct 2022 21:03:29 +0000 (14:03 -0700)
In MIGRATE_ISOLATE case, zone freepage state shouldn't be modified as
caller will take care of it.  Add missing is_migrate_isolate() here to
avoid possible unbalanced freepage state.  This would happen if someone
isolates the block, and then we face an MCE failure/soft-offline on a page
within that block.  __mod_zone_freepage_state() will be triggered via
below call trace which already had been triggered back when block was
isolated:

take_page_off_buddy
  break_down_buddy_pages
    set_page_guard

Link: https://lkml.kernel.org/r/20220916072257.9639-9-linmiaohe@huawei.com
Fixes: 7d277115b0bf ("mm,hwpoison: rework soft offline for free pages")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_alloc.c

index 43114e172592d9754f41e02b704f609481ad7518..c055b4cd37f01084f0714744d0495a199ea562b0 100644 (file)
@@ -873,7 +873,8 @@ static inline bool set_page_guard(struct zone *zone, struct page *page,
        INIT_LIST_HEAD(&page->buddy_list);
        set_page_private(page, order);
        /* Guard pages are not available for any usage */
-       __mod_zone_freepage_state(zone, -(1 << order), migratetype);
+       if (!is_migrate_isolate(migratetype))
+               __mod_zone_freepage_state(zone, -(1 << order), migratetype);
 
        return true;
 }