aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/sched.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 2810e562a991..e51f0eabfef2 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5461,11 +5461,12 @@ static void register_sched_domain_sysctl(void)
5461 struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1); 5461 struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
5462 char buf[32]; 5462 char buf[32];
5463 5463
5464 WARN_ON(sd_ctl_dir[0].child);
5465 sd_ctl_dir[0].child = entry;
5466
5464 if (entry == NULL) 5467 if (entry == NULL)
5465 return; 5468 return;
5466 5469
5467 sd_ctl_dir[0].child = entry;
5468
5469 for_each_online_cpu(i) { 5470 for_each_online_cpu(i) {
5470 snprintf(buf, 32, "cpu%d", i); 5471 snprintf(buf, 32, "cpu%d", i);
5471 entry->procname = kstrdup(buf, GFP_KERNEL); 5472 entry->procname = kstrdup(buf, GFP_KERNEL);
@@ -5473,14 +5474,19 @@ static void register_sched_domain_sysctl(void)
5473 entry->child = sd_alloc_ctl_cpu_table(i); 5474 entry->child = sd_alloc_ctl_cpu_table(i);
5474 entry++; 5475 entry++;
5475 } 5476 }
5477
5478 WARN_ON(sd_sysctl_header);
5476 sd_sysctl_header = register_sysctl_table(sd_ctl_root); 5479 sd_sysctl_header = register_sysctl_table(sd_ctl_root);
5477} 5480}
5478 5481
5482/* may be called multiple times per register */
5479static void unregister_sched_domain_sysctl(void) 5483static void unregister_sched_domain_sysctl(void)
5480{ 5484{
5481 unregister_sysctl_table(sd_sysctl_header); 5485 if (sd_sysctl_header)
5486 unregister_sysctl_table(sd_sysctl_header);
5482 sd_sysctl_header = NULL; 5487 sd_sysctl_header = NULL;
5483 sd_free_ctl_entry(&sd_ctl_dir[0].child); 5488 if (sd_ctl_dir[0].child)
5489 sd_free_ctl_entry(&sd_ctl_dir[0].child);
5484} 5490}
5485#else 5491#else
5486static void register_sched_domain_sysctl(void) 5492static void register_sched_domain_sysctl(void)
@@ -6424,13 +6430,17 @@ static cpumask_t fallback_doms;
6424 */ 6430 */
6425static int arch_init_sched_domains(const cpumask_t *cpu_map) 6431static int arch_init_sched_domains(const cpumask_t *cpu_map)
6426{ 6432{
6433 int err;
6434
6427 ndoms_cur = 1; 6435 ndoms_cur = 1;
6428 doms_cur = kmalloc(sizeof(cpumask_t), GFP_KERNEL); 6436 doms_cur = kmalloc(sizeof(cpumask_t), GFP_KERNEL);
6429 if (!doms_cur) 6437 if (!doms_cur)
6430 doms_cur = &fallback_doms; 6438 doms_cur = &fallback_doms;
6431 cpus_andnot(*doms_cur, *cpu_map, cpu_isolated_map); 6439 cpus_andnot(*doms_cur, *cpu_map, cpu_isolated_map);
6440 err = build_sched_domains(doms_cur);
6432 register_sched_domain_sysctl(); 6441 register_sched_domain_sysctl();
6433 return build_sched_domains(doms_cur); 6442
6443 return err;
6434} 6444}
6435 6445
6436static void arch_destroy_sched_domains(const cpumask_t *cpu_map) 6446static void arch_destroy_sched_domains(const cpumask_t *cpu_map)
@@ -6479,6 +6489,9 @@ void partition_sched_domains(int ndoms_new, cpumask_t *doms_new)
6479{ 6489{
6480 int i, j; 6490 int i, j;
6481 6491
6492 /* always unregister in case we don't destroy any domains */
6493 unregister_sched_domain_sysctl();
6494
6482 if (doms_new == NULL) { 6495 if (doms_new == NULL) {
6483 ndoms_new = 1; 6496 ndoms_new = 1;
6484 doms_new = &fallback_doms; 6497 doms_new = &fallback_doms;
@@ -6514,6 +6527,8 @@ match2:
6514 kfree(doms_cur); 6527 kfree(doms_cur);
6515 doms_cur = doms_new; 6528 doms_cur = doms_new;
6516 ndoms_cur = ndoms_new; 6529 ndoms_cur = ndoms_new;
6530
6531 register_sched_domain_sysctl();
6517} 6532}
6518 6533
6519#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 6534#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)