linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.h.duyck@intel.com>
To: linux-mm@kvack.org, akpm@linux-foundation.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [mm PATCH v2 24/26] mm: Add support for releasing multiple instances of a page
Date: Wed, 02 Nov 2016 07:16:08 -0400	[thread overview]
Message-ID: <20161102111605.79519.37675.stgit@ahduyck-blue-test.jf.intel.com> (raw)
In-Reply-To: <20161102111031.79519.14741.stgit@ahduyck-blue-test.jf.intel.com>

This patch adds 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.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---
 include/linux/gfp.h |    2 ++
 mm/page_alloc.c     |   14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index f8041f9de..4175dca 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -506,6 +506,8 @@ extern struct page *alloc_pages_vma(gfp_t gfp_mask, int order,
 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 --git a/mm/page_alloc.c b/mm/page_alloc.c
index 65e0b51..bb6d7bd 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3938,6 +3938,20 @@ static struct page *__page_frag_refill(struct page_frag_cache *nc,
 	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)
 {

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2016-11-02 17:17 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02 11:12 [mm PATCH v2 00/26] Add support for DMA writable pages being writable by the network stack Alexander Duyck
2016-11-02 11:12 ` [mm PATCH v2 01/26] swiotlb: Drop unused functions swiotlb_map_sg and swiotlb_unmap_sg Alexander Duyck
2016-11-03 14:14   ` Christoph Hellwig
2016-11-03 14:29     ` Konrad Rzeszutek Wilk
2016-11-03 14:45       ` Christoph Hellwig
2016-11-03 15:02         ` Duyck, Alexander H
2016-11-02 11:12 ` [mm PATCH v2 02/26] swiotlb-xen: Enforce return of DMA_ERROR_CODE in mapping function Alexander Duyck
2016-11-02 11:13 ` [mm PATCH v2 03/26] swiotlb: Add support for DMA_ATTR_SKIP_CPU_SYNC Alexander Duyck
2016-11-05 19:39   ` Konrad Rzeszutek Wilk
2016-11-05 23:13     ` Alexander Duyck
2016-11-02 11:13 ` [mm PATCH v2 04/26] arch/arc: Add option to skip sync on DMA mapping Alexander Duyck
2016-11-02 11:13 ` [mm PATCH v2 05/26] arch/arm: Add option to skip sync on DMA map and unmap Alexander Duyck
2016-11-02 11:13 ` [mm PATCH v2 06/26] arch/avr32: Add option to skip sync on DMA map Alexander Duyck
2016-11-02 11:13 ` [mm PATCH v2 07/26] arch/blackfin: " Alexander Duyck
2016-11-02 11:13 ` [mm PATCH v2 08/26] arch/c6x: Add option to skip sync on DMA map and unmap Alexander Duyck
2016-11-02 11:14 ` [mm PATCH v2 09/26] arch/frv: Add option to skip sync on DMA map Alexander Duyck
2016-11-02 11:14 ` [mm PATCH v2 10/26] arch/hexagon: Add option to skip DMA sync as a part of mapping Alexander Duyck
2016-11-02 11:14 ` [mm PATCH v2 11/26] arch/m68k: " Alexander Duyck
2016-11-02 11:14 ` [mm PATCH v2 12/26] arch/metag: Add option to skip DMA sync as a part of map and unmap Alexander Duyck
2016-11-02 11:14 ` [mm PATCH v2 13/26] arch/microblaze: " Alexander Duyck
2016-11-02 11:14 ` [mm PATCH v2 14/26] arch/mips: " Alexander Duyck
2016-11-02 11:14 ` [mm PATCH v2 15/26] arch/nios2: " Alexander Duyck
2016-11-02 11:14 ` [mm PATCH v2 16/26] arch/openrisc: Add option to skip DMA sync as a part of mapping Alexander Duyck
2016-11-02 11:15 ` [mm PATCH v2 17/26] arch/parisc: Add option to skip DMA sync as a part of map and unmap Alexander Duyck
2016-11-02 11:15 ` [mm PATCH v2 18/26] arch/powerpc: Add option to skip DMA sync as a part of mapping Alexander Duyck
2016-11-04  3:16   ` Michael Ellerman
2016-11-02 11:15 ` [mm PATCH v2 19/26] arch/sh: " Alexander Duyck
2016-11-02 11:15 ` [mm PATCH v2 20/26] arch/sparc: Add option to skip DMA sync as a part of map and unmap Alexander Duyck
2016-11-02 11:15 ` [mm PATCH v2 21/26] arch/tile: " Alexander Duyck
2016-11-02 11:15 ` [mm PATCH v2 22/26] arch/xtensa: Add option to skip DMA sync as a part of mapping Alexander Duyck
2016-11-02 11:16 ` [mm PATCH v2 23/26] dma: Add calls for dma_map_page_attrs and dma_unmap_page_attrs Alexander Duyck
2016-11-02 11:16 ` Alexander Duyck [this message]
2016-11-02 11:16 ` [mm PATCH v2 25/26] igb: Update driver to make use of DMA_ATTR_SKIP_CPU_SYNC Alexander Duyck
2016-11-02 11:16 ` [mm PATCH v2 26/26] igb: Update code to better handle incrementing page count Alexander Duyck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161102111605.79519.37675.stgit@ahduyck-blue-test.jf.intel.com \
    --to=alexander.h.duyck@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox