diff options
author | Toshi Kani <toshi.kani@hp.com> | 2013-08-12 11:45:53 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-13 06:20:16 -0400 |
commit | b9d10be7a8e88fdcb12540387c219cdde87b0795 (patch) | |
tree | ac6c78fb28efccbba5995eb55b3b151096dfff19 /drivers/acpi/acpi_processor.c | |
parent | 22e7551eb6fd58352930306039a98313c011e615 (diff) |
ACPI / processor: Acquire writer lock to update CPU maps
CPU system maps are protected with reader/writer locks. The reader
lock, get_online_cpus(), assures that the maps are not updated while
holding the lock. The writer lock, cpu_hotplug_begin(), is used to
udpate the cpu maps along with cpu_maps_update_begin().
However, the ACPI processor handler updates the cpu maps without
holding the the writer lock.
acpi_map_lsapic() is called from acpi_processor_hotadd_init() to
update cpu_possible_mask and cpu_present_mask. acpi_unmap_lsapic()
is called from acpi_processor_remove() to update cpu_possible_mask.
Currently, they are either unprotected or protected with the reader
lock, which is not correct.
For example, the get_online_cpus() below is supposed to assure that
cpu_possible_mask is not changed while the code is iterating with
for_each_possible_cpu().
get_online_cpus();
for_each_possible_cpu(cpu) {
:
}
put_online_cpus();
However, this lock has no protection with CPU hotplug since the ACPI
processor handler does not use the writer lock when it updates
cpu_possible_mask. The reader lock does not serialize within the
readers.
This patch protects them with the writer lock with cpu_hotplug_begin()
along with cpu_maps_update_begin(), which must be held before calling
cpu_hotplug_begin(). It also protects arch_register_cpu() /
arch_unregister_cpu(), which creates / deletes a sysfs cpu device
interface. For this purpose it changes cpu_hotplug_begin() and
cpu_hotplug_done() to global and exports them in cpu.h.
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpi_processor.c')
-rw-r--r-- | drivers/acpi/acpi_processor.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 5a74a9c1e42c..f29e06efa479 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c | |||
@@ -178,14 +178,17 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) | |||
178 | if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) | 178 | if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) |
179 | return -ENODEV; | 179 | return -ENODEV; |
180 | 180 | ||
181 | cpu_maps_update_begin(); | ||
182 | cpu_hotplug_begin(); | ||
183 | |||
181 | ret = acpi_map_lsapic(pr->handle, &pr->id); | 184 | ret = acpi_map_lsapic(pr->handle, &pr->id); |
182 | if (ret) | 185 | if (ret) |
183 | return ret; | 186 | goto out; |
184 | 187 | ||
185 | ret = arch_register_cpu(pr->id); | 188 | ret = arch_register_cpu(pr->id); |
186 | if (ret) { | 189 | if (ret) { |
187 | acpi_unmap_lsapic(pr->id); | 190 | acpi_unmap_lsapic(pr->id); |
188 | return ret; | 191 | goto out; |
189 | } | 192 | } |
190 | 193 | ||
191 | /* | 194 | /* |
@@ -195,7 +198,11 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) | |||
195 | */ | 198 | */ |
196 | pr_info("CPU%d has been hot-added\n", pr->id); | 199 | pr_info("CPU%d has been hot-added\n", pr->id); |
197 | pr->flags.need_hotplug_init = 1; | 200 | pr->flags.need_hotplug_init = 1; |
198 | return 0; | 201 | |
202 | out: | ||
203 | cpu_hotplug_done(); | ||
204 | cpu_maps_update_done(); | ||
205 | return ret; | ||
199 | } | 206 | } |
200 | #else | 207 | #else |
201 | static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) | 208 | static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) |
@@ -452,11 +459,15 @@ static void acpi_processor_remove(struct acpi_device *device) | |||
452 | per_cpu(processor_device_array, pr->id) = NULL; | 459 | per_cpu(processor_device_array, pr->id) = NULL; |
453 | per_cpu(processors, pr->id) = NULL; | 460 | per_cpu(processors, pr->id) = NULL; |
454 | 461 | ||
462 | cpu_maps_update_begin(); | ||
463 | cpu_hotplug_begin(); | ||
464 | |||
455 | /* Remove the CPU. */ | 465 | /* Remove the CPU. */ |
456 | get_online_cpus(); | ||
457 | arch_unregister_cpu(pr->id); | 466 | arch_unregister_cpu(pr->id); |
458 | acpi_unmap_lsapic(pr->id); | 467 | acpi_unmap_lsapic(pr->id); |
459 | put_online_cpus(); | 468 | |
469 | cpu_hotplug_done(); | ||
470 | cpu_maps_update_done(); | ||
460 | 471 | ||
461 | try_offline_node(cpu_to_node(pr->id)); | 472 | try_offline_node(cpu_to_node(pr->id)); |
462 | 473 | ||