Re: [PATCH RFC 4/4] mm/page_alloc: place pages to tail in __free_pages_core()

From: Oscar Salvador
Date: Mon Sep 28 2020 - 03:58:33 EST


On Wed, Sep 16, 2020 at 08:34:11PM +0200, David Hildenbrand wrote:
> @@ -1523,7 +1524,13 @@ void __free_pages_core(struct page *page, unsigned int order)
>
> atomic_long_add(nr_pages, &page_zone(page)->managed_pages);
> set_page_refcounted(page);
> - __free_pages(page, order);
> +
> + /*
> + * Bypass PCP and place fresh pages right to the tail, primarily
> + * relevant for memory onlining.
> + */
> + page_ref_dec(page);
> + __free_pages_ok(page, order, FOP_TO_TAIL);

Sorry, I must be missing something obvious here, but I am a bit confused here.
I get the part of placing them at the tail so rmqueue_bulk() won't
find them, but I do not get why we decrement page's refcount.
IIUC, its refcount will be 0, but why do we want to do that?

Another thing a bit unrelated... we mess three times with page's refcount
(two before this patch).
Why do we have this dance in place?

Thanks

--
Oscar Salvador
SUSE L3