linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: folio: use copy_highpage() instead of folio_migrate_copy() when copy once
@ 2021-07-27  3:32 Wang Qing
  2021-07-27 11:46 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Qing @ 2021-07-27  3:32 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, linux-kernel; +Cc: Wang Qing

folio_migrate_copy() will call cond_resched(), even if it only needs to be
copied once, restore the previous implementation before there is a better
solution: use copy_highpage() when copy once.

Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
___might_sleep.cold+0x1f3/0x239 kernel/sched/core.c:9182
folio_copy+0x10c/0x1a0 mm/util.c:761
folio_migrate_copy+0x19/0x30 mm/migrate.c:619
__buffer_migrate_page+0x820/0xa80 mm/migrate.c:757
move_to_new_page+0x339/0xf00 mm/migrate.c:904
__unmap_and_move mm/migrate.c:1069 [inline]
unmap_and_move mm/migrate.c:1210 [inline]
migrate_pages+0x2867/0x3890 mm/migrate.c:1487
compact_zone+0x1abb/0x3860 mm/compaction.c:2393
kcompactd_do_work+0x2c9/0x730 mm/compaction.c:2808
kcompactd+0x262/0xd10 mm/compaction.c:2903
kthread+0x3e5/0x4d0 kernel/kthread.c:319
 
Reported-by: syzbot+bb4c69145b4a52b40b27@syzkaller.appspotmail.com
Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 mm/folio-compat.c |  6 ------
 mm/migrate.c      | 15 +++++++++++----
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/mm/folio-compat.c b/mm/folio-compat.c
index 5b6ae1d..13ec6aa
--- a/mm/folio-compat.c
+++ b/mm/folio-compat.c
@@ -64,12 +64,6 @@ void migrate_page_states(struct page *newpage, struct page *page)
 	folio_migrate_flags(page_folio(newpage), page_folio(page));
 }
 EXPORT_SYMBOL(migrate_page_states);
-
-void migrate_page_copy(struct page *newpage, struct page *page)
-{
-	folio_migrate_copy(page_folio(newpage), page_folio(page));
-}
-EXPORT_SYMBOL(migrate_page_copy);
 #endif
 
 bool set_page_writeback(struct page *page)
diff --git a/mm/migrate.c b/mm/migrate.c
index 7d06515..8fb796b
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -614,12 +614,19 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio)
 }
 EXPORT_SYMBOL(folio_migrate_flags);
 
-void folio_migrate_copy(struct folio *newfolio, struct folio *folio)
+void migrate_page_copy(struct page *newpage, struct page *page)
 {
-	folio_copy(newfolio, folio);
+	struct folio *newfolio = page_folio(newpage);
+	struct folio *folio = page_folio(page);
+
+	if (PageHuge(page) || PageTransHuge(page))
+		folio_copy(newfolio, folio);
+	else
+		copy_highpage(newpage, page);
+
 	folio_migrate_flags(newfolio, folio);
 }
-EXPORT_SYMBOL(folio_migrate_copy);
+EXPORT_SYMBOL(migrate_page_copy);
 
 /************************************************************
  *                    Migration functions
@@ -647,7 +654,7 @@ int migrate_page(struct address_space *mapping,
 		return rc;
 
 	if (mode != MIGRATE_SYNC_NO_COPY)
-		folio_migrate_copy(newfolio, folio);
+		migrate_page_copy(newpage, page);
 	else
 		folio_migrate_flags(newfolio, folio);
 	return MIGRATEPAGE_SUCCESS;
-- 
2.7.4



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: folio: use copy_highpage() instead of folio_migrate_copy() when copy once
  2021-07-27  3:32 [PATCH] mm: folio: use copy_highpage() instead of folio_migrate_copy() when copy once Wang Qing
@ 2021-07-27 11:46 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2021-07-27 11:46 UTC (permalink / raw)
  To: Wang Qing; +Cc: Andrew Morton, linux-mm, linux-kernel

On Tue, Jul 27, 2021 at 11:32:54AM +0800, Wang Qing wrote:
> folio_migrate_copy() will call cond_resched(), even if it only needs to be
> copied once, restore the previous implementation before there is a better
> solution: use copy_highpage() when copy once.

no.  i already fixed this on july 22.

https://lore.kernel.org/linux-mm/YPmB60EwQPpEvdb%2F@casper.infradead.org/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-27 11:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27  3:32 [PATCH] mm: folio: use copy_highpage() instead of folio_migrate_copy() when copy once Wang Qing
2021-07-27 11:46 ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).