Re: [PATCH 12/12] mm, page_alloc: Only enforce watermarks for order-0 allocations
From: Mel Gorman
Date: Wed Aug 26 2015 - 10:53:30 EST
On Wed, Aug 26, 2015 at 03:42:23PM +0200, Vlastimil Babka wrote:
> >@@ -2309,22 +2311,30 @@ static bool __zone_watermark_ok(struct zone *z, unsigned int order,
> > #ifdef CONFIG_CMA
> > /* If allocation can't use CMA areas don't use free CMA pages */
> > if (!(alloc_flags & ALLOC_CMA))
> >- free_cma = zone_page_state(z, NR_FREE_CMA_PAGES);
> >+ free_pages -= zone_page_state(z, NR_FREE_CMA_PAGES);
> > #endif
> >
> >- if (free_pages - free_cma <= min + z->lowmem_reserve[classzone_idx])
> >+ if (free_pages <= min + z->lowmem_reserve[classzone_idx])
> > return false;
> >- for (o = 0; o < order; o++) {
> >- /* At the next order, this order's pages become unavailable */
> >- free_pages -= z->free_area[o].nr_free << o;
> >
> >- /* Require fewer higher order pages to be free */
> >- min >>= 1;
> >+ /* order-0 watermarks are ok */
> >+ if (!order)
> >+ return true;
> >+
> >+ /* Check at least one high-order page is free */
> >+ for (o = order; o < MAX_ORDER; o++) {
> >+ struct free_area *area = &z->free_area[o];
> >+ int mt;
> >+
> >+ if (atomic && area->nr_free)
> >+ return true;
> >
> >- if (free_pages <= min)
> >- return false;
> >+ for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) {
> >+ if (!list_empty(&area->free_list[mt]))
> >+ return true;
> >+ }
>
> I think we really need something like this here:
>
> #ifdef CONFIG_CMA
> if (alloc_flags & ALLOC_CMA)) &&
> !list_empty(&area->free_list[MIGRATE_CMA])
> return true;
> #endif
>
> This is not about CMA and high-order atomic allocations being used at the
> same time. This is about high-order MIGRATE_MOVABLE allocations (that set
> ALLOC_CMA) failing to use MIGRATE_CMA pageblocks, which they should be
> allowed to use. It's complementary to the existing free_pages adjustment
> above.
>
> Maybe there's not many high-order MIGRATE_MOVABLE allocations today, but
> they might increase with the driver migration framework. So why set up us a
> bomb.
>
Ok, that seems sensible. Will apply this hunk on top
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1a4169be1498..10f25bf18665 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2337,6 +2337,13 @@ static bool __zone_watermark_ok(struct zone *z, unsigned int order,
if (!list_empty(&area->free_list[mt]))
return true;
}
+
+#ifdef CONFIG_CMA
+ if ((alloc_flags & ALLOC_CMA) &&
+ !list_empty(&area->free_list[MIGRATE_CMA])) {
+ return true;
+ }
+#endif
}
return false;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/