]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[MIPS] Kill num_online_cpus() loops.
authorRalf Baechle <ralf@linux-mips.org>
Wed, 3 Oct 2007 18:16:57 +0000 (19:16 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 11 Oct 2007 22:46:18 +0000 (23:46 +0100)
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/gdb-stub.c
arch/mips/kernel/smp.c
arch/mips/kernel/smtc.c
include/asm-mips/mmu_context.h

index bd128fab4b3686c6d163d60feb54d9c6bfc31cb2..3191afa29ad8061404f1ba11b4aefd045acae5fa 100644 (file)
@@ -769,7 +769,7 @@ void handle_exception(struct gdb_regs *regs)
        /*
         * acquire the CPU spinlocks
         */
-       for (i = num_online_cpus()-1; i >= 0; i--)
+       for_each_online_cpu(i)
                if (__raw_spin_trylock(&kgdb_cpulock[i]) == 0)
                        panic("kgdb: couldn't get cpulock %d\n", i);
 
@@ -1044,7 +1044,7 @@ finish_kgdb:
 
 exit_kgdb_exception:
        /* release locks so other CPUs can go */
-       for (i = num_online_cpus()-1; i >= 0; i--)
+       for_each_online_cpu(i)
                __raw_spin_unlock(&kgdb_cpulock[i]);
        spin_unlock(&kgdb_lock);
 
index 481ba5355dcb8f9467d0c23439991b359dd72a9b..5ca3809a1b45112efd1f968d1c4c5b9ed43812b4 100644 (file)
@@ -375,10 +375,13 @@ void flush_tlb_mm(struct mm_struct *mm)
        if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) {
                smp_on_other_tlbs(flush_tlb_mm_ipi, (void *)mm);
        } else {
-               int i;
-               for (i = 0; i < num_online_cpus(); i++)
-                       if (smp_processor_id() != i)
-                               cpu_context(i, mm) = 0;
+               cpumask_t mask = cpu_online_map;
+               unsigned int cpu;
+
+               cpu_clear(smp_processor_id(), mask);
+               for_each_online_cpu(cpu)
+                       if (cpu_context(cpu, mm))
+                               cpu_context(cpu, mm) = 0;
        }
        local_flush_tlb_mm(mm);
 
@@ -411,10 +414,13 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned l
                fd.addr2 = end;
                smp_on_other_tlbs(flush_tlb_range_ipi, (void *)&fd);
        } else {
-               int i;
-               for (i = 0; i < num_online_cpus(); i++)
-                       if (smp_processor_id() != i)
-                               cpu_context(i, mm) = 0;
+               cpumask_t mask = cpu_online_map;
+               unsigned int cpu;
+
+               cpu_clear(smp_processor_id(), mask);
+               for_each_online_cpu(cpu)
+                       if (cpu_context(cpu, mm))
+                               cpu_context(cpu, mm) = 0;
        }
        local_flush_tlb_range(vma, start, end);
        preempt_enable();
@@ -453,10 +459,13 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
                fd.addr1 = page;
                smp_on_other_tlbs(flush_tlb_page_ipi, (void *)&fd);
        } else {
-               int i;
-               for (i = 0; i < num_online_cpus(); i++)
-                       if (smp_processor_id() != i)
-                               cpu_context(i, vma->vm_mm) = 0;
+               cpumask_t mask = cpu_online_map;
+               unsigned int cpu;
+
+               cpu_clear(smp_processor_id(), mask);
+               for_each_online_cpu(cpu)
+                       if (cpu_context(cpu, vma->vm_mm))
+                               cpu_context(cpu, vma->vm_mm) = 0;
        }
        local_flush_tlb_page(vma, page);
        preempt_enable();
index 4d91e2f455c076569ea61b0853f97ff924b7507d..a8c1a698d5889f722b80419de6707296148528e5 100644 (file)
@@ -1264,7 +1264,7 @@ void smtc_get_new_mmu_context(struct mm_struct *mm, unsigned long cpu)
                        if (cpu_has_vtag_icache)
                                flush_icache_all();
                        /* Traverse all online CPUs (hack requires contigous range) */
-                       for (i = 0; i < num_online_cpus(); i++) {
+                       for_each_online_cpu(i) {
                                /*
                                 * We don't need to worry about our own CPU, nor those of
                                 * CPUs who don't share our TLB.
@@ -1293,7 +1293,7 @@ void smtc_get_new_mmu_context(struct mm_struct *mm, unsigned long cpu)
        /*
         * SMTC shares the TLB within VPEs and possibly across all VPEs.
         */
-       for (i = 0; i < num_online_cpus(); i++) {
+       for_each_online_cpu(i) {
                if ((smtc_status & SMTC_TLB_SHARED) ||
                    (cpu_data[i].vpe_id == cpu_data[cpu].vpe_id))
                        cpu_context(i, mm) = asid_cache(i) = asid;
index b3b7a689e7d3427e3ce7767980193f553dcd6193..0c4f245eaeb2f6fe203e392b8455a087ebeb95ae 100644 (file)
@@ -120,7 +120,7 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
        int i;
 
-       for (i = 0; i < num_online_cpus(); i++)
+       for_each_online_cpu(i)
                cpu_context(i, mm) = 0;
 
        return 0;
@@ -284,7 +284,7 @@ drop_mmu_context(struct mm_struct *mm, unsigned cpu)
                int i;
 
                /* SMTC shares the TLB (and ASIDs) across VPEs */
-               for (i = 0; i < num_online_cpus(); i++) {
+               for_each_online_cpu(i) {
                    if((smtc_status & SMTC_TLB_SHARED)
                    || (cpu_data[i].vpe_id == cpu_data[cpu].vpe_id))
                        cpu_context(i, mm) = 0;