[Devel] [PATCH RH9 03/23] mm/vmalloc: add v[mz]alloc_account helpers

Vasily Averin vvs at virtuozzo.com
Sun Sep 26 13:05:57 MSK 2021


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

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
(cherry picked from commit 634f4e15e07b80d1d02404284da9d5ebce7f9a69)
VvS: rebase to rh9
https://jira.sw.ru/browse/PSBM-133990
Signed-off-by: Vasily Averin <vvs 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 2644425b6dce..dee19cac4b5c 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -138,6 +138,8 @@ static inline unsigned long vmalloc_nr_pages(void) { return 0; }
 
 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 d5cd52805149..fe575cdba254 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3087,6 +3087,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.25.1



More information about the Devel mailing list