Re: [PATCH v3 4/8] mm/hugetlb: make hugetlb migration callback CMA aware

From: Michal Hocko
Date: Tue Jun 30 2020 - 02:43:02 EST


On Tue 30-06-20 15:30:04, Joonsoo Kim wrote:
> 2020ë 6ì 29ì (ì) ìí 4:55, Michal Hocko <mhocko@xxxxxxxxxx>ëì ìì:
[...]
> > diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> > index 57ece74e3aae..c1595b1d36f3 100644
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -1092,10 +1092,14 @@ static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask,
> > /* Movability of hugepages depends on migration support. */
> > static inline gfp_t htlb_alloc_mask(struct hstate *h)
> > {
> > + gfp_t gfp;
> > +
> > if (hugepage_movable_supported(h))
> > - return GFP_HIGHUSER_MOVABLE;
> > + gfp = GFP_HIGHUSER_MOVABLE;
> > else
> > - return GFP_HIGHUSER;
> > + gfp = GFP_HIGHUSER;
> > +
> > + return current_gfp_context(gfp);
> > }
> >
> > static struct page *dequeue_huge_page_vma(struct hstate *h,
> >
> > If we even fix this general issue for other allocations and allow a
> > better CMA exclusion then it would be implemented consistently for
> > everybody.
>
> Yes, I have reviewed the memalloc_nocma_{} APIs and found the better way
> for CMA exclusion. I will do it after this patch is finished.
>
> > Does this make more sense to you are we still not on the same page wrt
> > to the actual problem?
>
> Yes, but we have different opinions about it. As said above, I will make
> a patch for better CMA exclusion after this patchset. It will make
> code consistent.
> I'd really appreciate it if you wait until then.

As I've said I would _prefer_ simplicity over "correctness" if it is only
partial and hard to reason about from the userspace experience but this
is not something I would _insist_ on. If Mike as a maintainer of the
code is ok with that then I will not stand in the way.

But please note that a missing current_gfp_context inside
htlb_alloc_mask is a subtle bug. I do not think it matters right now but
with a growing use of scoped apis this might actually hit some day so I
believe we want to have it in place.

Thanks!

--
Michal Hocko
SUSE Labs