Re: [PATCH] page_alloc: Fix freeing non-compound pages

From: Matthew Wilcox
Date: Tue Sep 22 2020 - 10:36:09 EST


On Tue, Sep 22, 2020 at 03:00:17PM +0100, Matthew Wilcox (Oracle) wrote:
> void __free_pages(struct page *page, unsigned int order)
> {
> if (put_page_testzero(page))
> free_the_page(page, order);
> + else
> + while (order-- > 0)
> + free_the_page(page + (1 << order), order);
> }
> EXPORT_SYMBOL(__free_pages);

... a three line patch and one of them is wrong.

- else
+ else if (!PageHead(page))

Anyone got a smart idea about how to _test_ this code path? I'm
wondering about loading one kernel module which wanders through memmap
calling
if (page_cache_get_speculative(page)) put_page(page);
and another kernel module that calls
__free_pages(alloc_page(GFP_KERNEL, 1), 1);

and putting in a printk to let me know when we hit it.