From: Nick Piggin Date: Wed, 30 Apr 2008 07:55:16 +0000 (-0700) Subject: mm: fix warning on memory offline X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3a902c5f6851cd0b64c33efaa3bd57aa27a82efb;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git mm: fix warning on memory offline KAMEZAWA Hiroyuki found a warning message in the buffer dirtying code that is coming from page migration caller. WARNING: at fs/buffer.c:720 __set_page_dirty+0x330/0x360() Call Trace: [] show_stack+0x80/0xa0 [] dump_stack+0x30/0x60 [] warn_on_slowpath+0x90/0xe0 [] __set_page_dirty+0x330/0x360 [] __set_page_dirty_buffers+0xd0/0x280 [] set_page_dirty+0xc0/0x260 [] migrate_page_copy+0x5d0/0x5e0 [] buffer_migrate_page+0x2e0/0x3c0 [] migrate_pages+0x770/0xe00 What was happening is that migrate_page_copy wants to transfer the PG_dirty bit from old page to new page, so what it would do is set_page_dirty(newpage). However set_page_dirty() is used to set the entire page dirty, wheras in this case, only part of the page was dirty, and it also was not uptodate. Marking the whole page dirty with set_page_dirty would lead to corruption or unresolvable conditions -- a dirty && !uptodate page and dirty && !uptodate buffers. Possibly we could just ClearPageDirty(oldpage); SetPageDirty(newpage); however in the interests of keeping the change minimal... Signed-off-by: Nick Piggin Tested-by: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/migrate.c b/mm/migrate.c index 4e0eccca5e26..449d77d409f5 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -383,7 +383,14 @@ static void migrate_page_copy(struct page *newpage, struct page *page) if (PageDirty(page)) { clear_page_dirty_for_io(page); - set_page_dirty(newpage); + /* + * Want to mark the page and the radix tree as dirty, and + * redo the accounting that clear_page_dirty_for_io undid, + * but we can't use set_page_dirty because that function + * is actually a signal that all of the page has become dirty. + * Wheras only part of our page may be dirty. + */ + __set_page_dirty_nobuffers(newpage); } #ifdef CONFIG_SWAP