The patch titled Subject: mm: add support for releasing multiple instances of a page has been added to the -mm tree. Its filename is mm-add-support-for-releasing-multiple-instances-of-a-page.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-add-support-for-releasing-multiple-instances-of-a-page.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-add-support-for-releasing-multiple-instances-of-a-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/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Alexander Duyck <alexander.h.duyck@xxxxxxxxx> Subject: mm: add support for releasing multiple instances of a page Add a function that allows us to batch free a page that has multiple references outstanding. Specifically this function can be used to drop a page being used in the page frag alloc cache. With this drivers can make use of functionality similar to the page frag alloc cache without having to do any workarounds for the fact that there is no function that frees multiple references. Link: http://lkml.kernel.org/r/20161110113606.76501.70752.stgit@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Alexander Duyck <alexander.h.duyck@xxxxxxxxx> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx> Cc: "James E.J. Bottomley" <jejb@xxxxxxxxxxxxxxxx> Cc: Chris Metcalf <cmetcalf@xxxxxxxxxxxx> Cc: David Howells <dhowells@xxxxxxxxxx> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> Cc: Hans-Christian Noren Egtvedt <egtvedt@xxxxxxxxxxxx> Cc: Helge Deller <deller@xxxxxx> Cc: James Hogan <james.hogan@xxxxxxxxxx> Cc: Jeff Kirsher <jeffrey.t.kirsher@xxxxxxxxx> Cc: Jonas Bonn <jonas@xxxxxxxxxxxx> Cc: Keguang Zhang <keguang.zhang@xxxxxxxxx> Cc: Ley Foon Tan <lftan@xxxxxxxxxx> Cc: Mark Salter <msalter@xxxxxxxxxx> Cc: Max Filippov <jcmvbkbc@xxxxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Cc: Michal Simek <monstr@xxxxxxxxx> Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx> Cc: Rich Felker <dalias@xxxxxxxx> Cc: Richard Kuo <rkuo@xxxxxxxxxxxxxx> Cc: Russell King <linux@xxxxxxxxxxxxxxx> Cc: Steven Miao <realmz6@xxxxxxxxx> Cc: Tobias Klauser <tklauser@xxxxxxxxxx> Cc: Vineet Gupta <vgupta@xxxxxxxxxxxx> Cc: Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/gfp.h | 2 ++ mm/page_alloc.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff -puN include/linux/gfp.h~mm-add-support-for-releasing-multiple-instances-of-a-page include/linux/gfp.h --- a/include/linux/gfp.h~mm-add-support-for-releasing-multiple-instances-of-a-page +++ a/include/linux/gfp.h @@ -506,6 +506,8 @@ extern void free_hot_cold_page(struct pa extern void free_hot_cold_page_list(struct list_head *list, bool cold); struct page_frag_cache; +extern void __page_frag_drain(struct page *page, unsigned int order, + unsigned int count); extern void *__alloc_page_frag(struct page_frag_cache *nc, unsigned int fragsz, gfp_t gfp_mask); extern void __free_page_frag(void *addr); diff -puN mm/page_alloc.c~mm-add-support-for-releasing-multiple-instances-of-a-page mm/page_alloc.c --- a/mm/page_alloc.c~mm-add-support-for-releasing-multiple-instances-of-a-page +++ a/mm/page_alloc.c @@ -3917,6 +3917,20 @@ static struct page *__page_frag_refill(s return page; } +void __page_frag_drain(struct page *page, unsigned int order, + unsigned int count) +{ + VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); + + if (page_ref_sub_and_test(page, count)) { + if (order == 0) + free_hot_cold_page(page, false); + else + __free_pages_ok(page, order); + } +} +EXPORT_SYMBOL(__page_frag_drain); + void *__alloc_page_frag(struct page_frag_cache *nc, unsigned int fragsz, gfp_t gfp_mask) { _ Patches currently in -mm which might be from alexander.h.duyck@xxxxxxxxx are arch-arc-add-option-to-skip-sync-on-dma-mapping.patch arch-arm-add-option-to-skip-sync-on-dma-map-and-unmap.patch arch-avr32-add-option-to-skip-sync-on-dma-map.patch arch-blackfin-add-option-to-skip-sync-on-dma-map.patch arch-c6x-add-option-to-skip-sync-on-dma-map-and-unmap.patch arch-frv-add-option-to-skip-sync-on-dma-map.patch arch-hexagon-add-option-to-skip-dma-sync-as-a-part-of-mapping.patch arch-m68k-add-option-to-skip-dma-sync-as-a-part-of-mapping.patch arch-metag-add-option-to-skip-dma-sync-as-a-part-of-map-and-unmap.patch arch-microblaze-add-option-to-skip-dma-sync-as-a-part-of-map-and-unmap.patch arch-mips-add-option-to-skip-dma-sync-as-a-part-of-map-and-unmap.patch arch-nios2-add-option-to-skip-dma-sync-as-a-part-of-map-and-unmap.patch arch-openrisc-add-option-to-skip-dma-sync-as-a-part-of-mapping.patch arch-parisc-add-option-to-skip-dma-sync-as-a-part-of-map-and-unmap.patch arch-powerpc-add-option-to-skip-dma-sync-as-a-part-of-mapping.patch arch-sh-add-option-to-skip-dma-sync-as-a-part-of-mapping.patch arch-sparc-add-option-to-skip-dma-sync-as-a-part-of-map-and-unmap.patch arch-tile-add-option-to-skip-dma-sync-as-a-part-of-map-and-unmap.patch arch-xtensa-add-option-to-skip-dma-sync-as-a-part-of-mapping.patch dma-add-calls-for-dma_map_page_attrs-and-dma_unmap_page_attrs.patch mm-add-support-for-releasing-multiple-instances-of-a-page.patch igb-update-driver-to-make-use-of-dma_attr_skip_cpu_sync.patch igb-update-code-to-better-handle-incrementing-page-count.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html