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

From: Brendan Jackman
Date: Tue Feb 25 2025 - 08:44:05 EST


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@xxxxxxxxxxx>

Aside from my WARN bikeshedding, which isn't really about this patch
anyway:

Reviewed-by: Brendan Jackman <jackmanb@xxxxxxxxxx>

> - 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?