[Devel] [PATCH RHEL8 COMMIT] kernel/sched: Use kvzalloc to allocate the array of ctl_tables

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jun 10 18:19:46 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.39
------>
commit f3b9b7964548478c52714cd7583c0eb4dc465268
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Thu Jun 10 18:19:46 2021 +0300

    kernel/sched: Use kvzalloc to allocate the array of ctl_tables
    
    On a machine with a lot of cpus, the sd_alloc_entry() can
    trigger a high order allocation, which is slow and may fail
    if memory fragmentation is high. Use kvzalloc to fallback
    0-order allocations if high-order isn't available.
    
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
    
    (cherry picked from vz7 commit 6a6935993911 ("kernel/sched: Use kvzalloc to
    allocate the array of ctl_tables"))
    
    VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127837
    
    Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
 kernel/sched/debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index dd5a97b7c7d8..93d13a33f704 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -210,7 +210,7 @@ static struct ctl_table sd_ctl_root[] = {
 static struct ctl_table *sd_alloc_ctl_entry(int n)
 {
 	struct ctl_table *entry =
-		kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
+		kvzalloc(n * sizeof(struct ctl_table), GFP_KERNEL);
 
 	return entry;
 }
@@ -232,7 +232,7 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
 			kfree(entry->procname);
 	}
 
-	kfree(*tablep);
+	kvfree(*tablep);
 	*tablep = NULL;
 }
 


More information about the Devel mailing list