[Devel] [PATCH RHEL COMMIT] mm/vmalloc: add v[mz]alloc_account helpers

Konstantin Khorenko khorenko at virtuozzo.com
Tue Sep 28 14:05:10 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 6253bfcdca0256c1e9902b8fe36ac06799832cf3
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Tue Sep 28 14:05:10 2021 +0300

    mm/vmalloc: add v[mz]alloc_account helpers
    
    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


More information about the Devel mailing list