diff options
author | Gautham R Shenoy <ego@in.ibm.com> | 2008-01-25 15:08:02 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-25 15:08:02 -0500 |
commit | 86ef5c9a8edd78e6bf92879f32329d89b2d55b5a (patch) | |
tree | 7bf46885326a6fdbb0c3596855408e9a5634dd3a /arch/x86 | |
parent | d221938c049f4845da13c8593132595a6b9222a8 (diff) |
cpu-hotplug: replace lock_cpu_hotplug() with get_online_cpus()
Replace all lock_cpu_hotplug/unlock_cpu_hotplug from the kernel and use
get_online_cpus and put_online_cpus instead as it highlights the
refcount semantics in these operations.
The new API guarantees protection against the cpu-hotplug operation, but
it doesn't guarantee serialized access to any of the local data
structures. Hence the changes needs to be reviewed.
In case of pseries_add_processor/pseries_remove_processor, use
cpu_maps_update_begin()/cpu_maps_update_done() as we're modifying the
cpu_present_map there.
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/main.c | 8 | ||||
-rw-r--r-- | arch/x86/kernel/microcode.c | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index 3b20613325dc..beb45c9c0835 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c | |||
@@ -349,7 +349,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, | |||
349 | replace = -1; | 349 | replace = -1; |
350 | 350 | ||
351 | /* No CPU hotplug when we change MTRR entries */ | 351 | /* No CPU hotplug when we change MTRR entries */ |
352 | lock_cpu_hotplug(); | 352 | get_online_cpus(); |
353 | /* Search for existing MTRR */ | 353 | /* Search for existing MTRR */ |
354 | mutex_lock(&mtrr_mutex); | 354 | mutex_lock(&mtrr_mutex); |
355 | for (i = 0; i < num_var_ranges; ++i) { | 355 | for (i = 0; i < num_var_ranges; ++i) { |
@@ -405,7 +405,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, | |||
405 | error = i; | 405 | error = i; |
406 | out: | 406 | out: |
407 | mutex_unlock(&mtrr_mutex); | 407 | mutex_unlock(&mtrr_mutex); |
408 | unlock_cpu_hotplug(); | 408 | put_online_cpus(); |
409 | return error; | 409 | return error; |
410 | } | 410 | } |
411 | 411 | ||
@@ -495,7 +495,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) | |||
495 | 495 | ||
496 | max = num_var_ranges; | 496 | max = num_var_ranges; |
497 | /* No CPU hotplug when we change MTRR entries */ | 497 | /* No CPU hotplug when we change MTRR entries */ |
498 | lock_cpu_hotplug(); | 498 | get_online_cpus(); |
499 | mutex_lock(&mtrr_mutex); | 499 | mutex_lock(&mtrr_mutex); |
500 | if (reg < 0) { | 500 | if (reg < 0) { |
501 | /* Search for existing MTRR */ | 501 | /* Search for existing MTRR */ |
@@ -536,7 +536,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) | |||
536 | error = reg; | 536 | error = reg; |
537 | out: | 537 | out: |
538 | mutex_unlock(&mtrr_mutex); | 538 | mutex_unlock(&mtrr_mutex); |
539 | unlock_cpu_hotplug(); | 539 | put_online_cpus(); |
540 | return error; | 540 | return error; |
541 | } | 541 | } |
542 | /** | 542 | /** |
diff --git a/arch/x86/kernel/microcode.c b/arch/x86/kernel/microcode.c index 09c315214a5e..40cfd5488719 100644 --- a/arch/x86/kernel/microcode.c +++ b/arch/x86/kernel/microcode.c | |||
@@ -436,7 +436,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_ | |||
436 | return -EINVAL; | 436 | return -EINVAL; |
437 | } | 437 | } |
438 | 438 | ||
439 | lock_cpu_hotplug(); | 439 | get_online_cpus(); |
440 | mutex_lock(µcode_mutex); | 440 | mutex_lock(µcode_mutex); |
441 | 441 | ||
442 | user_buffer = (void __user *) buf; | 442 | user_buffer = (void __user *) buf; |
@@ -447,7 +447,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_ | |||
447 | ret = (ssize_t)len; | 447 | ret = (ssize_t)len; |
448 | 448 | ||
449 | mutex_unlock(µcode_mutex); | 449 | mutex_unlock(µcode_mutex); |
450 | unlock_cpu_hotplug(); | 450 | put_online_cpus(); |
451 | 451 | ||
452 | return ret; | 452 | return ret; |
453 | } | 453 | } |
@@ -658,14 +658,14 @@ static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz) | |||
658 | 658 | ||
659 | old = current->cpus_allowed; | 659 | old = current->cpus_allowed; |
660 | 660 | ||
661 | lock_cpu_hotplug(); | 661 | get_online_cpus(); |
662 | set_cpus_allowed(current, cpumask_of_cpu(cpu)); | 662 | set_cpus_allowed(current, cpumask_of_cpu(cpu)); |
663 | 663 | ||
664 | mutex_lock(µcode_mutex); | 664 | mutex_lock(µcode_mutex); |
665 | if (uci->valid) | 665 | if (uci->valid) |
666 | err = cpu_request_microcode(cpu); | 666 | err = cpu_request_microcode(cpu); |
667 | mutex_unlock(µcode_mutex); | 667 | mutex_unlock(µcode_mutex); |
668 | unlock_cpu_hotplug(); | 668 | put_online_cpus(); |
669 | set_cpus_allowed(current, old); | 669 | set_cpus_allowed(current, old); |
670 | } | 670 | } |
671 | if (err) | 671 | if (err) |
@@ -817,9 +817,9 @@ static int __init microcode_init (void) | |||
817 | return PTR_ERR(microcode_pdev); | 817 | return PTR_ERR(microcode_pdev); |
818 | } | 818 | } |
819 | 819 | ||
820 | lock_cpu_hotplug(); | 820 | get_online_cpus(); |
821 | error = sysdev_driver_register(&cpu_sysdev_class, &mc_sysdev_driver); | 821 | error = sysdev_driver_register(&cpu_sysdev_class, &mc_sysdev_driver); |
822 | unlock_cpu_hotplug(); | 822 | put_online_cpus(); |
823 | if (error) { | 823 | if (error) { |
824 | microcode_dev_exit(); | 824 | microcode_dev_exit(); |
825 | platform_device_unregister(microcode_pdev); | 825 | platform_device_unregister(microcode_pdev); |
@@ -839,9 +839,9 @@ static void __exit microcode_exit (void) | |||
839 | 839 | ||
840 | unregister_hotcpu_notifier(&mc_cpu_notifier); | 840 | unregister_hotcpu_notifier(&mc_cpu_notifier); |
841 | 841 | ||
842 | lock_cpu_hotplug(); | 842 | get_online_cpus(); |
843 | sysdev_driver_unregister(&cpu_sysdev_class, &mc_sysdev_driver); | 843 | sysdev_driver_unregister(&cpu_sysdev_class, &mc_sysdev_driver); |
844 | unlock_cpu_hotplug(); | 844 | put_online_cpus(); |
845 | 845 | ||
846 | platform_device_unregister(microcode_pdev); | 846 | platform_device_unregister(microcode_pdev); |
847 | } | 847 | } |