Re: [PATCH 2/3] mm: page_alloc: remove remnants of unlocked migratetype updates

Johannes Weiner
2025-02-25T15:09:49Z

On Tue, Feb 25, 2025 at 01:43:35PM +0000, Brendan Jackman wrote:
> On Mon, Feb 24, 2025 at 07:08:25PM -0500, Johannes Weiner wrote:
> > The freelist hygiene patches made migratetype accesses fully protected
> > under the zone->lock. Remove remnants of handling the race conditions
> > that existed before from the MIGRATE_HIGHATOMIC code.
> >
> > Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
>
> Aside from my WARN bikeshedding, which isn't really about this patch
> anyway:
>
> Reviewed-by: Brendan Jackman <jackmanb@google.com>

Thanks

> > - if (is_migrate_highatomic(mt)) {
> > - unsigned long size;
> > - /*
> > - * It should never happen but changes to
> > - * locking could inadvertently allow a per-cpu
> > - * drain to add pages to MIGRATE_HIGHATOMIC
> > - * while unreserving so be safe and watch for
> > - * underflows.
> > - */
> > - size = max(pageblock_nr_pages, 1UL << order);
> > - size = min(size, zone->nr_reserved_highatomic);
> > - zone->nr_reserved_highatomic -= size;
> > - }
> > + size = max(pageblock_nr_pages, 1UL << order);
> > + size = min(size, zone->nr_reserved_highatomic);
> > + zone->nr_reserved_highatomic -= size;
>
> Now that the locking is a bit cleaner, would it make sense to add a
> [VM_]WARN_ON[_ONCE] for underflow?

Yeah I think that would be a nice additional cleanup. Do you want to
send a patch? Otherwise, I can.