sched/numa: Fix initialization of sched_domain_topology for NUMA
authorVincent Guittot <vincent.guittot@linaro.org>
Tue, 13 May 2014 09:11:01 +0000 (11:11 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 22 May 2014 09:16:29 +0000 (11:16 +0200)
Jet Chen has reported a kernel panics when booting qemu-system-x86_64 with
kvm64 cpu. A panic occured while building the sched_domain.

In sched_init_numa, we create a new topology table in which both default
levels and numa levels are copied. The last row of the table must have a null
pointer in the mask field.

The current implementation doesn't add this last row in the computation of the
table size. So we add 1 row in the allocation size that will be used as the
last row of the table. The kzalloc will ensure that the mask field is NULL.

Reported-by: Jet Chen <jet.chen@intel.com>
Tested-by: Jet Chen <jet.chen@intel.com>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: fengguang.wu@intel.com
Link: http://lkml.kernel.org/r/1399972261-25693-1-git-send-email-vincent.guittot@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/core.c

index a78c5b62a470a127e55fd2560cd393283d598d67..45d077ed24fbd38d55d68a735d2beea0348d8159 100644 (file)
@@ -6231,7 +6231,7 @@ static void sched_init_numa(void)
        /* Compute default topology size */
        for (i = 0; sched_domain_topology[i].mask; i++);
 
-       tl = kzalloc((i + level) *
+       tl = kzalloc((i + level + 1) *
                        sizeof(struct sched_domain_topology_level), GFP_KERNEL);
        if (!tl)
                return;