Re: [PATCH v2] mm, page_alloc: Fix has_unmovable_pages for HugePages

From: Michal Hocko
Date: Thu Dec 20 2018 - 04:12:32 EST


On Thu 20-12-18 00:39:18, Oscar Salvador wrote:
> On Wed, Dec 19, 2018 at 02:25:28PM +0000, Wei Yang wrote:
> > >- iter = round_up(iter + 1, 1<<compound_order(page)) - 1;
> > >+ skip_pages = (1 << compound_order(head)) - (page - head);
> > >+ iter = round_up(iter + 1, skip_pages) - 1;
> >
> > The comment of round_up says round up to next specified power of 2. And
> > second parameter must be a power of 2.
> >
> > Look skip_pages not satisfy this.

Yes this is true but the resulting numbers should be correct even for
skips that are not power of 2 AFAIC. Or do you have any counter example?

>
> At least alloc_gigantic_page() looks for 1GB range, aligned to that.
> But I see that in alloc_contig_range(), the boundaries can differ.
>
> Anyway, unless I am missing something, I think that we could just
> get rid of the round_up() and do something like:
>
> <--
> skip_pages = (1 << compound_order(head)) - (page - head);
> iter = skip_pages - 1;
> --
>
> which looks more simple IMHO.

Agreed!

--
Michal Hocko
SUSE Labs