The patch titled Subject: mm/page_alloc.c: use a single function to free page has been added to the -mm tree. Its filename is mm-page_alloc-use-a-single-function-to-free-page.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-page_alloc-use-a-single-function-to-free-page.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-page_alloc-use-a-single-function-to-free-page.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Aaron Lu <aaron.lu@xxxxxxxxx> Subject: mm/page_alloc.c: use a single function to free page There are multiple places of freeing a page, they all do the same things so a common function can be used to reduce code duplicate. It also avoids bug fixed in one function but left in another. Link: http://lkml.kernel.org/r/20181119134834.17765-3-aaron.lu@xxxxxxxxx Signed-off-by: Aaron Lu <aaron.lu@xxxxxxxxx> Acked-by: Vlastimil Babka <vbabka@xxxxxxx> Cc: Alexander Duyck <alexander.h.duyck@xxxxxxxxxxxxxxx> Cc: Ilias Apalodimas <ilias.apalodimas@xxxxxxxxxx> Cc: Jesper Dangaard Brouer <brouer@xxxxxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Cc: Pankaj gupta <pagupta@xxxxxxxxxx> Cc: Pawel Staszewski <pstaszewski@xxxxxxxxx> Cc: Tariq Toukan <tariqt@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/mm/page_alloc.c~mm-page_alloc-use-a-single-function-to-free-page +++ a/mm/page_alloc.c @@ -4551,16 +4551,19 @@ unsigned long get_zeroed_page(gfp_t gfp_ } EXPORT_SYMBOL(get_zeroed_page); -void __free_pages(struct page *page, unsigned int order) +static inline void free_the_page(struct page *page, unsigned int order) { - if (put_page_testzero(page)) { - if (order == 0) - free_unref_page(page); - else - __free_pages_ok(page, order); - } + if (order == 0) /* Via pcp? */ + free_unref_page(page); + else + __free_pages_ok(page, order); } +void __free_pages(struct page *page, unsigned int order) +{ + if (put_page_testzero(page)) + free_the_page(page, order); +} EXPORT_SYMBOL(__free_pages); void free_pages(unsigned long addr, unsigned int order) @@ -4609,14 +4612,8 @@ void __page_frag_cache_drain(struct page { VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); - if (page_ref_sub_and_test(page, count)) { - unsigned int order = compound_order(page); - - if (order == 0) - free_unref_page(page); - else - __free_pages_ok(page, order); - } + if (page_ref_sub_and_test(page, count)) + free_the_page(page, compound_order(page)); } EXPORT_SYMBOL(__page_frag_cache_drain); @@ -4681,14 +4678,8 @@ void page_frag_free(void *addr) { struct page *page = virt_to_head_page(addr); - if (unlikely(put_page_testzero(page))) { - unsigned int order = compound_order(page); - - if (order == 0) /* Via pcp? */ - free_unref_page(page); - else - __free_pages_ok(page, order); - } + if (unlikely(put_page_testzero(page))) + free_the_page(page, compound_order(page)); } EXPORT_SYMBOL(page_frag_free); _ Patches currently in -mm which might be from aaron.lu@xxxxxxxxx are mm-swap-use-nr_node_ids-for-avail_lists-in-swap_info_struct.patch mm-page_alloc-free-order-0-pages-through-pcp-in-page_frag_free.patch mm-page_alloc-use-a-single-function-to-free-page.patch