First off, sorry for the long delay getting back to you. I was sick for a few weeks and still catching up. I'm still not 100%. On Thu, Dec 08, 2022 at 05:51:11PM +0100, Vlastimil Babka wrote: > On 11/29/22 16:16, Mel Gorman wrote: > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index da746e9eb2cf..e2b65767dda0 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -3710,7 +3710,7 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone, > > * reserved for high-order atomic allocation, so order-0 > > * request should skip it. > > */ > > - if (order > 0 && alloc_flags & ALLOC_HARDER) > > + if (alloc_flags & ALLOC_HIGHATOMIC) > > page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); > > if (!page) { > > page = __rmqueue(zone, order, migratetype, alloc_flags); > > @@ -4028,8 +4028,10 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, > > return true; > > } > > #endif > > - if (alloc_harder && !free_area_empty(area, MIGRATE_HIGHATOMIC)) > > + if ((alloc_flags & ALLOC_HIGHATOMIC) && > > + !free_area_empty(area, MIGRATE_HIGHATOMIC)) { > > return true; > > alloc_harder is defined as > (alloc_flags & (ALLOC_HARDER|ALLOC_OOM)); > AFAICS this means we no longer allow ALLOC_OOM to use the highatomic > reserve. Isn't that a risk? > Yes, it is. I intend to apply the patch below on top. I didn't alter the first check for ALLOC_HIGHATOMIC as I wanted OOM handling to only use the high-order reserves if there was no other option. While this is a change in behaviour, it should be a harmless one. I'll add a note in the changelog. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 50fc1e7cb154..0ef4f3236a5a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3710,6 +3710,16 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone, page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); if (!page) { page = __rmqueue(zone, order, migratetype, alloc_flags); + + /* + * If the allocation fails, allow OOM handling access + * to HIGHATOMIC reserves as failing now is worse than + * failing a high-order atomic allocation in the + * future. + */ + if (!page && (alloc_flags & ALLOC_OOM)) + page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); + if (!page) { spin_unlock_irqrestore(&zone->lock, flags); return NULL; @@ -4023,7 +4033,7 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, return true; } #endif - if ((alloc_flags & ALLOC_HIGHATOMIC) && + if ((alloc_flags & (ALLOC_HIGHATOMIC|ALLOC_OOM)) && !free_area_empty(area, MIGRATE_HIGHATOMIC)) { return true; } -- Mel Gorman SUSE Labs