diff options
author | Paul Mackerras <paulus@samba.org> | 2013-08-12 02:28:47 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-08-14 01:00:16 -0400 |
commit | a8a5356cd511db229aeaad636dc0f83d8c4d0a15 (patch) | |
tree | 97a02feae18514e48549e2e729c1756d12956469 | |
parent | 630573c1da54925290cf7a4f45752f3e9876d7e0 (diff) |
powerpc: Pull out cpu_core_mask updates into a separate function
This factors out the details of updating cpu_core_mask into a separate
function, to make it easier to change how the mask is calculated later.
This makes no functional change.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/kernel/smp.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index e69211293789..0cc69d5deac9 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c | |||
@@ -631,11 +631,36 @@ static struct device_node *cpu_to_l2cache(int cpu) | |||
631 | return cache; | 631 | return cache; |
632 | } | 632 | } |
633 | 633 | ||
634 | static void traverse_core_siblings(int cpu, bool add) | ||
635 | { | ||
636 | struct device_node *l2_cache; | ||
637 | const struct cpumask *mask; | ||
638 | int i; | ||
639 | |||
640 | l2_cache = cpu_to_l2cache(cpu); | ||
641 | mask = add ? cpu_online_mask : cpu_present_mask; | ||
642 | for_each_cpu(i, mask) { | ||
643 | struct device_node *np = cpu_to_l2cache(i); | ||
644 | if (!np) | ||
645 | continue; | ||
646 | if (np == l2_cache) { | ||
647 | if (add) { | ||
648 | cpumask_set_cpu(cpu, cpu_core_mask(i)); | ||
649 | cpumask_set_cpu(i, cpu_core_mask(cpu)); | ||
650 | } else { | ||
651 | cpumask_clear_cpu(cpu, cpu_core_mask(i)); | ||
652 | cpumask_clear_cpu(i, cpu_core_mask(cpu)); | ||
653 | } | ||
654 | } | ||
655 | of_node_put(np); | ||
656 | } | ||
657 | of_node_put(l2_cache); | ||
658 | } | ||
659 | |||
634 | /* Activate a secondary processor. */ | 660 | /* Activate a secondary processor. */ |
635 | void start_secondary(void *unused) | 661 | void start_secondary(void *unused) |
636 | { | 662 | { |
637 | unsigned int cpu = smp_processor_id(); | 663 | unsigned int cpu = smp_processor_id(); |
638 | struct device_node *l2_cache; | ||
639 | int i, base; | 664 | int i, base; |
640 | 665 | ||
641 | atomic_inc(&init_mm.mm_count); | 666 | atomic_inc(&init_mm.mm_count); |
@@ -674,18 +699,7 @@ void start_secondary(void *unused) | |||
674 | cpumask_set_cpu(cpu, cpu_core_mask(base + i)); | 699 | cpumask_set_cpu(cpu, cpu_core_mask(base + i)); |
675 | cpumask_set_cpu(base + i, cpu_core_mask(cpu)); | 700 | cpumask_set_cpu(base + i, cpu_core_mask(cpu)); |
676 | } | 701 | } |
677 | l2_cache = cpu_to_l2cache(cpu); | 702 | traverse_core_siblings(cpu, true); |
678 | for_each_online_cpu(i) { | ||
679 | struct device_node *np = cpu_to_l2cache(i); | ||
680 | if (!np) | ||
681 | continue; | ||
682 | if (np == l2_cache) { | ||
683 | cpumask_set_cpu(cpu, cpu_core_mask(i)); | ||
684 | cpumask_set_cpu(i, cpu_core_mask(cpu)); | ||
685 | } | ||
686 | of_node_put(np); | ||
687 | } | ||
688 | of_node_put(l2_cache); | ||
689 | 703 | ||
690 | smp_wmb(); | 704 | smp_wmb(); |
691 | notify_cpu_starting(cpu); | 705 | notify_cpu_starting(cpu); |
@@ -741,7 +755,6 @@ int arch_sd_sibling_asym_packing(void) | |||
741 | #ifdef CONFIG_HOTPLUG_CPU | 755 | #ifdef CONFIG_HOTPLUG_CPU |
742 | int __cpu_disable(void) | 756 | int __cpu_disable(void) |
743 | { | 757 | { |
744 | struct device_node *l2_cache; | ||
745 | int cpu = smp_processor_id(); | 758 | int cpu = smp_processor_id(); |
746 | int base, i; | 759 | int base, i; |
747 | int err; | 760 | int err; |
@@ -761,20 +774,7 @@ int __cpu_disable(void) | |||
761 | cpumask_clear_cpu(cpu, cpu_core_mask(base + i)); | 774 | cpumask_clear_cpu(cpu, cpu_core_mask(base + i)); |
762 | cpumask_clear_cpu(base + i, cpu_core_mask(cpu)); | 775 | cpumask_clear_cpu(base + i, cpu_core_mask(cpu)); |
763 | } | 776 | } |
764 | 777 | traverse_core_siblings(cpu, false); | |
765 | l2_cache = cpu_to_l2cache(cpu); | ||
766 | for_each_present_cpu(i) { | ||
767 | struct device_node *np = cpu_to_l2cache(i); | ||
768 | if (!np) | ||
769 | continue; | ||
770 | if (np == l2_cache) { | ||
771 | cpumask_clear_cpu(cpu, cpu_core_mask(i)); | ||
772 | cpumask_clear_cpu(i, cpu_core_mask(cpu)); | ||
773 | } | ||
774 | of_node_put(np); | ||
775 | } | ||
776 | of_node_put(l2_cache); | ||
777 | |||
778 | 778 | ||
779 | return 0; | 779 | return 0; |
780 | } | 780 | } |