On Wed 08-07-20 16:27:16, Aneesh Kumar K.V wrote: > Vlastimil Babka <vbabka@xxxxxxx> writes: > > > On 7/8/20 9:41 AM, Michal Hocko wrote: > >> On Wed 08-07-20 16:16:02, Joonsoo Kim wrote: > >>> On Tue, Jul 07, 2020 at 01:22:31PM +0200, Vlastimil Babka wrote: > >>> > >>> Simply, I call memalloc_nocma_{save,restore} in new_non_cma_page(). It > >>> would not cause any problem. > >> > >> I believe a proper fix is the following. The scope is really defined for > >> FOLL_LONGTERM pins and pushing it inside check_and_migrate_cma_pages > >> will solve the problem as well but it imho makes more sense to do it in > >> the caller the same way we do for any others. > >> > >> Fixes: 9a4e9f3b2d73 ("mm: update get_user_pages_longterm to migrate pages allocated from CMA region") > > > > Agreed. > > > >> > >> I am not sure this is worth backporting to stable yet. > > > > CC Aneesh. > > > > Context: since check_and_migrate_cma_pages() calls __get_user_pages_locked(), it > > should also be called under memalloc_nocma_save(). > > But by then we faulted in all relevant pages and migrated them out of > CMA rea right? check_and_migrate_cma_pages will allocate target pages that you want to migrate off the CMA region unless I am misreading the code. And those allocation need to be placed outside of the CMA. -- Michal Hocko SUSE Labs