On Mon, Mar 18, 2019 at 01:21:59PM +0100, Vlastimil Babka wrote: > OK here's a new version that changes the patch to remove __GFP_COMP per > the v2 discussion, and also fixes the bug Kirill spotted (thanks!). > > ----8<---- > From 1fbc84c208573b885f51818ed823f89b3aa1e0ae Mon Sep 17 00:00:00 2001 > From: Vlastimil Babka <vbabka@xxxxxxx> > Date: Thu, 14 Mar 2019 10:19:30 +0100 > Subject: [PATCH v3] mm, page_alloc: disallow __GFP_COMP in alloc_pages_exact() > > alloc_pages_exact*() allocates a page of sufficient order and then splits it > to return only the number of pages requested. That makes it incompatible with > __GFP_COMP, because compound pages cannot be split. > > As shown by [1] things may silently work until the requested size (possibly > depending on user) stops being power of two. Then for CONFIG_DEBUG_VM, BUG_ON() > triggers in split_page(). Without CONFIG_DEBUG_VM, consequences are unclear. > > There are several options here, none of them great: > > 1) Don't do the spliting when __GFP_COMP is passed, and return the whole > compound page. However if caller then returns it via free_pages_exact(), > that will be unexpected and the freeing actions there will be wrong. > > 2) Warn and remove __GFP_COMP from the flags. But the caller may have really > wanted it, so things may break later somewhere. > > 3) Warn and return NULL. However NULL may be unexpected, especially for > small sizes. > > This patch picks option 2, because as Michal Hocko put it: "callers wanted it" > is much less probable than "caller is simply confused and more gfp flags is > surely better than fewer". > > [1] https://lore.kernel.org/lkml/20181126002805.GI18977@shao2-debian/T/#u > > Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx> Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> -- Kirill A. Shutemov