powerpc: Convert old cpumask API into new one
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Thu, 28 Apr 2011 05:07:23 +0000 (05:07 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 4 May 2011 05:22:59 +0000 (15:22 +1000)
Adapt new API.

Almost change is trivial. Most important change is the below line
because we plan to change task->cpus_allowed implementation.

-       ctx->cpus_allowed = current->cpus_allowed;

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
13 files changed:
arch/powerpc/include/asm/cputhreads.h
arch/powerpc/include/asm/kexec.h
arch/powerpc/kernel/crash.c
arch/powerpc/kernel/setup-common.c
arch/powerpc/kernel/smp.c
arch/powerpc/kernel/traps.c
arch/powerpc/mm/numa.c
arch/powerpc/platforms/cell/beat_smp.c
arch/powerpc/platforms/cell/cbe_regs.c
arch/powerpc/platforms/cell/smp.c
arch/powerpc/platforms/cell/spufs/sched.c
arch/powerpc/platforms/pseries/hotplug-cpu.c
arch/powerpc/xmon/xmon.c

index f71bb4c118b4566eb8a1149f8f7278d3a03b27ab..ce516e5eb0d3523d5027f3957877cfe144ee7a3f 100644 (file)
@@ -37,16 +37,16 @@ extern cpumask_t threads_core_mask;
  * This can typically be used for things like IPI for tlb invalidations
  * since those need to be done only once per core/TLB
  */
-static inline cpumask_t cpu_thread_mask_to_cores(cpumask_t threads)
+static inline cpumask_t cpu_thread_mask_to_cores(const struct cpumask *threads)
 {
        cpumask_t       tmp, res;
        int             i;
 
-       res = CPU_MASK_NONE;
+       cpumask_clear(&res);
        for (i = 0; i < NR_CPUS; i += threads_per_core) {
-               cpus_shift_left(tmp, threads_core_mask, i);
-               if (cpus_intersects(threads, tmp))
-                       cpu_set(i, res);
+               cpumask_shift_left(&tmp, &threads_core_mask, i);
+               if (cpumask_intersects(threads, &tmp))
+                       cpumask_set_cpu(i, &res);
        }
        return res;
 }
@@ -58,7 +58,7 @@ static inline int cpu_nr_cores(void)
 
 static inline cpumask_t cpu_online_cores_map(void)
 {
-       return cpu_thread_mask_to_cores(cpu_online_map);
+       return cpu_thread_mask_to_cores(cpu_online_mask);
 }
 
 #ifdef CONFIG_SMP
index f54408d995b5b9df718f818f4fdf16d37c796517..8a33698c61bd7ab98c0b7e08ee21e6a17aeeb409 100644 (file)
@@ -76,7 +76,7 @@ extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *));
 extern cpumask_t cpus_in_sr;
 static inline int kexec_sr_activated(int cpu)
 {
-       return cpu_isset(cpu,cpus_in_sr);
+       return cpumask_test_cpu(cpu, &cpus_in_sr);
 }
 
 struct kimage;
index 5b5e1f002a8ea2ef2053bb16ba20e1e110edd348..ccc2198e6b2367df382e8fed29aa57bcd0825335 100644 (file)
@@ -64,9 +64,9 @@ void crash_ipi_callback(struct pt_regs *regs)
                return;
 
        hard_irq_disable();
-       if (!cpu_isset(cpu, cpus_in_crash))
+       if (!cpumask_test_cpu(cpu, &cpus_in_crash))
                crash_save_cpu(regs, cpu);
-       cpu_set(cpu, cpus_in_crash);
+       cpumask_set_cpu(cpu, &cpus_in_crash);
 
        /*
         * Entered via soft-reset - could be the kdump
@@ -77,8 +77,8 @@ void crash_ipi_callback(struct pt_regs *regs)
         * Tell the kexec CPU that entered via soft-reset and ready
         * to go down.
         */
-       if (cpu_isset(cpu, cpus_in_sr)) {
-               cpu_clear(cpu, cpus_in_sr);
+       if (cpumask_test_cpu(cpu, &cpus_in_sr)) {
+               cpumask_clear_cpu(cpu, &cpus_in_sr);
                atomic_inc(&enter_on_soft_reset);
        }
 
@@ -87,7 +87,7 @@ void crash_ipi_callback(struct pt_regs *regs)
         * This barrier is needed to make sure that all CPUs are stopped.
         * If not, soft-reset will be invoked to bring other CPUs.
         */
-       while (!cpu_isset(crashing_cpu, cpus_in_crash))
+       while (!cpumask_test_cpu(crashing_cpu, &cpus_in_crash))
                cpu_relax();
 
        if (ppc_md.kexec_cpu_down)
@@ -109,7 +109,7 @@ static void crash_soft_reset_check(int cpu)
 {
        unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */
 
-       cpu_clear(cpu, cpus_in_sr);
+       cpumask_clear_cpu(cpu, &cpus_in_sr);
        while (atomic_read(&enter_on_soft_reset) != ncpus)
                cpu_relax();
 }
@@ -132,7 +132,7 @@ static void crash_kexec_prepare_cpus(int cpu)
         */
        printk(KERN_EMERG "Sending IPI to other cpus...\n");
        msecs = 10000;
-       while ((cpus_weight(cpus_in_crash) < ncpus) && (--msecs > 0)) {
+       while ((cpumask_weight(&cpus_in_crash) < ncpus) && (--msecs > 0)) {
                cpu_relax();
                mdelay(1);
        }
@@ -144,20 +144,20 @@ static void crash_kexec_prepare_cpus(int cpu)
         * user to do soft reset such that we get all.
         * Soft-reset will be used until better mechanism is implemented.
         */
-       if (cpus_weight(cpus_in_crash) < ncpus) {
+       if (cpumask_weight(&cpus_in_crash) < ncpus) {
                printk(KERN_EMERG "done waiting: %d cpu(s) not responding\n",
-                       ncpus - cpus_weight(cpus_in_crash));
+                       ncpus - cpumask_weight(&cpus_in_crash));
                printk(KERN_EMERG "Activate soft-reset to stop other cpu(s)\n");
-               cpus_in_sr = CPU_MASK_NONE;
+               cpumask_clear(&cpus_in_sr);
                atomic_set(&enter_on_soft_reset, 0);
-               while (cpus_weight(cpus_in_crash) < ncpus)
+               while (cpumask_weight(&cpus_in_crash) < ncpus)
                        cpu_relax();
        }
        /*
         * Make sure all CPUs are entered via soft-reset if the kdump is
         * invoked using soft-reset.
         */
-       if (cpu_isset(cpu, cpus_in_sr))
+       if (cpumask_test_cpu(cpu, &cpus_in_sr))
                crash_soft_reset_check(cpu);
        /* Leave the IPI callback set */
 }
@@ -210,7 +210,7 @@ void crash_kexec_secondary(struct pt_regs *regs)
                         * exited using 'x'(exit and recover) or
                         * kexec_should_crash() failed for all running tasks.
                         */
-                       cpu_clear(cpu, cpus_in_sr);
+                       cpumask_clear_cpu(cpu, &cpus_in_sr);
                        local_irq_restore(flags);
                        return;
                }
@@ -224,7 +224,7 @@ void crash_kexec_secondary(struct pt_regs *regs)
                 * then start kexec boot.
                 */
                crash_soft_reset_check(cpu);
-               cpu_set(crashing_cpu, cpus_in_crash);
+               cpumask_set_cpu(crashing_cpu, &cpus_in_crash);
                if (ppc_md.kexec_cpu_down)
                        ppc_md.kexec_cpu_down(1, 0);
                machine_kexec(kexec_crash_image);
@@ -253,7 +253,7 @@ static void crash_kexec_prepare_cpus(int cpu)
 
 void crash_kexec_secondary(struct pt_regs *regs)
 {
-       cpus_in_sr = CPU_MASK_NONE;
+       cpumask_clear(&cpus_in_sr);
 }
 #endif /* CONFIG_SMP */
 
@@ -345,7 +345,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
        crashing_cpu = smp_processor_id();
        crash_save_cpu(regs, crashing_cpu);
        crash_kexec_prepare_cpus(crashing_cpu);
-       cpu_set(crashing_cpu, cpus_in_crash);
+       cpumask_set_cpu(crashing_cpu, &cpus_in_crash);
        crash_kexec_wait_realmode(crashing_cpu);
 
        machine_kexec_mask_interrupts();
index 21f30cb68077f6be97daf30ee5c1f7617571036f..1475df6e403f5f8b1686fdf5ce08c5b22e4692ae 100644 (file)
@@ -381,7 +381,7 @@ static void __init cpu_init_thread_core_maps(int tpc)
        int i;
 
        threads_per_core = tpc;
-       threads_core_mask = CPU_MASK_NONE;
+       cpumask_clear(&threads_core_mask);
 
        /* This implementation only supports power of 2 number of threads
         * for simplicity and performance
@@ -390,7 +390,7 @@ static void __init cpu_init_thread_core_maps(int tpc)
        BUG_ON(tpc != (1 << threads_shift));
 
        for (i = 0; i < tpc; i++)
-               cpu_set(i, threads_core_mask);
+               cpumask_set_cpu(i, &threads_core_mask);
 
        printk(KERN_INFO "CPU maps initialized for %d thread%s per core\n",
               tpc, tpc > 1 ? "s" : "");
index b6083f4f39b17db1da23b0b566e2ef55d35611ae..87517ab6d36501363c7e02dc252a9e3c7d0f9441 100644 (file)
@@ -513,7 +513,7 @@ int cpu_first_thread_of_core(int core)
 }
 EXPORT_SYMBOL_GPL(cpu_first_thread_of_core);
 
-/* Must be called when no change can occur to cpu_present_map,
+/* Must be called when no change can occur to cpu_present_mask,
  * i.e. during cpu online or offline.
  */
 static struct device_node *cpu_to_l2cache(int cpu)
@@ -614,7 +614,7 @@ void __init smp_cpus_done(unsigned int max_cpus)
         * se we pin us down to CPU 0 for a short while
         */
        alloc_cpumask_var(&old_mask, GFP_NOWAIT);
-       cpumask_copy(old_mask, &current->cpus_allowed);
+       cpumask_copy(old_mask, tsk_cpus_allowed(current));
        set_cpus_allowed_ptr(current, cpumask_of(boot_cpuid));
        
        if (smp_ops && smp_ops->setup_cpu)
index 4a6a109b681678257805d5b653f81e940be0d3b0..06b9d457d0a785fccdaa48b2868db348be6e492c 100644 (file)
@@ -221,7 +221,7 @@ void system_reset_exception(struct pt_regs *regs)
        }
 
 #ifdef CONFIG_KEXEC
-       cpu_set(smp_processor_id(), cpus_in_sr);
+       cpumask_set_cpu(smp_processor_id(), &cpus_in_sr);
 #endif
 
        die("System Reset", regs, SIGABRT);
index e49b799b59a305015a9cf393b991efd537eaeec9..2164006fe170f8e0e8a7adddd67e78803872c9e2 100644 (file)
@@ -1452,7 +1452,7 @@ int arch_update_cpu_topology(void)
        unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0};
        struct sys_device *sysdev;
 
-       for_each_cpu_mask(cpu, cpu_associativity_changes_mask) {
+       for_each_cpu(cpu,&cpu_associativity_changes_mask) {
                vphn_get_associativity(cpu, associativity);
                nid = associativity_to_nid(associativity);
 
index 996df33165f1de22f6cb526af02394233bf31691..3e86acbb0fb4c12201afd39c5a2cac5d55a1c0e3 100644 (file)
@@ -85,7 +85,7 @@ static void smp_beatic_message_pass(int target, int msg)
 
 static int __init smp_beatic_probe(void)
 {
-       return cpus_weight(cpu_possible_map);
+       return cpumask_weight(cpu_possible_mask);
 }
 
 static void __devinit smp_beatic_setup_cpu(int cpu)
index dbc338f187a25a0288d6fda276ded42bc3f0705e..f3917e7a5b443dae4580cc67a8cbc3c132040c56 100644 (file)
@@ -45,8 +45,8 @@ static struct cbe_thread_map
        unsigned int cbe_id;
 } cbe_thread_map[NR_CPUS];
 
-static cpumask_t cbe_local_mask[MAX_CBE] = { [0 ... MAX_CBE-1] = CPU_MASK_NONE };
-static cpumask_t cbe_first_online_cpu = CPU_MASK_NONE;
+static cpumask_t cbe_local_mask[MAX_CBE] = { [0 ... MAX_CBE-1] = {CPU_BITS_NONE} };
+static cpumask_t cbe_first_online_cpu = { CPU_BITS_NONE };
 
 static struct cbe_regs_map *cbe_find_map(struct device_node *np)
 {
@@ -159,7 +159,8 @@ EXPORT_SYMBOL_GPL(cbe_cpu_to_node);
 
 u32 cbe_node_to_cpu(int node)
 {
-       return find_first_bit( (unsigned long *) &cbe_local_mask[node], sizeof(cpumask_t));
+       return cpumask_first(&cbe_local_mask[node]);
+
 }
 EXPORT_SYMBOL_GPL(cbe_node_to_cpu);
 
@@ -268,9 +269,9 @@ void __init cbe_regs_init(void)
                                thread->regs = map;
                                thread->cbe_id = cbe_id;
                                map->be_node = thread->be_node;
-                               cpu_set(i, cbe_local_mask[cbe_id]);
+                               cpumask_set_cpu(i, &cbe_local_mask[cbe_id]);
                                if(thread->thread_id == 0)
-                                       cpu_set(i, cbe_first_online_cpu);
+                                       cpumask_set_cpu(i, &cbe_first_online_cpu);
                        }
                }
 
index 03d638e2f44fba01672bcc278182b92f1a6c0589..a2161b91b0bf602aeda70bb116a7bc2d0a66525d 100644 (file)
@@ -77,7 +77,7 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
        unsigned int pcpu;
        int start_cpu;
 
-       if (cpu_isset(lcpu, of_spin_map))
+       if (cpumask_test_cpu(lcpu, &of_spin_map))
                /* Already started by OF and sitting in spin loop */
                return 1;
 
@@ -123,7 +123,7 @@ static int __init smp_iic_probe(void)
 {
        iic_request_IPIs();
 
-       return cpus_weight(cpu_possible_map);
+       return cpumask_weight(cpu_possible_mask);
 }
 
 static void __devinit smp_cell_setup_cpu(int cpu)
@@ -188,13 +188,12 @@ void __init smp_init_cell(void)
        if (cpu_has_feature(CPU_FTR_SMT)) {
                for_each_present_cpu(i) {
                        if (cpu_thread_in_core(i) == 0)
-                               cpu_set(i, of_spin_map);
+                               cpumask_set_cpu(i, &of_spin_map);
                }
-       } else {
-               of_spin_map = cpu_present_map;
-       }
+       } else
+               cpumask_copy(&of_spin_map, cpu_present_mask);
 
-       cpu_clear(boot_cpuid, of_spin_map);
+       cpumask_clear_cpu(boot_cpuid, &of_spin_map);
 
        /* Non-lpar has additional take/give timebase */
        if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) {
index 65203857b0cebdf4601a23617d8d6db1aa84494f..32cb4e66d2cd032220dd110c5a3a803bb066cf4f 100644 (file)
@@ -141,7 +141,7 @@ void __spu_update_sched_info(struct spu_context *ctx)
         * runqueue. The context will be rescheduled on the proper node
         * if it is timesliced or preempted.
         */
-       ctx->cpus_allowed = current->cpus_allowed;
+       cpumask_copy(&ctx->cpus_allowed, tsk_cpus_allowed(current));
 
        /* Save the current cpu id for spu interrupt routing. */
        ctx->last_ran = raw_smp_processor_id();
index ae6c27df4dc4b9bfdfeac18ce89ec12aa06b45cc..46f13a3c5d09eb5c88e01c1356b018a67622b546 100644 (file)
@@ -281,7 +281,7 @@ static int pseries_add_processor(struct device_node *np)
        }
 
        for_each_cpu(cpu, tmp) {
-               BUG_ON(cpumask_test_cpu(cpu, cpu_present_mask));
+               BUG_ON(cpu_present(cpu));
                set_cpu_present(cpu, true);
                set_hard_smp_processor_id(cpu, *intserv++);
        }
index 909804aaeebb56f90798f3ef08ab606f0ece7fcf..91309c5c00d7d18fd968a293d7e02637d666b051 100644 (file)
@@ -334,7 +334,7 @@ static void release_output_lock(void)
 
 int cpus_are_in_xmon(void)
 {
-       return !cpus_empty(cpus_in_xmon);
+       return !cpumask_empty(&cpus_in_xmon);
 }
 #endif
 
@@ -373,7 +373,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
 
 #ifdef CONFIG_SMP
        cpu = smp_processor_id();
-       if (cpu_isset(cpu, cpus_in_xmon)) {
+       if (cpumask_test_cpu(cpu, &cpus_in_xmon)) {
                get_output_lock();
                excprint(regs);
                printf("cpu 0x%x: Exception %lx %s in xmon, "
@@ -396,7 +396,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
        }
 
        xmon_fault_jmp[cpu] = recurse_jmp;
-       cpu_set(cpu, cpus_in_xmon);
+       cpumask_set_cpu(cpu, &cpus_in_xmon);
 
        bp = NULL;
        if ((regs->msr & (MSR_IR|MSR_PR|MSR_64BIT)) == (MSR_IR|MSR_64BIT))
@@ -440,7 +440,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
                        smp_send_debugger_break(MSG_ALL_BUT_SELF);
                        /* wait for other cpus to come in */
                        for (timeout = 100000000; timeout != 0; --timeout) {
-                               if (cpus_weight(cpus_in_xmon) >= ncpus)
+                               if (cpumask_weight(&cpus_in_xmon) >= ncpus)
                                        break;
                                barrier();
                        }
@@ -484,7 +484,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
                }
        }
  leave:
-       cpu_clear(cpu, cpus_in_xmon);
+       cpumask_clear_cpu(cpu, &cpus_in_xmon);
        xmon_fault_jmp[cpu] = NULL;
 #else
        /* UP is simple... */
@@ -630,7 +630,7 @@ static int xmon_iabr_match(struct pt_regs *regs)
 static int xmon_ipi(struct pt_regs *regs)
 {
 #ifdef CONFIG_SMP
-       if (in_xmon && !cpu_isset(smp_processor_id(), cpus_in_xmon))
+       if (in_xmon && !cpumask_test_cpu(smp_processor_id(), &cpus_in_xmon))
                xmon_core(regs, 1);
 #endif
        return 0;
@@ -976,7 +976,7 @@ static int cpu_cmd(void)
                printf("cpus stopped:");
                count = 0;
                for (cpu = 0; cpu < NR_CPUS; ++cpu) {
-                       if (cpu_isset(cpu, cpus_in_xmon)) {
+                       if (cpumask_test_cpu(cpu, &cpus_in_xmon)) {
                                if (count == 0)
                                        printf(" %x", cpu);
                                ++count;
@@ -992,7 +992,7 @@ static int cpu_cmd(void)
                return 0;
        }
        /* try to switch to cpu specified */
-       if (!cpu_isset(cpu, cpus_in_xmon)) {
+       if (!cpumask_test_cpu(cpu, &cpus_in_xmon)) {
                printf("cpu 0x%x isn't in xmon\n", cpu);
                return 0;
        }