Re: [PATCH v2 RESEND update 1/2] mm/page_alloc: free order-0 pages through PCP in page_frag_free()

From: Andrew Morton
Date: Wed Nov 21 2018 - 22:15:18 EST


On Tue, 20 Nov 2018 09:45:44 +0800 Aaron Lu <aaron.lu@xxxxxxxxx> wrote:

> page_frag_free() calls __free_pages_ok() to free the page back to
> Buddy. This is OK for high order page, but for order-0 pages, it
> misses the optimization opportunity of using Per-Cpu-Pages and can
> cause zone lock contention when called frequently.
>

Looks nice to me. Let's tell our readers why we're doing this.

--- a/mm/page_alloc.c~mm-page_alloc-free-order-0-pages-through-pcp-in-page_frag_free-fix
+++ a/mm/page_alloc.c
@@ -4684,7 +4684,7 @@ void page_frag_free(void *addr)
if (unlikely(put_page_testzero(page))) {
unsigned int order = compound_order(page);

- if (order == 0)
+ if (order == 0) /* Via pcp? */
free_unref_page(page);
else
__free_pages_ok(page, order);
_