[RHEL7,COMMIT] kernel/sched: Use kvzalloc to allocate the array of ctl_tables

Submitted by Konstantin Khorenko on Aug. 13, 2018, 3:08 p.m.

Details

Message ID 201808131508.w7DF8ADW030071@finist_ce7.work
State New
Series "kernel/sched: Use kvzalloc to allocate the array of ctl_tables."
Headers show

Commit Message

Konstantin Khorenko Aug. 13, 2018, 3:08 p.m.
The commit is pushed to "branch-rh7-3.10.0-862.9.1.vz7.70.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.9.1.vz7.70.2
------>
commit 0d1e2748f6f34d3676d7774c86d29f691c2551c0
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Mon Aug 13 18:08:10 2018 +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@virtuozzo.com>
---
 kernel/sched/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 26f4959f9ab4..e572d2b14a7f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6422,7 +6422,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;
 }
@@ -6444,7 +6444,7 @@  static void sd_free_ctl_entry(struct ctl_table **tablep)
 			kfree(entry->procname);
 	}
 
-	kfree(*tablep);
+	kvfree(*tablep);
 	*tablep = NULL;
 }