[Devel] [PATCH rh7 8½/9] vmalloc: add v[mz]alloc_account helpers

Vladimir Davydov vdavydov at virtuozzo.com
Wed Apr 27 03:05:00 PDT 2016


Same as v[mz]alloc, but accounted to kmemcg. Will be used later.

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 include/linux/vmalloc.h |  2 ++
 mm/vmalloc.c            | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 97b987fedec0..6ea82cf30dc1 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -68,6 +68,8 @@ static inline void vmalloc_init(void)
 
 extern void *vmalloc(unsigned long size);
 extern void *vzalloc(unsigned long size);
+extern void *vmalloc_account(unsigned long size);
+extern void *vzalloc_account(unsigned long size);
 extern void *vmalloc_user(unsigned long size);
 extern void *vmalloc_node(unsigned long size, int node);
 extern void *vzalloc_node(unsigned long size, int node);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 32d3744a9c46..a8c2b283699a 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1782,6 +1782,20 @@ void *vzalloc(unsigned long size)
 }
 EXPORT_SYMBOL(vzalloc);
 
+void *vmalloc_account(unsigned long size)
+{
+	return __vmalloc_node_flags(size, NUMA_NO_NODE,
+			GFP_KERNEL_ACCOUNT | __GFP_HIGHMEM);
+}
+EXPORT_SYMBOL(vmalloc_account);
+
+void *vzalloc_account(unsigned long size)
+{
+	return __vmalloc_node_flags(size, NUMA_NO_NODE,
+			GFP_KERNEL_ACCOUNT | __GFP_HIGHMEM | __GFP_ZERO);
+}
+EXPORT_SYMBOL(vzalloc_account);
+
 /**
  * vmalloc_user - allocate zeroed virtually contiguous memory for userspace
  * @size: allocation size
-- 
2.1.4



More information about the Devel mailing list