[Devel] [PATCH RHEL7 COMMIT] gfp: add __get_free_kmem_pages helper

Vladimir Davydov vdavydov at odin.com
Mon Sep 7 03:15:47 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.6.7
------>
commit 062f5a65f378f56a06edd3b6a4b42356c5bf5aba
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Mon Sep 7 14:15:47 2015 +0400

    gfp: add __get_free_kmem_pages helper
    
    Works exactly as __get_free_pages except it also tries to charge newly
    allocated pages to memcg/kmem. It will be used by the next patch.
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
    Reviewed-by: Kirill Tkhai <ktkhai at odin.com>
---
 include/linux/gfp.h |  1 +
 mm/page_alloc.c     | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index f1d510ef6b74..19b20134dfc6 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -358,6 +358,7 @@ extern struct page *alloc_kmem_pages_node(int nid, gfp_t gfp_mask,
 					  unsigned int order);
 
 extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order);
+extern unsigned long __get_free_kmem_pages(gfp_t gfp_mask, unsigned int order);
 extern unsigned long get_zeroed_page(gfp_t gfp_mask);
 
 void *alloc_pages_exact(size_t size, gfp_t gfp_mask);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0dbb6e95061e..c479b9aa36bd 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2809,6 +2809,18 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)
 }
 EXPORT_SYMBOL(__get_free_pages);
 
+unsigned long __get_free_kmem_pages(gfp_t gfp_mask, unsigned int order)
+{
+	struct page *page;
+
+	VM_BUG_ON((gfp_mask & __GFP_HIGHMEM) != 0);
+
+	page = alloc_kmem_pages(gfp_mask, order);
+	if (!page)
+		return 0;
+	return (unsigned long) page_address(page);
+}
+
 unsigned long get_zeroed_page(gfp_t gfp_mask)
 {
 	return __get_free_pages(gfp_mask | __GFP_ZERO, 0);



More information about the Devel mailing list