On Thu, Dec 3, 2020 at 4:17 AM Michal Hocko <mhocko@xxxxxxxx> wrote: > > On Wed 02-12-20 00:23:29, Pavel Tatashin wrote: > [...] > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 611799c72da5..7a6d86d0bc5f 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -3766,20 +3766,25 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) > > return alloc_flags; > > } > > > > -static inline unsigned int current_alloc_flags(gfp_t gfp_mask, > > - unsigned int alloc_flags) > > +static inline unsigned int cma_alloc_flags(gfp_t gfp_mask, > > + unsigned int alloc_flags) > > { > > #ifdef CONFIG_CMA > > - unsigned int pflags = current->flags; > > - > > - if (!(pflags & PF_MEMALLOC_NOMOVABLE) && > > - gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE) > > + if (gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE) > > alloc_flags |= ALLOC_CMA; > > - > > #endif > > return alloc_flags; > > } > > > > +static inline gfp_t current_gfp_checkmovable(gfp_t gfp_mask) > > +{ > > + unsigned int pflags = current->flags; > > + > > + if ((pflags & PF_MEMALLOC_NOMOVABLE)) > > + return gfp_mask & ~__GFP_MOVABLE; > > + return gfp_mask; > > +} > > + > > It sucks that we have to control both ALLOC and gfp flags. But wouldn't > it be simpler and more straightforward to keep current_alloc_flags as is > (module PF rename) and hook the gfp mask evaluation into current_gfp_context > and move it up before the first allocation attempt? We could do that, but perhaps as a separate patch? I am worried about hidden implication of adding extra scope (GFP_NOIO|GFP_NOFS) to the fast path. Also, current_gfp_context() is used elsewhere, and in some places removing __GFP_MOVABLE from gfp_mask means that we will need to also change other things. For example [1], in try_to_free_pages() we call current_gfp_context(gfp_mask) which can reduce the maximum zone idx, yet we simply set it to: reclaim_idx = gfp_zone(gfp_mask), not to the newly determined gfp_mask. [1] https://soleen.com/source/xref/linux/mm/vmscan.c?r=2da9f630#3239 All scope flags > should be applicable to the hot path as well. It would add few cycles to > there but the question is whether that would be noticeable over just > handling PF_MEMALLOC_NOMOVABLE on its own. The cache line would be > pulled in anyway. Let's try it in a separate patch? I will add it in the next version of this series. Thank you, Pasha