diff options
author | Li Zefan <lizefan@huawei.com> | 2013-04-27 09:52:43 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-04-27 09:52:43 -0400 |
commit | 5b16c2a493fe1e439c4e7ad51f58153968ca6cf3 (patch) | |
tree | 82ed118dcd768f713b96ca055200c341ee02baeb /kernel/cpuset.c | |
parent | e0e80a02e5701c8790bd348ab59edb154fbda60b (diff) |
cpuset: fix cpu hotplug vs rebuild_sched_domains() race
rebuild_sched_domains() might pass doms with offlined cpu to
partition_sched_domains(), which results in an oops:
general protection fault: 0000 [#1] SMP
...
RIP: 0010:[<ffffffff81077a1e>] [<ffffffff81077a1e>] get_group+0x6e/0x90
...
Call Trace:
[<ffffffff8107f07c>] build_sched_domains+0x70c/0xcb0
[<ffffffff8107f2a7>] ? build_sched_domains+0x937/0xcb0
[<ffffffff81173f64>] ? kfree+0xe4/0x1b0
[<ffffffff8107f6e0>] ? partition_sched_domains+0xc0/0x470
[<ffffffff8107f905>] partition_sched_domains+0x2e5/0x470
[<ffffffff8107f6e0>] ? partition_sched_domains+0xc0/0x470
[<ffffffff810c9007>] ? generate_sched_domains+0xc7/0x530
[<ffffffff810c94a8>] rebuild_sched_domains_locked+0x38/0x70
[<ffffffff810cb4a4>] cpuset_write_resmask+0x1a4/0x500
[<ffffffff810c8700>] ? cpuset_mount+0xe0/0xe0
[<ffffffff810c7f50>] ? cpuset_read_u64+0x100/0x100
[<ffffffff810be890>] ? cgroup_iter_next+0x90/0x90
[<ffffffff810cb300>] ? cpuset_css_offline+0x70/0x70
[<ffffffff810c1a73>] cgroup_file_write+0x133/0x2e0
[<ffffffff8118995b>] vfs_write+0xcb/0x130
[<ffffffff8118a174>] sys_write+0x64/0xa0
Reported-by: Li Zhong <zhong@linux.vnet.ibm.com>
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r-- | kernel/cpuset.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 8f0f45e002f2..93d140f159cc 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -769,12 +769,20 @@ static void rebuild_sched_domains_locked(void) | |||
769 | lockdep_assert_held(&cpuset_mutex); | 769 | lockdep_assert_held(&cpuset_mutex); |
770 | get_online_cpus(); | 770 | get_online_cpus(); |
771 | 771 | ||
772 | /* | ||
773 | * We have raced with CPU hotplug. Don't do anything to avoid | ||
774 | * passing doms with offlined cpu to partition_sched_domains(). | ||
775 | * Anyways, hotplug work item will rebuild sched domains. | ||
776 | */ | ||
777 | if (!cpumask_equal(top_cpuset.cpus_allowed, cpu_active_mask)) | ||
778 | goto out; | ||
779 | |||
772 | /* Generate domain masks and attrs */ | 780 | /* Generate domain masks and attrs */ |
773 | ndoms = generate_sched_domains(&doms, &attr); | 781 | ndoms = generate_sched_domains(&doms, &attr); |
774 | 782 | ||
775 | /* Have scheduler rebuild the domains */ | 783 | /* Have scheduler rebuild the domains */ |
776 | partition_sched_domains(ndoms, doms, attr); | 784 | partition_sched_domains(ndoms, doms, attr); |
777 | 785 | out: | |
778 | put_online_cpus(); | 786 | put_online_cpus(); |
779 | } | 787 | } |
780 | #else /* !CONFIG_SMP */ | 788 | #else /* !CONFIG_SMP */ |