Re: [PATCH v3 21/26] mm/page_alloc: implement FREETYPE_UNMAPPED allocations
Yosry Ahmed <[email protected]>
| Newsgroups | org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Aug 15, 2026 at 03:30:44PM +0100, Brendan Jackman wrote: > On Fri Aug 7, 2026 at 1:16 AM BST, Yosry Ahmed wrote: > >> diff --git a/mm/compaction.c b/mm/compaction.c > >> index 67b01af024e17..c9eb3947ffc79 100644 > >> --- a/mm/compaction.c > >> +++ b/mm/compaction.c > >> @@ -1393,6 +1393,9 @@ static bool suitable_migration_source(struct compact_control *cc, > >> block_ft = get_pageblock_freetype(page); > >> block_mt = free_to_migratetype(block_ft); > >> > >> + if (freetype_unmapped(get_pageblock_freetype(page))) > >> + return false; > >> + > >> /* > >> * CMA pages can only be taken by ALLOC_CMA requests. For anybody > >> * else, vacating a CMA block consumes free pages the caller > >> @@ -1444,6 +1447,9 @@ static bool suitable_migration_target(struct compact_control *cc, > >> return false; > >> } > >> > >> + if (freetype_unmapped(get_pageblock_freetype(page))) > >> + return false; > >> + > > > > Do we also want to add safety checks in the page migration code? IIUC, > > if we miss a check in the compaction code and try to compact an > > unmapped pageblock the kernel will crash with a #PF in supervisor > > mode. > > Shrug, yeah I would certainly be happy with sprinkling some more > > if (WARN_ON(freetype_unmapped(...))) > return -1; > > here and there. But yeah this feels like a maintainer preference / > philosophy question :D If the machine is gonna crash quite clearly > anyway maybe it's not worth it, I dunno. Hmm not necessarily crash? Right now if we do miss a check and end up trying to migrate an unmapped page we will crash (we actually do, will respond separately). If migration fails, I assume compaction will just fail and we might end up with more reclaim or OOMs, but not necessarily crash? Migration is where we actually access memory, so having checks there to avoid crashes (when possible) seems worthwhile. > > >> if (cc->ignore_block_suitable) > >> return true; > >> >