Re: [PATCH V2 0/6] mm: page_alloc: freelist migratetype hygiene

From: Johannes Weiner
Date: Mon Sep 18 2023 - 12:04:22 EST


On Mon, Sep 18, 2023 at 09:07:53AM +0200, Vlastimil Babka wrote:
> On 9/15/23 16:16, Johannes Weiner wrote:
> > On Thu, Sep 14, 2023 at 04:52:38PM -0700, Mike Kravetz wrote:
> >> In next-20230913, I started hitting the following BUG. Seems related
> >> to this series. And, if series is reverted I do not see the BUG.
> >>
> >> I can easily reproduce on a small 16G VM. kernel command line contains
> >> "hugetlb_free_vmemmap=on hugetlb_cma=4G". Then run the script,
> >> while true; do
> >> echo 4 > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
> >> echo 4 > /sys/kernel/mm/hugepages/hugepages-1048576kB/demote
> >> echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
> >> done
> >>
> >> For the BUG below I believe it was the first (or second) 1G page creation from
> >> CMA that triggered: cma_alloc of 1G.
> >>
> >> Sorry, have not looked deeper into the issue.
> >
> > Thanks for the report, and sorry about the breakage!
> >
> > I was scratching my head at this:
> >
> > /* MIGRATE_ISOLATE page should not go to pcplists */
> > VM_BUG_ON_PAGE(is_migrate_isolate(mt), page);
> >
> > because there is nothing in page isolation that prevents setting
> > MIGRATE_ISOLATE on something that's on the pcplist already. So why
> > didn't this trigger before already?
> >
> > Then it clicked: it used to only check the *pcpmigratetype* determined
> > by free_unref_page(), which of course mustn't be MIGRATE_ISOLATE.
> >
> > Pages that get isolated while *already* on the pcplist are fine, and
> > are handled properly:
> >
> > mt = get_pcppage_migratetype(page);
> >
> > /* MIGRATE_ISOLATE page should not go to pcplists */
> > VM_BUG_ON_PAGE(is_migrate_isolate(mt), page);
> >
> > /* Pageblock could have been isolated meanwhile */
> > if (unlikely(isolated_pageblocks))
> > mt = get_pageblock_migratetype(page);
> >
> > So this was purely a sanity check against the pcpmigratetype cache
> > operations. With that gone, we can remove it.
>
> Agreed, I assume you'll fold it in 1/6 in v3.

Yes, will do.