Skip to contentSkip to conversation

adjust the way cpumasks get passed around (v2)

PATCH In review Jan Beulich 2 participants 5 messages May 25, 2009 – May 26, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 adjust the way cpumasks get passed around (v2)

Rather than passing cpumasks by value in all cases (which is problematic for large NR_CPUS configurations), pass them 'by reference' (i.e. through a pointer to a const cpumask).

On x86 this changes send_IPI_mask() to always only send IPIs to remote CPUs (meaning any caller needing to handle the current CPU as well has to do so on its own).

IA64 changes compile-tested only.

xen/arch/ia64/linux-xen/smp.c +7 -8
@@ -57,19 +57,18 @@
 //#if CONFIG_SMP || IA64
 #if CONFIG_SMP
 //Huh? This seems to be used on ia64 even if !CONFIG_SMP
-void smp_send_event_check_mask(cpumask_t mask)
+void smp_send_event_check_mask(const cpumask_t *mask)
 {
     int cpu;
 
     /*  Not for me.  */
-    cpu_clear(smp_processor_id(), mask);
-    if (cpus_empty(mask))
+    if (cpus_subset(*mask, *cpumask_of(smp_processor_id())))
         return;
 
     //printf("smp_send_event_check_mask called\n");
 
     for (cpu = 0; cpu < NR_CPUS; ++cpu)
-        if (cpu_isset(cpu, mask))
+        if (cpu_isset(cpu, *mask) && cpu != smp_processor_id())
 	    platform_send_ipi(cpu, IA64_IPI_RESCHEDULE, IA64_IPI_DM_INT, 0);
 }
 #endif
@@ -438,11 +437,11 @@ EXPORT_SYMBOL(smp_call_function);
 
 #ifdef XEN
 int
-on_selected_cpus(cpumask_t selected, void (*func) (void *info), void *info,
-                 int retry, int wait)
+on_selected_cpus(const cpumask_t *selected, void (*func) (void *info),
+                 void *info, int retry, int wait)
 {
 	struct call_data_struct data;
-	unsigned int cpu, nr_cpus = cpus_weight(selected);
+	unsigned int cpu, nr_cpus = cpus_weight(*selected);
 
 	ASSERT(local_irq_is_enabled());
 
@@ -460,7 +459,7 @@ on_selected_cpus(cpumask_t selected, voi
 	call_data = &data;
 	wmb();
 
-	for_each_cpu_mask(cpu, selected)
+	for_each_cpu_mask(cpu, *selected)
 		send_IPI_single(cpu, IPI_CALL_FUNC);
 
 	while (atomic_read(wait ? &data.finished : &data.started) != nr_cpus)
xen/arch/ia64/linux-xen/sn/kernel/sn2_smp.c +1 -1
@@ -239,7 +239,7 @@ sn2_global_tlb_purge(unsigned long start
 		flush_data.start = start;
 		flush_data.end = end;
 		flush_data.nbits = nbits;
-		on_selected_cpus(selected_cpus, sn_flush_ptcga_cpu,
+		on_selected_cpus(&selected_cpus, sn_flush_ptcga_cpu,
 				 &flush_data, 1, 1);
 	}
 	spin_unlock(&sn2_ptcg_lock2);
xen/arch/ia64/xen/mm.c +1 -1
@@ -3182,7 +3182,7 @@ int get_page_type(struct page_info *page
                 if ( unlikely(!cpus_empty(mask)) )
                 {
                     perfc_incr(need_flush_tlb_flush);
-                    flush_tlb_mask(mask);
+                    flush_tlb_mask(&mask);
                 }
 
                 /* We lose existing type, back pointer, and validity. */
xen/arch/ia64/xen/vhpt.c +7 -8
@@ -548,22 +548,21 @@ void flush_tlb_for_log_dirty(struct doma
 	cpus_clear (d->domain_dirty_cpumask);
 }
 
-void flush_tlb_mask(cpumask_t mask)
+void flush_tlb_mask(const cpumask_t *mask)
 {
     int cpu;
 
     cpu = smp_processor_id();
-    if (cpu_isset (cpu, mask)) {
-        cpu_clear(cpu, mask);
+    if (cpu_isset(cpu, *mask))
         flush_tlb_vhpt_all (NULL);
-    }
 
-    if (cpus_empty(mask))
+    if (cpus_subset(*mask, *cpumask_of(cpu)))
         return;
 
-    for_each_cpu_mask (cpu, mask)
-        smp_call_function_single
-            (cpu, (void (*)(void *))flush_tlb_vhpt_all, NULL, 1, 1);
+    for_each_cpu_mask (cpu, *mask)
+        if (cpu != smp_processor_id())
+            smp_call_function_single
+                (cpu, (void (*)(void *))flush_tlb_vhpt_all, NULL, 1, 1);
 }
 
 #ifdef PERF_COUNTERS
xen/arch/x86/acpi/cpufreq/cpufreq.c +3 -5
@@ -186,7 +186,7 @@ static void drv_read(struct drv_cmd *cmd
     if (likely(cpu_isset(smp_processor_id(), cmd->mask)))
         do_drv_read((void *)cmd);
     else
-        on_selected_cpus( cmd->mask, do_drv_read, (void *)cmd, 0, 1);
+        on_selected_cpus(&cmd->mask, do_drv_read, (void *)cmd, 0, 1);
 }
 
 static void drv_write(struct drv_cmd *cmd)
@@ -195,7 +195,7 @@ static void drv_write(struct drv_cmd *cm
         cpu_isset(smp_processor_id(), cmd->mask))
         do_drv_write((void *)cmd);
     else
-        on_selected_cpus( cmd->mask, do_drv_write, (void *)cmd, 0, 0);
+        on_selected_cpus(&cmd->mask, do_drv_write, (void *)cmd, 0, 0);
 }
 
 static u32 get_cur_val(cpumask_t mask)
@@ -274,7 +274,6 @@ static unsigned int get_measured_perf(un
     struct cpufreq_policy *policy;    
     struct perf_pair readin, cur, *saved;
     unsigned int perf_percent;
-    cpumask_t cpumask;
     unsigned int retval;
 
     if (!cpu_online(cpu))
@@ -303,8 +302,7 @@ static unsigned int get_measured_perf(un
     if (cpu == smp_processor_id()) {
         read_measured_perf_ctrs((void *)&readin);
     } else {
-        cpumask = cpumask_of_cpu(cpu);
-        on_selected_cpus(cpumask, read_measured_perf_ctrs, 
+        on_selected_cpus(cpumask_of(cpu), read_measured_perf_ctrs,
                         (void *)&readin, 0, 1);
     }
 
xen/arch/x86/acpi/cpufreq/powernow.c +1 -1
@@ -121,7 +121,7 @@ static int powernow_cpufreq_target(struc
 
     cmd.val = next_perf_state;
 
-    on_selected_cpus( cmd.mask, transition_pstate, (void *) &cmd, 0, 0);
+    on_selected_cpus(&cmd.mask, transition_pstate, (void *) &cmd, 0, 0);
 
     perf->state = next_perf_state;
     policy->cur = freqs.new;
xen/arch/x86/cpu/mcheck/mce.c +4 -4
@@ -1205,8 +1205,8 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 
 		add_taint(TAINT_ERROR_INJECT);
 
-		on_selected_cpus(cpumask_of_cpu(target),
-		    x86_mc_msrinject, mc_msrinject, 1, 1);
+		on_selected_cpus(cpumask_of(target), x86_mc_msrinject,
+				 mc_msrinject, 1, 1);
 
 		break;
 
@@ -1225,8 +1225,8 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 
 		add_taint(TAINT_ERROR_INJECT);
 
-		on_selected_cpus(cpumask_of_cpu(target), x86_mc_mceinject,
-		    mc_mceinject, 1, 1);
+		on_selected_cpus(cpumask_of(target), x86_mc_mceinject,
+		                 mc_mceinject, 1, 1);
 		break;
 
 	default:
xen/arch/x86/cpu/mtrr/main.c +1 -1
@@ -688,7 +688,7 @@ void mtrr_save_state(void)
 	if (cpu == 0)
 		mtrr_save_fixed_ranges(NULL);
 	else
-		on_selected_cpus(cpumask_of_cpu(0), mtrr_save_fixed_ranges, NULL, 1, 1);
+		on_selected_cpus(cpumask_of(0), mtrr_save_fixed_ranges, NULL, 1, 1);
 	put_cpu();
 }
 
xen/arch/x86/crash.c +2 -4
@@ -58,10 +58,8 @@ static int crash_nmi_callback(struct cpu
  */
 static void smp_send_nmi_allbutself(void)
 {
-    cpumask_t allbutself = cpu_online_map;
-    cpu_clear(smp_processor_id(), allbutself);
-    if ( !cpus_empty(allbutself) )
-        send_IPI_mask(allbutself, APIC_DM_NMI);
+    if ( !cpus_subset(cpu_online_map, *cpumask_of(smp_processor_id())) )
+        send_IPI_mask(&cpu_online_map, APIC_DM_NMI);
 }
 
 static void nmi_shootdown_cpus(void)
xen/arch/x86/domain.c +2 -2
@@ -1316,7 +1316,7 @@ void context_switch(struct vcpu *prev, s
     if ( unlikely(!cpu_isset(cpu, dirty_mask) && !cpus_empty(dirty_mask)) )
     {
         /* Other cpus call __sync_lazy_execstate from flush ipi handler. */
-        flush_tlb_mask(dirty_mask);
+        flush_tlb_mask(&dirty_mask);
     }
 
     if ( is_hvm_vcpu(prev) && !list_empty(&prev->arch.hvm_vcpu.tm_list) )
@@ -1410,7 +1410,7 @@ void sync_vcpu_execstate(struct vcpu *v)
         (void)__sync_lazy_execstate();
 
     /* Other cpus call __sync_lazy_execstate from flush ipi handler. */
-    flush_tlb_mask(v->vcpu_dirty_cpumask);
+    flush_tlb_mask(&v->vcpu_dirty_cpumask);
 }
 
 struct migrate_info {
xen/arch/x86/genapic/x2apic.c +4 -3
@@ -56,7 +56,7 @@ unsigned int cpu_mask_to_apicid_x2apic(c
     return cpu_physical_id(first_cpu(cpumask));
 }
 
-void send_IPI_mask_x2apic(cpumask_t cpumask, int vector)
+void send_IPI_mask_x2apic(const cpumask_t *cpumask, int vector)
 {
     unsigned int cpu, cfg;
     unsigned long flags;
@@ -76,8 +76,9 @@ void send_IPI_mask_x2apic(cpumask_t cpum
     local_irq_save(flags);
 
     cfg = APIC_DM_FIXED | 0 /* no shorthand */ | APIC_DEST_PHYSICAL | vector;
-    for_each_cpu_mask ( cpu, cpumask )
-        apic_wrmsr(APIC_ICR, cfg, cpu_physical_id(cpu));
+    for_each_cpu_mask ( cpu, *cpumask )
+        if ( cpu != smp_processor_id() )
+            apic_wrmsr(APIC_ICR, cfg, cpu_physical_id(cpu));
 
     local_irq_restore(flags);
 }
xen/arch/x86/hpet.c +1 -1
@@ -617,7 +617,7 @@ void hpet_disable_legacy_broadcast(void)
 
     spin_unlock_irq(&legacy_hpet_event.lock);
 
-    smp_send_event_check_mask(cpu_online_map);
+    smp_send_event_check_mask(&cpu_online_map);
 }
 
 void hpet_broadcast_enter(void)
xen/arch/x86/hvm/hvm.c +1 -1
@@ -2408,7 +2408,7 @@ static int hvmop_flush_tlb_all(void)
         paging_update_cr3(v);
 
     /* Flush all dirty TLBs. */
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
 
     /* Done. */
     for_each_vcpu ( d, v )
xen/arch/x86/hvm/vmx/vmcs.c +2 -2
@@ -264,7 +264,7 @@ static void vmx_clear_vmcs(struct vcpu *
     int cpu = v->arch.hvm_vmx.active_cpu;
 
     if ( cpu != -1 )
-        on_selected_cpus(cpumask_of_cpu(cpu), __vmx_clear_vmcs, v, 1, 1);
+        on_selected_cpus(cpumask_of(cpu), __vmx_clear_vmcs, v, 1, 1);
 }
 
 static void vmx_load_vmcs(struct vcpu *v)
@@ -899,7 +899,7 @@ void vmx_do_resume(struct vcpu *v)
         {
             int cpu = v->arch.hvm_vmx.active_cpu;
             if ( cpu != -1 )
-                on_selected_cpus(cpumask_of_cpu(cpu), wbinvd_ipi, NULL, 1, 1);
+                on_selected_cpus(cpumask_of(cpu), wbinvd_ipi, NULL, 1, 1);
         }
 
         vmx_clear_vmcs(v);
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -2163,7 +2163,7 @@ static void ept_handle_violation(unsigne
         {
             paging_mark_dirty(d, mfn_x(mfn));
             p2m_change_type(d, gfn, p2m_ram_logdirty, p2m_ram_rw);
-            flush_tlb_mask(d->domain_dirty_cpumask);
+            flush_tlb_mask(&d->domain_dirty_cpumask);
         }
         return;
     }
xen/arch/x86/irq.c +3 -3
@@ -516,7 +516,7 @@ static void __pirq_guest_eoi(struct doma
     }
 
     if ( !cpus_empty(cpu_eoi_map) )
-        on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 0);
+        on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1, 0);
 }
 
 int pirq_guest_eoi(struct domain *d, int irq)
@@ -755,7 +755,7 @@ static irq_guest_action_t *__pirq_guest_
         {
             cpu_eoi_map = action->cpu_eoi_map;
             spin_unlock_irq(&desc->lock);
-            on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 0);
+            on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1, 0);
             spin_lock_irq(&desc->lock);
         }
         break;
@@ -793,7 +793,7 @@ static irq_guest_action_t *__pirq_guest_
     {
         BUG_ON(action->ack_type != ACKTYPE_EOI);
         spin_unlock_irq(&desc->lock);
-        on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 1);
+        on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1, 1);
         spin_lock_irq(&desc->lock);
     }
 
xen/arch/x86/machine_kexec.c +2 -4
@@ -91,7 +91,6 @@ static void __machine_reboot_kexec(void 
 void machine_reboot_kexec(xen_kexec_image_t *image)
 {
     int reboot_cpu_id;
-    cpumask_t reboot_cpu;
 
     reboot_cpu_id = 0;
 
@@ -100,9 +99,8 @@ void machine_reboot_kexec(xen_kexec_imag
 
     if ( reboot_cpu_id != smp_processor_id() )
     {
-        cpus_clear(reboot_cpu);
-        cpu_set(reboot_cpu_id, reboot_cpu);
-        on_selected_cpus(reboot_cpu, __machine_reboot_kexec, image, 1, 0);
+        on_selected_cpus(cpumask_of(reboot_cpu_id), __machine_reboot_kexec,
+                         image, 1, 0);
         for (;;)
                 ; /* nothing */
     }
xen/arch/x86/mm.c +11 -11
@@ -510,7 +510,7 @@ static void invalidate_shadow_ldt(struct
 
     /* Rid TLBs of stale mappings (guest mappings and shadow mappings). */
     if ( flush )
-        flush_tlb_mask(v->vcpu_dirty_cpumask);
+        flush_tlb_mask(&v->vcpu_dirty_cpumask);
 
  out:
     spin_unlock(&v->arch.shadow_ldt_lock);
@@ -1235,7 +1235,7 @@ static void pae_flush_pgd(
                 paging_update_cr3(v);
                 cpus_or(m, m, v->vcpu_dirty_cpumask);
             }
-        flush_tlb_mask(m);
+        flush_tlb_mask(&m);
     }
 
     /* If below 4GB then the pgdir is not shadowed in low memory. */
@@ -1260,7 +1260,7 @@ static void pae_flush_pgd(
         spin_unlock(&cache->lock);
     }
 
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
 }
 #else
 # define pae_flush_pgd(mfn, idx, nl3e) ((void)0)
@@ -2275,7 +2275,7 @@ static int __get_page_type(struct page_i
                       ((nx & PGT_type_mask) == PGT_writable_page)) )
                 {
                     perfc_incr(need_flush_tlb_flush);
-                    flush_tlb_mask(mask);
+                    flush_tlb_mask(&mask);
                 }
 
                 /* We lose existing type and validity. */
@@ -2476,7 +2476,7 @@ static void process_deferred_ops(void)
     if ( deferred_ops & (DOP_FLUSH_ALL_TLBS|DOP_FLUSH_TLB) )
     {
         if ( deferred_ops & DOP_FLUSH_ALL_TLBS )
-            flush_tlb_mask(d->domain_dirty_cpumask);
+            flush_tlb_mask(&d->domain_dirty_cpumask);
         else
             flush_tlb_local();
     }
@@ -2811,9 +2811,9 @@ int do_mmuext_op(
             }
             pmask = vcpumask_to_pcpumask(d, vmask);
             if ( op.cmd == MMUEXT_TLB_FLUSH_MULTI )
-                flush_tlb_mask(pmask);
+                flush_tlb_mask(&pmask);
             else
-                flush_tlb_one_mask(pmask, op.arg1.linear_addr);
+                flush_tlb_one_mask(&pmask, op.arg1.linear_addr);
             break;
         }
 
@@ -2822,7 +2822,7 @@ int do_mmuext_op(
             break;
     
         case MMUEXT_INVLPG_ALL:
-            flush_tlb_one_mask(d->domain_dirty_cpumask, op.arg1.linear_addr);
+            flush_tlb_one_mask(&d->domain_dirty_cpumask, op.arg1.linear_addr);
             break;
 
         case MMUEXT_FLUSH_CACHE:
@@ -3639,7 +3639,7 @@ int do_update_va_mapping(unsigned long v
             pmask = vcpumask_to_pcpumask(d, vmask);
             if ( cpu_isset(smp_processor_id(), pmask) )
                 this_cpu(percpu_mm_info).deferred_ops &= ~DOP_FLUSH_TLB;
-            flush_tlb_mask(pmask);
+            flush_tlb_mask(&pmask);
             break;
         }
         break;
@@ -3657,7 +3657,7 @@ int do_update_va_mapping(unsigned long v
                 flush_tlb_one_local(va);
             break;
         case UVMF_ALL:
-            flush_tlb_one_mask(d->domain_dirty_cpumask, va);
+            flush_tlb_one_mask(&d->domain_dirty_cpumask, va);
             break;
         default:
             if ( unlikely(!is_pv_32on64_domain(d) ?
@@ -3667,7 +3667,7 @@ int do_update_va_mapping(unsigned long v
             pmask = vcpumask_to_pcpumask(d, vmask);
             if ( this_cpu(percpu_mm_info).deferred_ops & DOP_FLUSH_TLB )
                 cpu_clear(smp_processor_id(), pmask);
-            flush_tlb_one_mask(pmask, va);
+            flush_tlb_one_mask(&pmask, va);
             break;
         }
         break;
xen/arch/x86/mm/hap/hap.c +3 -3
@@ -64,7 +64,7 @@ int hap_enable_log_dirty(struct domain *
 
     /* set l1e entries of P2M table to be read-only. */
     p2m_change_entry_type_global(d, p2m_ram_rw, p2m_ram_logdirty);
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
     return 0;
 }
 
@@ -83,7 +83,7 @@ void hap_clean_dirty_bitmap(struct domai
 {
     /* set l1e entries of P2M table to be read-only. */
     p2m_change_entry_type_global(d, p2m_ram_rw, p2m_ram_logdirty);
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
 }
 
 /************************************************/
@@ -643,7 +643,7 @@ hap_write_p2m_entry(struct vcpu *v, unsi
     safe_write_pte(p, new);
     if ( (old_flags & _PAGE_PRESENT)
          && (level == 1 || (level == 2 && (old_flags & _PAGE_PSE))) )
-             flush_tlb_mask(v->domain->domain_dirty_cpumask);
+             flush_tlb_mask(&v->domain->domain_dirty_cpumask);
 
 #if CONFIG_PAGING_LEVELS == 3
     /* install P2M in monitor table for PAE Xen */
xen/arch/x86/mm/shadow/common.c +9 -9
@@ -695,7 +695,7 @@ static int oos_remove_write_access(struc
     }
 
     if ( ftlb )
-        flush_tlb_mask(v->domain->domain_dirty_cpumask);
+        flush_tlb_mask(&v->domain->domain_dirty_cpumask);
 
     return 0;
 }
@@ -1145,7 +1145,7 @@ sh_validate_guest_pt_write(struct vcpu *
     rc = sh_validate_guest_entry(v, gmfn, entry, size);
     if ( rc & SHADOW_SET_FLUSH )
         /* Need to flush TLBs to pick up shadow PT changes */
-        flush_tlb_mask(d->domain_dirty_cpumask);
+        flush_tlb_mask(&d->domain_dirty_cpumask);
     if ( rc & SHADOW_SET_ERROR ) 
     {
         /* This page is probably not a pagetable any more: tear it out of the 
@@ -1393,7 +1393,7 @@ static void _shadow_prealloc(
                 /* See if that freed up enough space */
                 if ( space_is_available(d, order, count) )
                 {
-                    flush_tlb_mask(d->domain_dirty_cpumask);
+                    flush_tlb_mask(&d->domain_dirty_cpumask);
                     return;
                 }
             }
@@ -1447,7 +1447,7 @@ static void shadow_blow_tables(struct do
                                pagetable_get_mfn(v->arch.shadow_table[i]));
 
     /* Make sure everyone sees the unshadowings */
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
 }
 
 void shadow_blow_tables_per_domain(struct domain *d)
@@ -1554,7 +1554,7 @@ mfn_t shadow_alloc(struct domain *d,  
         if ( unlikely(!cpus_empty(mask)) )
         {
             perfc_incr(shadow_alloc_tlbflush);
-            flush_tlb_mask(mask);
+            flush_tlb_mask(&mask);
         }
         /* Now safe to clear the page for reuse */
         p = sh_map_domain_page(page_to_mfn(sp+i));
@@ -2803,7 +2803,7 @@ void sh_remove_shadows(struct vcpu *v, m
 
     /* Need to flush TLBs now, so that linear maps are safe next time we 
      * take a fault. */
-    flush_tlb_mask(v->domain->domain_dirty_cpumask);
+    flush_tlb_mask(&v->domain->domain_dirty_cpumask);
 
     if ( do_locking ) shadow_unlock(v->domain);
 }
@@ -3435,7 +3435,7 @@ shadow_write_p2m_entry(struct vcpu *v, u
         {
             sh_remove_all_shadows_and_parents(v, mfn);
             if ( sh_remove_all_mappings(v, mfn) )
-                flush_tlb_mask(d->domain_dirty_cpumask);    
+                flush_tlb_mask(&d->domain_dirty_cpumask);
         }
     }
 
@@ -3474,7 +3474,7 @@ shadow_write_p2m_entry(struct vcpu *v, u
                 }
                 omfn = _mfn(mfn_x(omfn) + 1);
             }
-            flush_tlb_mask(flushmask);
+            flush_tlb_mask(&flushmask);
             
             if ( npte )
                 unmap_domain_page(npte);
@@ -3752,7 +3752,7 @@ int shadow_track_dirty_vram(struct domai
         }
     }
     if ( flush_tlb )
-        flush_tlb_mask(d->domain_dirty_cpumask);    
+        flush_tlb_mask(&d->domain_dirty_cpumask);
     goto out;
 
 out_sl1ma:
xen/arch/x86/mm/shadow/multi.c +4 -4
@@ -3146,7 +3146,7 @@ static int sh_page_fault(struct vcpu *v,
          */
         perfc_incr(shadow_rm_write_flush_tlb);
         atomic_inc(&d->arch.paging.shadow.gtable_dirty_version);
-        flush_tlb_mask(d->domain_dirty_cpumask);
+        flush_tlb_mask(&d->domain_dirty_cpumask);
     }
 
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
@@ -4135,7 +4135,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
      * (old) shadow linear maps in the writeable mapping heuristics. */
 #if GUEST_PAGING_LEVELS == 2
     if ( sh_remove_write_access(v, gmfn, 2, 0) != 0 )
-        flush_tlb_mask(v->domain->domain_dirty_cpumask); 
+        flush_tlb_mask(&v->domain->domain_dirty_cpumask);
     sh_set_toplevel_shadow(v, 0, gmfn, SH_type_l2_shadow);
 #elif GUEST_PAGING_LEVELS == 3
     /* PAE guests have four shadow_table entries, based on the 
@@ -4158,7 +4158,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
             }
         }
         if ( flush ) 
-            flush_tlb_mask(v->domain->domain_dirty_cpumask);
+            flush_tlb_mask(&v->domain->domain_dirty_cpumask);
         /* Now install the new shadows. */
         for ( i = 0; i < 4; i++ ) 
         {
@@ -4179,7 +4179,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
     }
 #elif GUEST_PAGING_LEVELS == 4
     if ( sh_remove_write_access(v, gmfn, 4, 0) != 0 )
-        flush_tlb_mask(v->domain->domain_dirty_cpumask);
+        flush_tlb_mask(&v->domain->domain_dirty_cpumask);
     sh_set_toplevel_shadow(v, 0, gmfn, SH_type_l4_shadow);
 #else
 #error This should never happen 
xen/arch/x86/shutdown.c +1 -1
@@ -310,7 +310,7 @@ void machine_restart(unsigned int delay_
     if ( get_apic_id() != boot_cpu_physical_apicid )
     {
         /* Send IPI to the boot CPU (logical cpu 0). */
-        on_selected_cpus(cpumask_of_cpu(0), __machine_restart,
+        on_selected_cpus(cpumask_of(0), __machine_restart,
                          &delay_millisecs, 1, 0);
         for ( ; ; )
             halt();
xen/arch/x86/smp.c +33 -23

145 lines not on this page · raw message

xen/arch/x86/time.c +1 -1
@@ -1189,7 +1189,7 @@ static void time_calibration(void *unuse
     };
 
     /* @wait=1 because we must wait for all cpus before freeing @r. */
-    on_selected_cpus(r.cpu_calibration_map,
+    on_selected_cpus(&r.cpu_calibration_map,
                      opt_consistent_tscs
                      ? time_calibration_tsc_rendezvous
                      : time_calibration_std_rendezvous,
xen/common/Makefile +1 -0
@@ -1,4 +1,5 @@
 obj-y += bitmap.o
+obj-y += cpu.o
 obj-y += domctl.o
 obj-y += domain.o
 obj-y += event_channel.o
xen/common/cpu.c new file +26 -0
@@ -0,0 +1,26 @@
+#include <xen/config.h>
+#include <xen/cpumask.h>
+
+/*
+ * cpu_bit_bitmap[] is a special, "compressed" data structure that
+ * represents all NR_CPUS bits binary values of 1<<nr.
+ *
+ * It is used by cpumask_of() to get a constant address to a CPU
+ * mask value that has a single bit set only.
+ */
+
+/* cpu_bit_bitmap[0] is empty - so we can back into it */
+#define MASK_DECLARE_1(x)	[x+1][0] = 1UL << (x)
+#define MASK_DECLARE_2(x)	MASK_DECLARE_1(x), MASK_DECLARE_1(x+1)
+#define MASK_DECLARE_4(x)	MASK_DECLARE_2(x), MASK_DECLARE_2(x+2)
+#define MASK_DECLARE_8(x)	MASK_DECLARE_4(x), MASK_DECLARE_4(x+4)
+
+const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = {
+
+	MASK_DECLARE_8(0),	MASK_DECLARE_8(8),
+	MASK_DECLARE_8(16),	MASK_DECLARE_8(24),
+#if BITS_PER_LONG > 32
+	MASK_DECLARE_8(32),	MASK_DECLARE_8(40),
+	MASK_DECLARE_8(48),	MASK_DECLARE_8(56),
+#endif
+};
xen/common/grant_table.c +5 -5
@@ -715,7 +715,7 @@ gnttab_unmap_grant_ref(
                 goto fault;
         }
 
-        flush_tlb_mask(current->domain->domain_dirty_cpumask);
+        flush_tlb_mask(&current->domain->domain_dirty_cpumask);
 
         for ( i = 0; i < partial_done; i++ )
             __gnttab_unmap_common_complete(&(common[i]));
@@ -727,7 +727,7 @@ gnttab_unmap_grant_ref(
     return 0;
 
 fault:
-    flush_tlb_mask(current->domain->domain_dirty_cpumask);
+    flush_tlb_mask(&current->domain->domain_dirty_cpumask);
 
     for ( i = 0; i < partial_done; i++ )
         __gnttab_unmap_common_complete(&(common[i]));
@@ -774,7 +774,7 @@ gnttab_unmap_and_replace(
                 goto fault;
         }
         
-        flush_tlb_mask(current->domain->domain_dirty_cpumask);
+        flush_tlb_mask(&current->domain->domain_dirty_cpumask);
         
         for ( i = 0; i < partial_done; i++ )
             __gnttab_unmap_common_complete(&(common[i]));
@@ -786,7 +786,7 @@ gnttab_unmap_and_replace(
     return 0;
 
 fault:
-    flush_tlb_mask(current->domain->domain_dirty_cpumask);
+    flush_tlb_mask(&current->domain->domain_dirty_cpumask);
 
     for ( i = 0; i < partial_done; i++ )
         __gnttab_unmap_common_complete(&(common[i]));
@@ -1123,7 +1123,7 @@ gnttab_transfer(
 #ifndef __ia64__ /* IA64 implicitly replaces the old page in steal_page(). */
         guest_physmap_remove_page(d, gop.mfn, mfn, 0);
 #endif
-        flush_tlb_mask(d->domain_dirty_cpumask);
+        flush_tlb_mask(&d->domain_dirty_cpumask);
 
         /* Find the target domain. */
         if ( unlikely((e = rcu_lock_domain_by_id(gop.domid)) == NULL) )
xen/common/keyhandler.c +1 -1
@@ -119,7 +119,7 @@ static void dump_registers(unsigned char
         if ( cpu == smp_processor_id() )
             continue;
         printk("\n*** Dumping CPU%d host state: ***\n", cpu);
-        on_selected_cpus(cpumask_of_cpu(cpu), __dump_execstate, NULL, 1, 1);
+        on_selected_cpus(cpumask_of(cpu), __dump_execstate, NULL, 1, 1);
     }
 
     printk("\n");
xen/common/page_alloc.c +1 -1
@@ -422,7 +422,7 @@ static struct page_info *alloc_heap_page
     if ( unlikely(!cpus_empty(mask)) )
     {
         perfc_incr(need_flush_tlb_flush);
-        flush_tlb_mask(mask);
+        flush_tlb_mask(&mask);
     }
 
     return pg;
xen/include/asm-ia64/tlbflush.h +1 -1
@@ -39,7 +39,7 @@ void domain_flush_tlb_vhpt(struct domain
 void flush_tlb_for_log_dirty(struct domain *d);
 
 /* Flush v-tlb on cpus set in mask for current domain.  */
-void flush_tlb_mask(cpumask_t mask);
+void flush_tlb_mask(const cpumask_t *mask);
 
 /* Flush local machine TLB.  */
 void local_flush_tlb_all (void);
xen/include/asm-x86/flushtlb.h +5 -5
@@ -90,12 +90,12 @@ void flush_area_local(const void *va, un
 #define flush_local(flags) flush_area_local(NULL, flags)
 
 /* Flush specified CPUs' TLBs/caches */
-void flush_area_mask(cpumask_t, const void *va, unsigned int flags);
+void flush_area_mask(const cpumask_t *, const void *va, unsigned int flags);
 #define flush_mask(mask, flags) flush_area_mask(mask, NULL, flags)
 
 /* Flush all CPUs' TLBs/caches */
-#define flush_area_all(va, flags) flush_area_mask(cpu_online_map, va, flags)
-#define flush_all(flags) flush_mask(cpu_online_map, flags)
+#define flush_area_all(va, flags) flush_area_mask(&cpu_online_map, va, flags)
+#define flush_all(flags) flush_mask(&cpu_online_map, flags)
 
 /* Flush local TLBs */
 #define flush_tlb_local()                       \
@@ -111,8 +111,8 @@ void flush_area_mask(cpumask_t, const vo
 
 /* Flush all CPUs' TLBs */
 #define flush_tlb_all()                         \
-    flush_tlb_mask(cpu_online_map)
+    flush_tlb_mask(&cpu_online_map)
 #define flush_tlb_one_all(v)                    \
-    flush_tlb_one_mask(cpu_online_map, v)
+    flush_tlb_one_mask(&cpu_online_map, v)
 
 #endif /* __FLUSHTLB_H__ */
xen/include/asm-x86/genapic.h +4 -4
@@ -35,7 +35,7 @@ struct genapic { 
 	void (*clustered_apic_check)(void);
 	cpumask_t (*target_cpus)(void);
 	unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
-	void (*send_IPI_mask)(cpumask_t mask, int vector);
+	void (*send_IPI_mask)(const cpumask_t *mask, int vector);
 };
 
 #define APICFUNC(x) .x = x
@@ -52,7 +52,7 @@ void init_apic_ldr_flat(void);
 void clustered_apic_check_flat(void);
 cpumask_t target_cpus_flat(void);
 unsigned int cpu_mask_to_apicid_flat(cpumask_t cpumask);
-void send_IPI_mask_flat(cpumask_t mask, int vector);
+void send_IPI_mask_flat(const cpumask_t *mask, int vector);
 #define GENAPIC_FLAT \
 	.int_delivery_mode = dest_LowestPrio, \
 	.int_dest_mode = 1 /* logical delivery */, \
@@ -66,7 +66,7 @@ void init_apic_ldr_x2apic(void);
 void clustered_apic_check_x2apic(void);
 cpumask_t target_cpus_x2apic(void);
 unsigned int cpu_mask_to_apicid_x2apic(cpumask_t cpumask);
-void send_IPI_mask_x2apic(cpumask_t mask, int vector);
+void send_IPI_mask_x2apic(const cpumask_t *mask, int vector);
 #define GENAPIC_X2APIC \
 	.int_delivery_mode = dest_Fixed, \
 	.int_dest_mode = 0 /* physical delivery */, \
@@ -80,7 +80,7 @@ void init_apic_ldr_phys(void);
 void clustered_apic_check_phys(void);
 cpumask_t target_cpus_phys(void);
 unsigned int cpu_mask_to_apicid_phys(cpumask_t cpumask);
-void send_IPI_mask_phys(cpumask_t mask, int vector);
+void send_IPI_mask_phys(const cpumask_t *mask, int vector);
 #define GENAPIC_PHYS \
 	.int_delivery_mode = dest_Fixed, \
 	.int_dest_mode = 0 /* physical delivery */, \
xen/include/xen/cpumask.h +17 -12
@@ -80,7 +80,6 @@
 #include <xen/kernel.h>
 
 typedef struct { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
-extern cpumask_t _unused_cpumask_arg_;
 
 #define cpu_set(cpu, dst) __cpu_set((cpu), &(dst))
 static inline void __cpu_set(int cpu, volatile cpumask_t *dstp)
@@ -244,17 +243,23 @@ static inline int __cycle_cpu(int n, con
     return nxt;
 }
 
-#define cpumask_of_cpu(cpu)						\
-({									\
-	typeof(_unused_cpumask_arg_) m;					\
-	if (sizeof(m) == sizeof(unsigned long)) {			\
-		m.bits[0] = 1UL<<(cpu);					\
-	} else {							\
-		cpus_clear(m);						\
-		cpu_set((cpu), m);					\
-	}								\
-	m;								\
-})
+/*
+ * Special-case data structure for "single bit set only" constant CPU masks.
+ *
+ * We pre-generate all the 64 (or 32) possible bit positions, with enough
+ * padding to the left and the right, and return the constant pointer
+ * appropriately offset.
+ */
+extern const unsigned long
+	cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];
+
+static inline const cpumask_t *cpumask_of(unsigned int cpu)
+{
+	const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
+	return (const cpumask_t *)(p - cpu / BITS_PER_LONG);
+}
+
+#define cpumask_of_cpu(cpu) (*cpumask_of(cpu))
 
 #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
 
xen/include/xen/smp.h +4 -4
@@ -9,9 +9,9 @@
  */
 extern void smp_send_stop(void);
 
-extern void smp_send_event_check_mask(cpumask_t mask);
+extern void smp_send_event_check_mask(const cpumask_t *mask);
 #define smp_send_event_check_cpu(cpu) \
-    smp_send_event_check_mask(cpumask_of_cpu(cpu))
+    smp_send_event_check_mask(cpumask_of(cpu))
 
 /*
  * Prepare machine for booting other CPUs.
@@ -41,7 +41,7 @@ extern int smp_call_function(
  * Call a function on a selection of processors
  */
 extern int on_selected_cpus(
-    cpumask_t selected,
+    const cpumask_t *selected,
     void (*func) (void *info),
     void *info,
     int retry,
@@ -62,7 +62,7 @@ static inline int on_each_cpu(
     int retry,
     int wait)
 {
-    return on_selected_cpus(cpu_online_map, func, info, retry, wait);
+    return on_selected_cpus(&cpu_online_map, func, info, retry, wait);
 }
 
 #define smp_processor_id() raw_smp_processor_id()
xen/include/xen/softirq.h +1 -1
@@ -39,7 +39,7 @@ static inline void cpumask_raise_softirq
             cpu_clear(cpu, mask);
     }
 
-    smp_send_event_check_mask(mask);
+    smp_send_event_check_mask(&mask);
 }
 
 static inline void cpu_raise_softirq(unsigned int cpu, unsigned int nr)
#1 lore raw
Quoted 3 lines · Jan Beulich

On x86 this changes send_IPI_mask() to always only send IPIs to remote CPUs (meaning any caller needing to handle the current CPU as well has to do so on its own).

Why?

-- Keir

#2 lore raw
Quoted 7 lines · Keir Fraser
Quoted 3 lines · Jan Beulich

On x86 this changes send_IPI_mask() to always only send IPIs to remote CPUs (meaning any caller needing to handle the current CPU as well has to do so on its own).

Why?

Oh, I see why. Fair enough I guess.

-- Keir

#3 lore raw
In reply to Jan Beulich
Quoted 7 lines · Jan Beulich

Rather than passing cpumasks by value in all cases (which is problematic for large NR_CPUS configurations), pass them 'by reference' (i.e. through a pointer to a const cpumask).

On x86 this changes send_IPI_mask() to always only send IPIs to remote CPUs (meaning any caller needing to handle the current CPU as well has to do so on its own).

This doesn't apply. Can you refresh or try sending as an email attachment (may as well do same for the dependent 'remove unused parameter of on_selected_cpu' patch as well).

-- Keir

#4 lore raw

Re: [PATCH] adjust the way cpumasks get passed around(v2)

Quoted 7 lines
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 26.05.09 12:58 >>>

Quoted 4 lines · Jan Beulich

Rather than passing cpumasks by value in all cases (which is problematic for large NR_CPUS configurations), pass them 'by reference' (i.e. through a pointer to a const cpumask).

Quoted 7 lines
Quoted 3 lines

On x86 this changes send_IPI_mask() to always only send IPIs to remote CPUs (meaning any caller needing to handle the current CPU as well has to do so on its own).

This doesn't apply. Can you refresh or try sending as an email attachment (may as well do same for the dependent 'remove unused parameter of on_selected_cpu' patch as well).

Both attached. I'll have to do some looking around to see why all of the sudden such problems are happening again.

Jan

Remove the unused "retry" parameter of on_selected_cpus(), on_each_cpu(), smp_call_function(), and smp_call_function_single().

IA64 changes compile-tested only.

Will only apply cleanly with the earlier sent cpumask passing patch applied first.

xen/arch/ia64/linux-xen/mca.c +2 -2
@@ -956,7 +956,7 @@ ia64_mca_cmc_vector_enable (void *dummy)
 static void
 ia64_mca_cmc_vector_disable_keventd(void *unused)
 {
-	on_each_cpu(ia64_mca_cmc_vector_disable, NULL, 1, 0);
+	on_each_cpu(ia64_mca_cmc_vector_disable, NULL, 0);
 }
 
 /*
@@ -968,7 +968,7 @@ ia64_mca_cmc_vector_disable_keventd(void
 static void
 ia64_mca_cmc_vector_enable_keventd(void *unused)
 {
-	on_each_cpu(ia64_mca_cmc_vector_enable, NULL, 1, 0);
+	on_each_cpu(ia64_mca_cmc_vector_enable, NULL, 0);
 }
 #endif /* !XEN	*/
 
xen/arch/ia64/linux-xen/perfmon.c +5 -5
@@ -1895,7 +1895,7 @@ pfm_syswide_cleanup_other_cpu(pfm_contex
 	int ret;
 
 	DPRINT(("calling CPU%d for cleanup\n", ctx->ctx_cpu));
-	ret = smp_call_function_single(ctx->ctx_cpu, pfm_syswide_force_stop, ctx, 0, 1);
+	ret = smp_call_function_single(ctx->ctx_cpu, pfm_syswide_force_stop, ctx, 1);
 	DPRINT(("called CPU%d for cleanup ret=%d\n", ctx->ctx_cpu, ret));
 }
 #endif /* CONFIG_SMP */
@@ -6895,7 +6895,7 @@ pfm_install_alt_pmu_interrupt(pfm_intr_h
 	}
 
 	/* save the current system wide pmu states */
-	ret = on_each_cpu(pfm_alt_save_pmu_state, NULL, 0, 1);
+	ret = on_each_cpu(pfm_alt_save_pmu_state, NULL, 1);
 	if (ret) {
 		DPRINT(("on_each_cpu() failed: %d\n", ret));
 		goto cleanup_reserve;
@@ -6940,7 +6940,7 @@ pfm_remove_alt_pmu_interrupt(pfm_intr_ha
 
 	pfm_alt_intr_handler = NULL;
 
-	ret = on_each_cpu(pfm_alt_restore_pmu_state, NULL, 0, 1);
+	ret = on_each_cpu(pfm_alt_restore_pmu_state, NULL, 1);
 	if (ret) {
 		DPRINT(("on_each_cpu() failed: %d\n", ret));
 	}
@@ -7499,7 +7499,7 @@ xenpfm_context_load(XEN_GUEST_HANDLE(pfa
 
 	BUG_ON(in_irq());
 	spin_lock(&xenpfm_context_lock);
-	smp_call_function(&xenpfm_context_load_cpu, &arg, 1, 1);
+	smp_call_function(&xenpfm_context_load_cpu, &arg, 1);
 	xenpfm_context_load_cpu(&arg);
 	spin_unlock(&xenpfm_context_lock);
 	for_each_online_cpu(cpu) {
@@ -7553,7 +7553,7 @@ xenpfm_context_unload(void)
 		return error;
 	}
 
-	smp_call_function(&xenpfm_context_unload_cpu, &arg, 1, 1);
+	smp_call_function(&xenpfm_context_unload_cpu, &arg, 1);
 	xenpfm_context_unload_cpu(&arg);
 	spin_unlock(&xenpfm_context_lock);
 	for_each_online_cpu(cpu) {
xen/arch/ia64/linux-xen/smp.c +5 -6
@@ -274,7 +274,7 @@ smp_send_reschedule (int cpu)
 void
 smp_flush_tlb_all (void)
 {
-	on_each_cpu((void (*)(void *))local_flush_tlb_all, NULL, 1, 1);
+	on_each_cpu((void (*)(void *))local_flush_tlb_all, NULL, 1);
 }
 
 void
@@ -297,7 +297,7 @@ smp_flush_tlb_mm (struct mm_struct *mm)
 	 * anyhow, and once a CPU is interrupted, the cost of local_flush_tlb_all() is
 	 * rather trivial.
 	 */
-	on_each_cpu((void (*)(void *))local_finish_flush_tlb_mm, mm, 1, 1);
+	on_each_cpu((void (*)(void *))local_finish_flush_tlb_mm, mm, 1);
 }
 #endif
 
@@ -314,7 +314,7 @@ smp_flush_tlb_mm (struct mm_struct *mm)
  */
 
 int
-smp_call_function_single (int cpuid, void (*func) (void *info), void *info, int nonatomic,
+smp_call_function_single (int cpuid, void (*func) (void *info), void *info,
 			  int wait)
 {
 	struct call_data_struct data;
@@ -372,7 +372,6 @@ EXPORT_SYMBOL(smp_call_function_single);
  *  [SUMMARY]	Run a function on all other CPUs.
  *  <func>	The function to run. This must be fast and non-blocking.
  *  <info>	An arbitrary pointer to pass to the function.
- *  <nonatomic>	currently unused.
  *  <wait>	If true, wait (atomically) until function has completed on other CPUs.
  *  [RETURNS]   0 on success, else a negative status code.
  *
@@ -383,7 +382,7 @@ EXPORT_SYMBOL(smp_call_function_single);
  * hardware interrupt handler or from a bottom half handler.
  */
 int
-smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wait)
+smp_call_function (void (*func) (void *info), void *info, int wait)
 {
 	struct call_data_struct data;
 	int cpus = num_online_cpus()-1;
@@ -438,7 +437,7 @@ EXPORT_SYMBOL(smp_call_function);
 #ifdef XEN
 int
 on_selected_cpus(const cpumask_t *selected, void (*func) (void *info),
-                 void *info, int retry, int wait)
+                 void *info, int wait)
 {
 	struct call_data_struct data;
 	unsigned int cpu, nr_cpus = cpus_weight(*selected);
xen/arch/ia64/linux-xen/smpboot.c +1 -1
@@ -307,7 +307,7 @@ ia64_sync_itc (unsigned int master)
 
 	go[MASTER] = 1;
 
-	if (smp_call_function_single(master, sync_master, NULL, 1, 0) < 0) {
+	if (smp_call_function_single(master, sync_master, NULL, 0) < 0) {
 		printk(KERN_ERR "sync_itc: failed to get attention of CPU %u!\n", master);
 		return;
 	}
xen/arch/ia64/linux-xen/sn/kernel/sn2_smp.c +1 -1
@@ -240,7 +240,7 @@ sn2_global_tlb_purge(unsigned long start
 		flush_data.end = end;
 		flush_data.nbits = nbits;
 		on_selected_cpus(&selected_cpus, sn_flush_ptcga_cpu,
-				 &flush_data, 1, 1);
+				 &flush_data, 1);
 	}
 	spin_unlock(&sn2_ptcg_lock2);
 }
xen/arch/ia64/vmx/vmmu.c +1 -2
@@ -448,8 +448,7 @@ IA64FAULT vmx_vcpu_ptc_ga(VCPU *vcpu, u6
             if (cpu != current->processor) {
                 spin_barrier(&per_cpu(schedule_data, cpu).schedule_lock);
                 /* Flush VHPT on remote processors. */
-                smp_call_function_single(cpu, &ptc_ga_remote_func,
-                                         &args, 0, 1);
+                smp_call_function_single(cpu, &ptc_ga_remote_func, &args, 1);
             } else {
                 ptc_ga_remote_func(&args);
             }
xen/arch/ia64/vmx/vtlb.c +1 -1
@@ -643,7 +643,7 @@ void vmx_vcpu_flush_vtlb_all(VCPU *v)
     if (v->processor == smp_processor_id())
         __thash_purge_all(v);
     else
-        smp_call_function_single(v->processor, __thash_purge_all, v, 1, 1);
+        smp_call_function_single(v->processor, __thash_purge_all, v, 1);
     vcpu_unpause(v);
 }
 
xen/arch/ia64/xen/cpufreq/cpufreq.c +2 -4
@@ -95,8 +95,7 @@ acpi_cpufreq_get (unsigned int cpu)
 	if (cpu == smp_processor_id())
 		processor_get_freq((void*)&freq);
 	else
-		smp_call_function_single(cpu, processor_get_freq,
-					 (void *)&freq, 0, 1);
+		smp_call_function_single(cpu, processor_get_freq, &freq, 1);
 
 	return freq;
 }
@@ -143,8 +142,7 @@ processor_set_freq (struct acpi_cpufreq_
 	if (cpu == smp_processor_id())
 		processor_set_pstate((void *)&value);
 	else
-		smp_call_function_single(cpu, processor_set_pstate,
-				(void *)&value, 0, 1);
+		smp_call_function_single(cpu, processor_set_pstate, &value, 1);
 
 	if (value) {
 		printk(KERN_WARNING "Transition failed\n");
xen/arch/ia64/xen/flushtlb.c +1 -1
@@ -70,7 +70,7 @@ void
 new_tlbflush_clock_period(void)
 {
     /* flush all vhpt of physical cpu and mTLB */
-    on_each_cpu(tlbflush_clock_local_flush, NULL, 1, 1);
+    on_each_cpu(tlbflush_clock_local_flush, NULL, 1);
 
     /*
      * if global TLB shootdown is finished, increment tlbflush_time
xen/arch/ia64/xen/fw_emul.c +5 -6
@@ -281,7 +281,7 @@ sal_emulator (long index, unsigned long 
 				IA64_SAL_DEBUG("SAL_GET_STATE_INFO: remote\n");
 				ret = smp_call_function_single(e->cpuid,
 				                               get_state_info_on,
-				                               &arg, 0, 1);
+				                               &arg, 1);
 				if (ret < 0) {
 					printk("SAL_GET_STATE_INFO "
 					       "smp_call_function_single error:"
@@ -344,7 +344,7 @@ sal_emulator (long index, unsigned long 
 				int ret;
 				IA64_SAL_DEBUG("SAL_CLEAR_STATE_INFO: remote\n");
 				ret = smp_call_function_single(e->cpuid,
-					clear_state_info_on, &arg, 0, 1);
+					clear_state_info_on, &arg, 1);
 				if (ret < 0) {
 					printk("sal_emulator: "
 					       "SAL_CLEAR_STATE_INFO "
@@ -845,8 +845,7 @@ xen_pal_emulator(unsigned long index, u6
 				.progress = 0,
 				.status = 0
 			};
-			smp_call_function(remote_pal_cache_flush,
-					  (void *)&args, 1, 1);
+			smp_call_function(remote_pal_cache_flush, &args, 1);
 			if (args.status != 0)
 				panic_domain(NULL, "PAL_CACHE_FLUSH ERROR, "
 					     "remote status %lx", args.status);
@@ -945,7 +944,7 @@ xen_pal_emulator(unsigned long index, u6
 			/* must be performed on all remote processors 
 			   in the coherence domain. */
 			smp_call_function(remote_pal_prefetch_visibility,
-					  (void *)in1, 1, 1);
+					  (void *)in1, 1);
 			status = 1; /* no more necessary on remote processor */
 		}
 		break;
@@ -953,7 +952,7 @@ xen_pal_emulator(unsigned long index, u6
 		status = ia64_pal_mc_drain();
 		/* FIXME: All vcpus likely call PAL_MC_DRAIN.
 		   That causes the congestion. */
-		smp_call_function(remote_pal_mc_drain, NULL, 1, 1);
+		smp_call_function(remote_pal_mc_drain, NULL, 1);
 		break;
 	    case PAL_BRAND_INFO:
 		if (in1 == 0) {
xen/arch/ia64/xen/vhpt.c +7 -7
@@ -307,7 +307,7 @@ void domain_flush_vtlb_all(struct domain
 			// takes care of mTLB flush.
 			smp_call_function_single(v->processor,
 						 __vcpu_flush_vtlb_all,
-						 v, 1, 1);
+						 v, 1);
 	}
 	perfc_incr(domain_flush_vtlb_all);
 }
@@ -513,9 +513,9 @@ void domain_flush_tlb_vhpt(struct domain
 {
 	/* Very heavy...  */
 	if (HAS_PERVCPU_VHPT(d) || is_hvm_domain(d))
-		on_each_cpu((void (*)(void *))local_flush_tlb_all, NULL, 1, 1);
+		on_each_cpu((void (*)(void *))local_flush_tlb_all, NULL, 1);
 	else
-		on_each_cpu((void (*)(void *))flush_tlb_vhpt_all, d, 1, 1);
+		on_each_cpu((void (*)(void *))flush_tlb_vhpt_all, d, 1);
 	cpus_clear (d->domain_dirty_cpumask);
 }
 
@@ -532,7 +532,7 @@ void flush_tlb_for_log_dirty(struct doma
 			thash_purge_all(v);
 		}
 		smp_call_function((void (*)(void *))local_flush_tlb_all, 
-					NULL, 1, 1);
+					NULL, 1);
 	} else if (HAS_PERVCPU_VHPT(d)) {
 		for_each_vcpu (d, v) {
 			if (!v->is_initialised)
@@ -541,9 +541,9 @@ void flush_tlb_for_log_dirty(struct doma
 			vcpu_purge_tr_entry(&PSCBX(v,itlb));
 			vcpu_vhpt_flush(v);
 		}
-		on_each_cpu((void (*)(void *))local_flush_tlb_all, NULL, 1, 1);
+		on_each_cpu((void (*)(void *))local_flush_tlb_all, NULL, 1);
 	} else {
-		on_each_cpu((void (*)(void *))flush_tlb_vhpt_all, d, 1, 1);
+		on_each_cpu((void (*)(void *))flush_tlb_vhpt_all, d, 1);
 	}
 	cpus_clear (d->domain_dirty_cpumask);
 }
@@ -562,7 +562,7 @@ void flush_tlb_mask(const cpumask_t *mas
     for_each_cpu_mask (cpu, *mask)
         if (cpu != smp_processor_id())
             smp_call_function_single
-                (cpu, (void (*)(void *))flush_tlb_vhpt_all, NULL, 1, 1);
+                (cpu, (void (*)(void *))flush_tlb_vhpt_all, NULL, 1);
 }
 
 #ifdef PERF_COUNTERS
xen/arch/x86/acpi/cpufreq/cpufreq.c +3 -3
@@ -186,7 +186,7 @@ static void drv_read(struct drv_cmd *cmd
     if (likely(cpu_isset(smp_processor_id(), cmd->mask)))
         do_drv_read((void *)cmd);
     else
-        on_selected_cpus(&cmd->mask, do_drv_read, (void *)cmd, 0, 1);
+        on_selected_cpus(&cmd->mask, do_drv_read, cmd, 1);
 }
 
 static void drv_write(struct drv_cmd *cmd)
@@ -195,7 +195,7 @@ static void drv_write(struct drv_cmd *cm
         cpu_isset(smp_processor_id(), cmd->mask))
         do_drv_write((void *)cmd);
     else
-        on_selected_cpus(&cmd->mask, do_drv_write, (void *)cmd, 0, 0);
+        on_selected_cpus(&cmd->mask, do_drv_write, cmd, 0);
 }
 
 static u32 get_cur_val(cpumask_t mask)
@@ -303,7 +303,7 @@ static unsigned int get_measured_perf(un
         read_measured_perf_ctrs((void *)&readin);
     } else {
         on_selected_cpus(cpumask_of(cpu), read_measured_perf_ctrs,
-                        (void *)&readin, 0, 1);
+                        &readin, 1);
     }
 
     cur.aperf.whole = readin.aperf.whole - saved->aperf.whole;
xen/arch/x86/acpi/cpufreq/powernow.c +1 -1
@@ -121,7 +121,7 @@ static int powernow_cpufreq_target(struc
 
     cmd.val = next_perf_state;
 
-    on_selected_cpus(&cmd.mask, transition_pstate, (void *) &cmd, 0, 0);
+    on_selected_cpus(&cmd.mask, transition_pstate, &cmd, 0);
 
     perf->state = next_perf_state;
     policy->cur = freqs.new;
xen/arch/x86/cpu/amd.c +1 -1
@@ -246,7 +246,7 @@ static void check_disable_c1e(unsigned i
 {
 	/* C1E is sometimes enabled during entry to ACPI mode. */
 	if ((port == acpi_smi_cmd) && (value == acpi_enable_value))
-		on_each_cpu(disable_c1e, NULL, 1, 1);
+		on_each_cpu(disable_c1e, NULL, 1);
 }
 
 static void __devinit init_amd(struct cpuinfo_x86 *c)
xen/arch/x86/cpu/mcheck/amd_nonfatal.c +1 -1
@@ -133,7 +133,7 @@ void mce_amd_checkregs(void *info)
  */
 static void mce_amd_work_fn(void *data)
 {
-	on_each_cpu(mce_amd_checkregs, data, 1, 1);
+	on_each_cpu(mce_amd_checkregs, data, 1);
 
 	if (adjust > 0) {
 		if (!guest_enabled_event(dom0->vcpu[0], VIRQ_MCA) ) {
xen/arch/x86/cpu/mcheck/mce.c +3 -4
@@ -1162,8 +1162,7 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 			if (log_cpus == NULL)
 				return x86_mcerr("do_mca cpuinfo", -ENOMEM);
 
-			if (on_each_cpu(do_mc_get_cpu_info, log_cpus,
-			    1, 1) != 0) {
+			if (on_each_cpu(do_mc_get_cpu_info, log_cpus, 1)) {
 				xfree(log_cpus);
 				return x86_mcerr("do_mca cpuinfo", -EIO);
 			}
@@ -1206,7 +1205,7 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 		add_taint(TAINT_ERROR_INJECT);
 
 		on_selected_cpus(cpumask_of(target), x86_mc_msrinject,
-				 mc_msrinject, 1, 1);
+				 mc_msrinject, 1);
 
 		break;
 
@@ -1226,7 +1225,7 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 		add_taint(TAINT_ERROR_INJECT);
 
 		on_selected_cpus(cpumask_of(target), x86_mc_mceinject,
-		                 mc_mceinject, 1, 1);
+		                 mc_mceinject, 1);
 		break;
 
 	default:
xen/arch/x86/cpu/mcheck/mce_intel.c +1 -1
@@ -632,7 +632,7 @@ static void __cpu_mcheck_distribute_cmci
 void cpu_mcheck_distribute_cmci(void)
 {
     if (cmci_support && !mce_disabled)
-        on_each_cpu(__cpu_mcheck_distribute_cmci, NULL, 0, 0);
+        on_each_cpu(__cpu_mcheck_distribute_cmci, NULL, 0);
 }
 
 static void clear_cmci(void)
xen/arch/x86/cpu/mcheck/non-fatal.c +1 -1
@@ -69,7 +69,7 @@ static void mce_checkregs (void *info)
 
 static void mce_work_fn(void *data)
 { 
-	on_each_cpu(mce_checkregs, NULL, 1, 1);
+	on_each_cpu(mce_checkregs, NULL, 1);
 
 	if (variable_period) {
 		if (adjust)
xen/arch/x86/cpu/mtrr/main.c +2 -2
@@ -229,7 +229,7 @@ static void set_mtrr(unsigned int reg, u
 	atomic_set(&data.gate,0);
 
 	/*  Start the ball rolling on other CPUs  */
-	if (smp_call_function(ipi_handler, &data, 1, 0) != 0)
+	if (smp_call_function(ipi_handler, &data, 0) != 0)
 		panic("mtrr: timed out waiting for other CPUs\n");
 
 	local_irq_save(flags);
@@ -688,7 +688,7 @@ void mtrr_save_state(void)
 	if (cpu == 0)
 		mtrr_save_fixed_ranges(NULL);
 	else
-		on_selected_cpus(cpumask_of(0), mtrr_save_fixed_ranges, NULL, 1, 1);
+		on_selected_cpus(cpumask_of(0), mtrr_save_fixed_ranges, NULL, 1);
 	put_cpu();
 }
 
xen/arch/x86/hvm/hvm.c +1 -1
@@ -971,7 +971,7 @@ int hvm_set_cr0(unsigned long value)
             if ( !v->domain->arch.hvm_domain.is_in_uc_mode )
             {
                 /* Flush physical caches. */
-                on_each_cpu(local_flush_cache, NULL, 1, 1);
+                on_each_cpu(local_flush_cache, NULL, 1);
                 hvm_set_uc_mode(v, 1);
             }
             spin_unlock(&v->domain->arch.hvm_domain.uc_lock);
xen/arch/x86/hvm/svm/svm.c +1 -1
@@ -1173,7 +1173,7 @@ static void wbinvd_ipi(void *info)
 static void svm_wbinvd_intercept(void)
 {
     if ( has_arch_pdevs(current->domain) )
-        on_each_cpu(wbinvd_ipi, NULL, 1, 1);
+        on_each_cpu(wbinvd_ipi, NULL, 1);
 }
 
 static void svm_vmexit_do_invalidate_cache(struct cpu_user_regs *regs)
xen/arch/x86/hvm/vmx/vmcs.c +2 -2
@@ -264,7 +264,7 @@ static void vmx_clear_vmcs(struct vcpu *
     int cpu = v->arch.hvm_vmx.active_cpu;
 
     if ( cpu != -1 )
-        on_selected_cpus(cpumask_of(cpu), __vmx_clear_vmcs, v, 1, 1);
+        on_selected_cpus(cpumask_of(cpu), __vmx_clear_vmcs, v, 1);
 }
 
 static void vmx_load_vmcs(struct vcpu *v)
@@ -899,7 +899,7 @@ void vmx_do_resume(struct vcpu *v)
         {
             int cpu = v->arch.hvm_vmx.active_cpu;
             if ( cpu != -1 )
-                on_selected_cpus(cpumask_of(cpu), wbinvd_ipi, NULL, 1, 1);
+                on_selected_cpus(cpumask_of(cpu), wbinvd_ipi, NULL, 1);
         }
 
         vmx_clear_vmcs(v);
xen/arch/x86/hvm/vmx/vmx.c +2 -2
@@ -1219,7 +1219,7 @@ void ept_sync_domain(struct domain *d)
     if ( d->arch.hvm_domain.hap_enabled && d->vcpu[0] )
     {
         ASSERT(local_irq_is_enabled());
-        on_each_cpu(__ept_sync_domain, d, 1, 1);
+        on_each_cpu(__ept_sync_domain, d, 1);
     }
 }
 
@@ -2130,7 +2130,7 @@ static void vmx_wbinvd_intercept(void)
         return;
 
     if ( cpu_has_wbinvd_exiting )
-        on_each_cpu(wbinvd_ipi, NULL, 1, 1);
+        on_each_cpu(wbinvd_ipi, NULL, 1);
     else
         wbinvd();
 }
xen/arch/x86/irq.c +3 -3
@@ -516,7 +516,7 @@ static void __pirq_guest_eoi(struct doma
     }
 
     if ( !cpus_empty(cpu_eoi_map) )
-        on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1, 0);
+        on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 0);
 }
 
 int pirq_guest_eoi(struct domain *d, int irq)
@@ -755,7 +755,7 @@ static irq_guest_action_t *__pirq_guest_
         {
             cpu_eoi_map = action->cpu_eoi_map;
             spin_unlock_irq(&desc->lock);
-            on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1, 0);
+            on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 0);
             spin_lock_irq(&desc->lock);
         }
         break;
@@ -793,7 +793,7 @@ static irq_guest_action_t *__pirq_guest_
     {
         BUG_ON(action->ack_type != ACKTYPE_EOI);
         spin_unlock_irq(&desc->lock);
-        on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1, 1);
+        on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1);
         spin_lock_irq(&desc->lock);
     }
 
xen/arch/x86/machine_kexec.c +1 -1
@@ -100,7 +100,7 @@ void machine_reboot_kexec(xen_kexec_imag
     if ( reboot_cpu_id != smp_processor_id() )
     {
         on_selected_cpus(cpumask_of(reboot_cpu_id), __machine_reboot_kexec,
-                         image, 1, 0);
+                         image, 0);
         for (;;)
                 ; /* nothing */
     }
xen/arch/x86/oprofile/nmi_int.c +5 -5
@@ -186,7 +186,7 @@ static void nmi_cpu_setup(void * dummy)
 
 int nmi_setup_events(void)
 {
-	on_each_cpu(nmi_cpu_setup, NULL, 0, 1);
+	on_each_cpu(nmi_cpu_setup, NULL, 1);
 	return 0;
 }
 
@@ -207,7 +207,7 @@ int nmi_reserve_counters(void)
 	/* We need to serialize save and setup for HT because the subset
 	 * of msrs are distinct for save and setup operations
 	 */
-	on_each_cpu(nmi_save_registers, NULL, 0, 1);
+	on_each_cpu(nmi_save_registers, NULL, 1);
  	return 0;
 }
 
@@ -256,7 +256,7 @@ static void nmi_cpu_shutdown(void * dumm
  
 void nmi_release_counters(void)
 {
-	on_each_cpu(nmi_cpu_shutdown, NULL, 0, 1);
+	on_each_cpu(nmi_cpu_shutdown, NULL, 1);
 	release_lapic_nmi();
 	free_msrs();
 }
@@ -274,7 +274,7 @@ static void nmi_cpu_start(void * dummy)
 
 int nmi_start(void)
 {
-	on_each_cpu(nmi_cpu_start, NULL, 0, 1);
+	on_each_cpu(nmi_cpu_start, NULL, 1);
 	return 0;
 }
  
@@ -306,7 +306,7 @@ static void nmi_cpu_stop(void * dummy)
  
 void nmi_stop(void)
 {
-	on_each_cpu(nmi_cpu_stop, NULL, 0, 1);
+	on_each_cpu(nmi_cpu_stop, NULL, 1);
 }
 
 
xen/arch/x86/shutdown.c +2 -2
@@ -91,7 +91,7 @@ void machine_halt(void)
     watchdog_disable();
     console_start_sync();
     local_irq_enable();
-    smp_call_function(__machine_halt, NULL, 1, 0);
+    smp_call_function(__machine_halt, NULL, 0);
     __machine_halt(NULL);
 }
 
@@ -311,7 +311,7 @@ void machine_restart(unsigned int delay_
     {
         /* Send IPI to the boot CPU (logical cpu 0). */
         on_selected_cpus(cpumask_of(0), __machine_restart,
-                         &delay_millisecs, 1, 0);
+                         &delay_millisecs, 0);
         for ( ; ; )
             halt();
     }
xen/arch/x86/smp.c +2 -4
@@ -235,19 +235,17 @@ static struct call_data_struct *call_dat
 int smp_call_function(
     void (*func) (void *info),
     void *info,
-    int retry,
     int wait)
 {
     cpumask_t allbutself = cpu_online_map;
     cpu_clear(smp_processor_id(), allbutself);
-    return on_selected_cpus(&allbutself, func, info, retry, wait);
+    return on_selected_cpus(&allbutself, func, info, wait);
 }
 
 int on_selected_cpus(
     const cpumask_t *selected,
     void (*func) (void *info),
     void *info,
-    int retry,
     int wait)
 {
     struct call_data_struct data;
@@ -333,7 +331,7 @@ void smp_send_stop(void)
 {
     int timeout = 10;
 
-    smp_call_function(stop_this_cpu, NULL, 1, 0);
+    smp_call_function(stop_this_cpu, NULL, 0);
 
     /* Wait 10ms for all other CPUs to go offline. */
     while ( (num_online_cpus() > 1) && (timeout-- > 0) )
xen/arch/x86/time.c +1 -1
@@ -1193,7 +1193,7 @@ static void time_calibration(void *unuse
                      opt_consistent_tscs
                      ? time_calibration_tsc_rendezvous
                      : time_calibration_std_rendezvous,
-                     &r, 0, 1);
+                     &r, 1);
 }
 
 void init_percpu_time(void)
xen/arch/x86/x86_32/traps.c +1 -1
@@ -403,7 +403,7 @@ static long register_guest_callback(stru
     case CALLBACKTYPE_sysenter_deprecated:
         if ( !cpu_has_sep )
             ret = -EINVAL;
-        else if ( on_each_cpu(do_update_sysenter, &reg->address, 1, 1) != 0 )
+        else if ( on_each_cpu(do_update_sysenter, &reg->address, 1) != 0 )
             ret = -EIO;
         break;
 
xen/common/gdbstub.c +1 -1
@@ -672,7 +672,7 @@ static void gdb_smp_pause(void)
 
     atomic_set(&gdb_smp_paused_count, 0);
 
-    smp_call_function(gdb_pause_this_cpu, NULL, /* dont wait! */0, 0);
+    smp_call_function(gdb_pause_this_cpu, NULL, /* dont wait! */0);
 
     /* Wait 100ms for all other CPUs to enter pause loop */
     while ( (atomic_read(&gdb_smp_paused_count) < (num_online_cpus() - 1)) 
xen/common/keyhandler.c +2 -2
@@ -119,7 +119,7 @@ static void dump_registers(unsigned char
         if ( cpu == smp_processor_id() )
             continue;
         printk("\n*** Dumping CPU%d host state: ***\n", cpu);
-        on_selected_cpus(cpumask_of(cpu), __dump_execstate, NULL, 1, 1);
+        on_selected_cpus(cpumask_of(cpu), __dump_execstate, NULL, 1);
     }
 
     printk("\n");
@@ -263,7 +263,7 @@ static void read_clocks(unsigned char ke
 
     spin_lock(&lock);
 
-    smp_call_function(read_clocks_slave, NULL, 0, 0);
+    smp_call_function(read_clocks_slave, NULL, 0);
 
     local_irq_disable();
     read_clocks_cpumask = cpu_online_map;
xen/include/asm-ia64/linux-xen/asm/smp.h +2 -2
@@ -127,8 +127,8 @@ extern void __init smp_build_cpu_map(voi
 extern void __init init_smp_config (void);
 extern void smp_do_timer (struct pt_regs *regs);
 
-extern int smp_call_function_single (int cpuid, void (*func) (void *info), void *info,
-				     int retry, int wait);
+extern int smp_call_function_single (int cpuid, void (*func) (void *info),
+				     void *info, int wait);
 extern void smp_send_reschedule (int cpu);
 #ifdef XEN
 extern void lock_ipi_calllock(unsigned long *flags);
xen/include/xen/smp.h +1 -4
@@ -34,7 +34,6 @@ extern void smp_cpus_done(unsigned int m
 extern int smp_call_function(
     void (*func) (void *info),
     void *info,
-    int retry,
     int wait);
 
 /* 
@@ -44,7 +43,6 @@ extern int on_selected_cpus(
     const cpumask_t *selected,
     void (*func) (void *info),
     void *info,
-    int retry,
     int wait);
 
 /*
@@ -59,10 +57,9 @@ void smp_prepare_boot_cpu(void);
 static inline int on_each_cpu(
     void (*func) (void *info),
     void *info,
-    int retry,
     int wait)
 {
-    return on_selected_cpus(&cpu_online_map, func, info, retry, wait);
+    return on_selected_cpus(&cpu_online_map, func, info, wait);
 }
 
 #define smp_processor_id() raw_smp_processor_id()

Rather than passing cpumasks by value in all cases (which is problematic for large NR_CPUS configurations), pass them 'by reference' (i.e. through a pointer to a const cpumask).

On x86 this changes send_IPI_mask() to always only send IPIs to remote CPUs (meaning any caller needing to handle the current CPU as well has to do so on its own).

IA64 changes compile-tested only.

xen/arch/ia64/linux-xen/smp.c +7 -8
@@ -57,19 +57,18 @@
 //#if CONFIG_SMP || IA64
 #if CONFIG_SMP
 //Huh? This seems to be used on ia64 even if !CONFIG_SMP
-void smp_send_event_check_mask(cpumask_t mask)
+void smp_send_event_check_mask(const cpumask_t *mask)
 {
     int cpu;
 
     /*  Not for me.  */
-    cpu_clear(smp_processor_id(), mask);
-    if (cpus_empty(mask))
+    if (cpus_subset(*mask, *cpumask_of(smp_processor_id())))
         return;
 
     //printf("smp_send_event_check_mask called\n");
 
     for (cpu = 0; cpu < NR_CPUS; ++cpu)
-        if (cpu_isset(cpu, mask))
+        if (cpu_isset(cpu, *mask) && cpu != smp_processor_id())
 	    platform_send_ipi(cpu, IA64_IPI_RESCHEDULE, IA64_IPI_DM_INT, 0);
 }
 #endif
@@ -438,11 +437,11 @@ EXPORT_SYMBOL(smp_call_function);
 
 #ifdef XEN
 int
-on_selected_cpus(cpumask_t selected, void (*func) (void *info), void *info,
-                 int retry, int wait)
+on_selected_cpus(const cpumask_t *selected, void (*func) (void *info),
+                 void *info, int retry, int wait)
 {
 	struct call_data_struct data;
-	unsigned int cpu, nr_cpus = cpus_weight(selected);
+	unsigned int cpu, nr_cpus = cpus_weight(*selected);
 
 	ASSERT(local_irq_is_enabled());
 
@@ -460,7 +459,7 @@ on_selected_cpus(cpumask_t selected, voi
 	call_data = &data;
 	wmb();
 
-	for_each_cpu_mask(cpu, selected)
+	for_each_cpu_mask(cpu, *selected)
 		send_IPI_single(cpu, IPI_CALL_FUNC);
 
 	while (atomic_read(wait ? &data.finished : &data.started) != nr_cpus)
xen/arch/ia64/linux-xen/sn/kernel/sn2_smp.c +1 -1
@@ -239,7 +239,7 @@ sn2_global_tlb_purge(unsigned long start
 		flush_data.start = start;
 		flush_data.end = end;
 		flush_data.nbits = nbits;
-		on_selected_cpus(selected_cpus, sn_flush_ptcga_cpu,
+		on_selected_cpus(&selected_cpus, sn_flush_ptcga_cpu,
 				 &flush_data, 1, 1);
 	}
 	spin_unlock(&sn2_ptcg_lock2);
xen/arch/ia64/xen/mm.c +1 -1
@@ -3182,7 +3182,7 @@ int get_page_type(struct page_info *page
                 if ( unlikely(!cpus_empty(mask)) )
                 {
                     perfc_incr(need_flush_tlb_flush);
-                    flush_tlb_mask(mask);
+                    flush_tlb_mask(&mask);
                 }
 
                 /* We lose existing type, back pointer, and validity. */
xen/arch/ia64/xen/vhpt.c +7 -8
@@ -548,22 +548,21 @@ void flush_tlb_for_log_dirty(struct doma
 	cpus_clear (d->domain_dirty_cpumask);
 }
 
-void flush_tlb_mask(cpumask_t mask)
+void flush_tlb_mask(const cpumask_t *mask)
 {
     int cpu;
 
     cpu = smp_processor_id();
-    if (cpu_isset (cpu, mask)) {
-        cpu_clear(cpu, mask);
+    if (cpu_isset(cpu, *mask))
         flush_tlb_vhpt_all (NULL);
-    }
 
-    if (cpus_empty(mask))
+    if (cpus_subset(*mask, *cpumask_of(cpu)))
         return;
 
-    for_each_cpu_mask (cpu, mask)
-        smp_call_function_single
-            (cpu, (void (*)(void *))flush_tlb_vhpt_all, NULL, 1, 1);
+    for_each_cpu_mask (cpu, *mask)
+        if (cpu != smp_processor_id())
+            smp_call_function_single
+                (cpu, (void (*)(void *))flush_tlb_vhpt_all, NULL, 1, 1);
 }
 
 #ifdef PERF_COUNTERS
xen/arch/x86/acpi/cpufreq/cpufreq.c +3 -5
@@ -186,7 +186,7 @@ static void drv_read(struct drv_cmd *cmd
     if (likely(cpu_isset(smp_processor_id(), cmd->mask)))
         do_drv_read((void *)cmd);
     else
-        on_selected_cpus( cmd->mask, do_drv_read, (void *)cmd, 0, 1);
+        on_selected_cpus(&cmd->mask, do_drv_read, (void *)cmd, 0, 1);
 }
 
 static void drv_write(struct drv_cmd *cmd)
@@ -195,7 +195,7 @@ static void drv_write(struct drv_cmd *cm
         cpu_isset(smp_processor_id(), cmd->mask))
         do_drv_write((void *)cmd);
     else
-        on_selected_cpus( cmd->mask, do_drv_write, (void *)cmd, 0, 0);
+        on_selected_cpus(&cmd->mask, do_drv_write, (void *)cmd, 0, 0);
 }
 
 static u32 get_cur_val(cpumask_t mask)
@@ -274,7 +274,6 @@ static unsigned int get_measured_perf(un
     struct cpufreq_policy *policy;    
     struct perf_pair readin, cur, *saved;
     unsigned int perf_percent;
-    cpumask_t cpumask;
     unsigned int retval;
 
     if (!cpu_online(cpu))
@@ -303,8 +302,7 @@ static unsigned int get_measured_perf(un
     if (cpu == smp_processor_id()) {
         read_measured_perf_ctrs((void *)&readin);
     } else {
-        cpumask = cpumask_of_cpu(cpu);
-        on_selected_cpus(cpumask, read_measured_perf_ctrs, 
+        on_selected_cpus(cpumask_of(cpu), read_measured_perf_ctrs,
                         (void *)&readin, 0, 1);
     }
 
xen/arch/x86/acpi/cpufreq/powernow.c +1 -1
@@ -121,7 +121,7 @@ static int powernow_cpufreq_target(struc
 
     cmd.val = next_perf_state;
 
-    on_selected_cpus( cmd.mask, transition_pstate, (void *) &cmd, 0, 0);
+    on_selected_cpus(&cmd.mask, transition_pstate, (void *) &cmd, 0, 0);
 
     perf->state = next_perf_state;
     policy->cur = freqs.new;
xen/arch/x86/cpu/mcheck/mce.c +4 -4
@@ -1205,8 +1205,8 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 
 		add_taint(TAINT_ERROR_INJECT);
 
-		on_selected_cpus(cpumask_of_cpu(target),
-		    x86_mc_msrinject, mc_msrinject, 1, 1);
+		on_selected_cpus(cpumask_of(target), x86_mc_msrinject,
+				 mc_msrinject, 1, 1);
 
 		break;
 
@@ -1225,8 +1225,8 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
 
 		add_taint(TAINT_ERROR_INJECT);
 
-		on_selected_cpus(cpumask_of_cpu(target), x86_mc_mceinject,
-		    mc_mceinject, 1, 1);
+		on_selected_cpus(cpumask_of(target), x86_mc_mceinject,
+		                 mc_mceinject, 1, 1);
 		break;
 
 	default:
xen/arch/x86/cpu/mtrr/main.c +1 -1
@@ -688,7 +688,7 @@ void mtrr_save_state(void)
 	if (cpu == 0)
 		mtrr_save_fixed_ranges(NULL);
 	else
-		on_selected_cpus(cpumask_of_cpu(0), mtrr_save_fixed_ranges, NULL, 1, 1);
+		on_selected_cpus(cpumask_of(0), mtrr_save_fixed_ranges, NULL, 1, 1);
 	put_cpu();
 }
 
xen/arch/x86/crash.c +2 -4
@@ -58,10 +58,8 @@ static int crash_nmi_callback(struct cpu
  */
 static void smp_send_nmi_allbutself(void)
 {
-    cpumask_t allbutself = cpu_online_map;
-    cpu_clear(smp_processor_id(), allbutself);
-    if ( !cpus_empty(allbutself) )
-        send_IPI_mask(allbutself, APIC_DM_NMI);
+    if ( !cpus_subset(cpu_online_map, *cpumask_of(smp_processor_id())) )
+        send_IPI_mask(&cpu_online_map, APIC_DM_NMI);
 }
 
 static void nmi_shootdown_cpus(void)
xen/arch/x86/domain.c +2 -2
@@ -1316,7 +1316,7 @@ void context_switch(struct vcpu *prev, s
     if ( unlikely(!cpu_isset(cpu, dirty_mask) && !cpus_empty(dirty_mask)) )
     {
         /* Other cpus call __sync_lazy_execstate from flush ipi handler. */
-        flush_tlb_mask(dirty_mask);
+        flush_tlb_mask(&dirty_mask);
     }
 
     if ( is_hvm_vcpu(prev) && !list_empty(&prev->arch.hvm_vcpu.tm_list) )
@@ -1410,7 +1410,7 @@ void sync_vcpu_execstate(struct vcpu *v)
         (void)__sync_lazy_execstate();
 
     /* Other cpus call __sync_lazy_execstate from flush ipi handler. */
-    flush_tlb_mask(v->vcpu_dirty_cpumask);
+    flush_tlb_mask(&v->vcpu_dirty_cpumask);
 }
 
 struct migrate_info {
xen/arch/x86/genapic/x2apic.c +4 -3
@@ -56,7 +56,7 @@ unsigned int cpu_mask_to_apicid_x2apic(c
     return cpu_physical_id(first_cpu(cpumask));
 }
 
-void send_IPI_mask_x2apic(cpumask_t cpumask, int vector)
+void send_IPI_mask_x2apic(const cpumask_t *cpumask, int vector)
 {
     unsigned int cpu, cfg;
     unsigned long flags;
@@ -76,8 +76,9 @@ void send_IPI_mask_x2apic(cpumask_t cpum
     local_irq_save(flags);
 
     cfg = APIC_DM_FIXED | 0 /* no shorthand */ | APIC_DEST_PHYSICAL | vector;
-    for_each_cpu_mask ( cpu, cpumask )
-        apic_wrmsr(APIC_ICR, cfg, cpu_physical_id(cpu));
+    for_each_cpu_mask ( cpu, *cpumask )
+        if ( cpu != smp_processor_id() )
+            apic_wrmsr(APIC_ICR, cfg, cpu_physical_id(cpu));
 
     local_irq_restore(flags);
 }
xen/arch/x86/hpet.c +1 -1
@@ -617,7 +617,7 @@ void hpet_disable_legacy_broadcast(void)
 
     spin_unlock_irq(&legacy_hpet_event.lock);
 
-    smp_send_event_check_mask(cpu_online_map);
+    smp_send_event_check_mask(&cpu_online_map);
 }
 
 void hpet_broadcast_enter(void)
xen/arch/x86/hvm/hvm.c +1 -1
@@ -2408,7 +2408,7 @@ static int hvmop_flush_tlb_all(void)
         paging_update_cr3(v);
 
     /* Flush all dirty TLBs. */
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
 
     /* Done. */
     for_each_vcpu ( d, v )
xen/arch/x86/hvm/vmx/vmcs.c +2 -2
@@ -264,7 +264,7 @@ static void vmx_clear_vmcs(struct vcpu *
     int cpu = v->arch.hvm_vmx.active_cpu;
 
     if ( cpu != -1 )
-        on_selected_cpus(cpumask_of_cpu(cpu), __vmx_clear_vmcs, v, 1, 1);
+        on_selected_cpus(cpumask_of(cpu), __vmx_clear_vmcs, v, 1, 1);
 }
 
 static void vmx_load_vmcs(struct vcpu *v)
@@ -899,7 +899,7 @@ void vmx_do_resume(struct vcpu *v)
         {
             int cpu = v->arch.hvm_vmx.active_cpu;
             if ( cpu != -1 )
-                on_selected_cpus(cpumask_of_cpu(cpu), wbinvd_ipi, NULL, 1, 1);
+                on_selected_cpus(cpumask_of(cpu), wbinvd_ipi, NULL, 1, 1);
         }
 
         vmx_clear_vmcs(v);
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -2163,7 +2163,7 @@ static void ept_handle_violation(unsigne
         {
             paging_mark_dirty(d, mfn_x(mfn));
             p2m_change_type(d, gfn, p2m_ram_logdirty, p2m_ram_rw);
-            flush_tlb_mask(d->domain_dirty_cpumask);
+            flush_tlb_mask(&d->domain_dirty_cpumask);
         }
         return;
     }
xen/arch/x86/irq.c +3 -3
@@ -516,7 +516,7 @@ static void __pirq_guest_eoi(struct doma
     }
 
     if ( !cpus_empty(cpu_eoi_map) )
-        on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 0);
+        on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1, 0);
 }
 
 int pirq_guest_eoi(struct domain *d, int irq)
@@ -755,7 +755,7 @@ static irq_guest_action_t *__pirq_guest_
         {
             cpu_eoi_map = action->cpu_eoi_map;
             spin_unlock_irq(&desc->lock);
-            on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 0);
+            on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1, 0);
             spin_lock_irq(&desc->lock);
         }
         break;
@@ -793,7 +793,7 @@ static irq_guest_action_t *__pirq_guest_
     {
         BUG_ON(action->ack_type != ACKTYPE_EOI);
         spin_unlock_irq(&desc->lock);
-        on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 1);
+        on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 1, 1);
         spin_lock_irq(&desc->lock);
     }
 
xen/arch/x86/machine_kexec.c +2 -4
@@ -91,7 +91,6 @@ static void __machine_reboot_kexec(void 
 void machine_reboot_kexec(xen_kexec_image_t *image)
 {
     int reboot_cpu_id;
-    cpumask_t reboot_cpu;
 
     reboot_cpu_id = 0;
 
@@ -100,9 +99,8 @@ void machine_reboot_kexec(xen_kexec_imag
 
     if ( reboot_cpu_id != smp_processor_id() )
     {
-        cpus_clear(reboot_cpu);
-        cpu_set(reboot_cpu_id, reboot_cpu);
-        on_selected_cpus(reboot_cpu, __machine_reboot_kexec, image, 1, 0);
+        on_selected_cpus(cpumask_of(reboot_cpu_id), __machine_reboot_kexec,
+                         image, 1, 0);
         for (;;)
                 ; /* nothing */
     }
xen/arch/x86/mm.c +11 -11
@@ -510,7 +510,7 @@ static void invalidate_shadow_ldt(struct
 
     /* Rid TLBs of stale mappings (guest mappings and shadow mappings). */
     if ( flush )
-        flush_tlb_mask(v->vcpu_dirty_cpumask);
+        flush_tlb_mask(&v->vcpu_dirty_cpumask);
 
  out:
     spin_unlock(&v->arch.shadow_ldt_lock);
@@ -1235,7 +1235,7 @@ static void pae_flush_pgd(
                 paging_update_cr3(v);
                 cpus_or(m, m, v->vcpu_dirty_cpumask);
             }
-        flush_tlb_mask(m);
+        flush_tlb_mask(&m);
     }
 
     /* If below 4GB then the pgdir is not shadowed in low memory. */
@@ -1260,7 +1260,7 @@ static void pae_flush_pgd(
         spin_unlock(&cache->lock);
     }
 
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
 }
 #else
 # define pae_flush_pgd(mfn, idx, nl3e) ((void)0)
@@ -2275,7 +2275,7 @@ static int __get_page_type(struct page_i
                       ((nx & PGT_type_mask) == PGT_writable_page)) )
                 {
                     perfc_incr(need_flush_tlb_flush);
-                    flush_tlb_mask(mask);
+                    flush_tlb_mask(&mask);
                 }
 
                 /* We lose existing type and validity. */
@@ -2476,7 +2476,7 @@ static void process_deferred_ops(void)
     if ( deferred_ops & (DOP_FLUSH_ALL_TLBS|DOP_FLUSH_TLB) )
     {
         if ( deferred_ops & DOP_FLUSH_ALL_TLBS )
-            flush_tlb_mask(d->domain_dirty_cpumask);
+            flush_tlb_mask(&d->domain_dirty_cpumask);
         else
             flush_tlb_local();
     }
@@ -2811,9 +2811,9 @@ int do_mmuext_op(
             }
             pmask = vcpumask_to_pcpumask(d, vmask);
             if ( op.cmd == MMUEXT_TLB_FLUSH_MULTI )
-                flush_tlb_mask(pmask);
+                flush_tlb_mask(&pmask);
             else
-                flush_tlb_one_mask(pmask, op.arg1.linear_addr);
+                flush_tlb_one_mask(&pmask, op.arg1.linear_addr);
             break;
         }
 
@@ -2822,7 +2822,7 @@ int do_mmuext_op(
             break;
     
         case MMUEXT_INVLPG_ALL:
-            flush_tlb_one_mask(d->domain_dirty_cpumask, op.arg1.linear_addr);
+            flush_tlb_one_mask(&d->domain_dirty_cpumask, op.arg1.linear_addr);
             break;
 
         case MMUEXT_FLUSH_CACHE:
@@ -3639,7 +3639,7 @@ int do_update_va_mapping(unsigned long v
             pmask = vcpumask_to_pcpumask(d, vmask);
             if ( cpu_isset(smp_processor_id(), pmask) )
                 this_cpu(percpu_mm_info).deferred_ops &= ~DOP_FLUSH_TLB;
-            flush_tlb_mask(pmask);
+            flush_tlb_mask(&pmask);
             break;
         }
         break;
@@ -3657,7 +3657,7 @@ int do_update_va_mapping(unsigned long v
                 flush_tlb_one_local(va);
             break;
         case UVMF_ALL:
-            flush_tlb_one_mask(d->domain_dirty_cpumask, va);
+            flush_tlb_one_mask(&d->domain_dirty_cpumask, va);
             break;
         default:
             if ( unlikely(!is_pv_32on64_domain(d) ?
@@ -3667,7 +3667,7 @@ int do_update_va_mapping(unsigned long v
             pmask = vcpumask_to_pcpumask(d, vmask);
             if ( this_cpu(percpu_mm_info).deferred_ops & DOP_FLUSH_TLB )
                 cpu_clear(smp_processor_id(), pmask);
-            flush_tlb_one_mask(pmask, va);
+            flush_tlb_one_mask(&pmask, va);
             break;
         }
         break;
xen/arch/x86/mm/hap/hap.c +3 -3
@@ -64,7 +64,7 @@ int hap_enable_log_dirty(struct domain *
 
     /* set l1e entries of P2M table to be read-only. */
     p2m_change_entry_type_global(d, p2m_ram_rw, p2m_ram_logdirty);
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
     return 0;
 }
 
@@ -83,7 +83,7 @@ void hap_clean_dirty_bitmap(struct domai
 {
     /* set l1e entries of P2M table to be read-only. */
     p2m_change_entry_type_global(d, p2m_ram_rw, p2m_ram_logdirty);
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
 }
 
 /************************************************/
@@ -643,7 +643,7 @@ hap_write_p2m_entry(struct vcpu *v, unsi
     safe_write_pte(p, new);
     if ( (old_flags & _PAGE_PRESENT)
          && (level == 1 || (level == 2 && (old_flags & _PAGE_PSE))) )
-             flush_tlb_mask(v->domain->domain_dirty_cpumask);
+             flush_tlb_mask(&v->domain->domain_dirty_cpumask);
 
 #if CONFIG_PAGING_LEVELS == 3
     /* install P2M in monitor table for PAE Xen */
xen/arch/x86/mm/shadow/common.c +9 -9
@@ -695,7 +695,7 @@ static int oos_remove_write_access(struc
     }
 
     if ( ftlb )
-        flush_tlb_mask(v->domain->domain_dirty_cpumask);
+        flush_tlb_mask(&v->domain->domain_dirty_cpumask);
 
     return 0;
 }
@@ -1145,7 +1145,7 @@ sh_validate_guest_pt_write(struct vcpu *
     rc = sh_validate_guest_entry(v, gmfn, entry, size);
     if ( rc & SHADOW_SET_FLUSH )
         /* Need to flush TLBs to pick up shadow PT changes */
-        flush_tlb_mask(d->domain_dirty_cpumask);
+        flush_tlb_mask(&d->domain_dirty_cpumask);
     if ( rc & SHADOW_SET_ERROR ) 
     {
         /* This page is probably not a pagetable any more: tear it out of the 
@@ -1393,7 +1393,7 @@ static void _shadow_prealloc(
                 /* See if that freed up enough space */
                 if ( space_is_available(d, order, count) )
                 {
-                    flush_tlb_mask(d->domain_dirty_cpumask);
+                    flush_tlb_mask(&d->domain_dirty_cpumask);
                     return;
                 }
             }
@@ -1447,7 +1447,7 @@ static void shadow_blow_tables(struct do
                                pagetable_get_mfn(v->arch.shadow_table[i]));
 
     /* Make sure everyone sees the unshadowings */
-    flush_tlb_mask(d->domain_dirty_cpumask);
+    flush_tlb_mask(&d->domain_dirty_cpumask);
 }
 
 void shadow_blow_tables_per_domain(struct domain *d)
@@ -1554,7 +1554,7 @@ mfn_t shadow_alloc(struct domain *d,  
         if ( unlikely(!cpus_empty(mask)) )
         {
             perfc_incr(shadow_alloc_tlbflush);
-            flush_tlb_mask(mask);
+            flush_tlb_mask(&mask);
         }
         /* Now safe to clear the page for reuse */
         p = sh_map_domain_page(page_to_mfn(sp+i));
@@ -2803,7 +2803,7 @@ void sh_remove_shadows(struct vcpu *v, m
 
     /* Need to flush TLBs now, so that linear maps are safe next time we 
      * take a fault. */
-    flush_tlb_mask(v->domain->domain_dirty_cpumask);
+    flush_tlb_mask(&v->domain->domain_dirty_cpumask);
 
     if ( do_locking ) shadow_unlock(v->domain);
 }
@@ -3435,7 +3435,7 @@ shadow_write_p2m_entry(struct vcpu *v, u
         {
             sh_remove_all_shadows_and_parents(v, mfn);
             if ( sh_remove_all_mappings(v, mfn) )
-                flush_tlb_mask(d->domain_dirty_cpumask);    
+                flush_tlb_mask(&d->domain_dirty_cpumask);
         }
     }
 
@@ -3474,7 +3474,7 @@ shadow_write_p2m_entry(struct vcpu *v, u
                 }
                 omfn = _mfn(mfn_x(omfn) + 1);
             }
-            flush_tlb_mask(flushmask);
+            flush_tlb_mask(&flushmask);
             
             if ( npte )
                 unmap_domain_page(npte);
@@ -3752,7 +3752,7 @@ int shadow_track_dirty_vram(struct domai
         }
     }
     if ( flush_tlb )
-        flush_tlb_mask(d->domain_dirty_cpumask);    
+        flush_tlb_mask(&d->domain_dirty_cpumask);
     goto out;
 
 out_sl1ma:
xen/arch/x86/mm/shadow/multi.c +4 -4
@@ -3146,7 +3146,7 @@ static int sh_page_fault(struct vcpu *v,
          */
         perfc_incr(shadow_rm_write_flush_tlb);
         atomic_inc(&d->arch.paging.shadow.gtable_dirty_version);
-        flush_tlb_mask(d->domain_dirty_cpumask);
+        flush_tlb_mask(&d->domain_dirty_cpumask);
     }
 
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
@@ -4135,7 +4135,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
      * (old) shadow linear maps in the writeable mapping heuristics. */
 #if GUEST_PAGING_LEVELS == 2
     if ( sh_remove_write_access(v, gmfn, 2, 0) != 0 )
-        flush_tlb_mask(v->domain->domain_dirty_cpumask); 
+        flush_tlb_mask(&v->domain->domain_dirty_cpumask);
     sh_set_toplevel_shadow(v, 0, gmfn, SH_type_l2_shadow);
 #elif GUEST_PAGING_LEVELS == 3
     /* PAE guests have four shadow_table entries, based on the 
@@ -4158,7 +4158,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
             }
         }
         if ( flush ) 
-            flush_tlb_mask(v->domain->domain_dirty_cpumask);
+            flush_tlb_mask(&v->domain->domain_dirty_cpumask);
         /* Now install the new shadows. */
         for ( i = 0; i < 4; i++ ) 
         {
@@ -4179,7 +4179,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
     }
 #elif GUEST_PAGING_LEVELS == 4
     if ( sh_remove_write_access(v, gmfn, 4, 0) != 0 )
-        flush_tlb_mask(v->domain->domain_dirty_cpumask);
+        flush_tlb_mask(&v->domain->domain_dirty_cpumask);
     sh_set_toplevel_shadow(v, 0, gmfn, SH_type_l4_shadow);
 #else
 #error This should never happen 
xen/arch/x86/shutdown.c +1 -1
@@ -310,7 +310,7 @@ void machine_restart(unsigned int delay_
     if ( get_apic_id() != boot_cpu_physical_apicid )
     {
         /* Send IPI to the boot CPU (logical cpu 0). */
-        on_selected_cpus(cpumask_of_cpu(0), __machine_restart,
+        on_selected_cpus(cpumask_of(0), __machine_restart,
                          &delay_millisecs, 1, 0);
         for ( ; ; )
             halt();
xen/arch/x86/smp.c +33 -23

145 lines not on this page · raw message

xen/arch/x86/time.c +1 -1
@@ -1189,7 +1189,7 @@ static void time_calibration(void *unuse
     };
 
     /* @wait=1 because we must wait for all cpus before freeing @r. */
-    on_selected_cpus(r.cpu_calibration_map,
+    on_selected_cpus(&r.cpu_calibration_map,
                      opt_consistent_tscs
                      ? time_calibration_tsc_rendezvous
                      : time_calibration_std_rendezvous,
xen/common/Makefile +1 -0
@@ -1,4 +1,5 @@
 obj-y += bitmap.o
+obj-y += cpu.o
 obj-y += domctl.o
 obj-y += domain.o
 obj-y += event_channel.o
xen/common/cpu.c new file +26 -0
@@ -0,0 +1,26 @@
+#include <xen/config.h>
+#include <xen/cpumask.h>
+
+/*
+ * cpu_bit_bitmap[] is a special, "compressed" data structure that
+ * represents all NR_CPUS bits binary values of 1<<nr.
+ *
+ * It is used by cpumask_of() to get a constant address to a CPU
+ * mask value that has a single bit set only.
+ */
+
+/* cpu_bit_bitmap[0] is empty - so we can back into it */
+#define MASK_DECLARE_1(x)	[x+1][0] = 1UL << (x)
+#define MASK_DECLARE_2(x)	MASK_DECLARE_1(x), MASK_DECLARE_1(x+1)
+#define MASK_DECLARE_4(x)	MASK_DECLARE_2(x), MASK_DECLARE_2(x+2)
+#define MASK_DECLARE_8(x)	MASK_DECLARE_4(x), MASK_DECLARE_4(x+4)
+
+const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = {
+
+	MASK_DECLARE_8(0),	MASK_DECLARE_8(8),
+	MASK_DECLARE_8(16),	MASK_DECLARE_8(24),
+#if BITS_PER_LONG > 32
+	MASK_DECLARE_8(32),	MASK_DECLARE_8(40),
+	MASK_DECLARE_8(48),	MASK_DECLARE_8(56),
+#endif
+};
xen/common/grant_table.c +5 -5
@@ -715,7 +715,7 @@ gnttab_unmap_grant_ref(
                 goto fault;
         }
 
-        flush_tlb_mask(current->domain->domain_dirty_cpumask);
+        flush_tlb_mask(&current->domain->domain_dirty_cpumask);
 
         for ( i = 0; i < partial_done; i++ )
             __gnttab_unmap_common_complete(&(common[i]));
@@ -727,7 +727,7 @@ gnttab_unmap_grant_ref(
     return 0;
 
 fault:
-    flush_tlb_mask(current->domain->domain_dirty_cpumask);
+    flush_tlb_mask(&current->domain->domain_dirty_cpumask);
 
     for ( i = 0; i < partial_done; i++ )
         __gnttab_unmap_common_complete(&(common[i]));
@@ -774,7 +774,7 @@ gnttab_unmap_and_replace(
                 goto fault;
         }
         
-        flush_tlb_mask(current->domain->domain_dirty_cpumask);
+        flush_tlb_mask(&current->domain->domain_dirty_cpumask);
         
         for ( i = 0; i < partial_done; i++ )
             __gnttab_unmap_common_complete(&(common[i]));
@@ -786,7 +786,7 @@ gnttab_unmap_and_replace(
     return 0;
 
 fault:
-    flush_tlb_mask(current->domain->domain_dirty_cpumask);
+    flush_tlb_mask(&current->domain->domain_dirty_cpumask);
 
     for ( i = 0; i < partial_done; i++ )
         __gnttab_unmap_common_complete(&(common[i]));
@@ -1123,7 +1123,7 @@ gnttab_transfer(
 #ifndef __ia64__ /* IA64 implicitly replaces the old page in steal_page(). */
         guest_physmap_remove_page(d, gop.mfn, mfn, 0);
 #endif
-        flush_tlb_mask(d->domain_dirty_cpumask);
+        flush_tlb_mask(&d->domain_dirty_cpumask);
 
         /* Find the target domain. */
         if ( unlikely((e = rcu_lock_domain_by_id(gop.domid)) == NULL) )
xen/common/keyhandler.c +1 -1
@@ -119,7 +119,7 @@ static void dump_registers(unsigned char
         if ( cpu == smp_processor_id() )
             continue;
         printk("\n*** Dumping CPU%d host state: ***\n", cpu);
-        on_selected_cpus(cpumask_of_cpu(cpu), __dump_execstate, NULL, 1, 1);
+        on_selected_cpus(cpumask_of(cpu), __dump_execstate, NULL, 1, 1);
     }
 
     printk("\n");
xen/common/page_alloc.c +1 -1
@@ -422,7 +422,7 @@ static struct page_info *alloc_heap_page
     if ( unlikely(!cpus_empty(mask)) )
     {
         perfc_incr(need_flush_tlb_flush);
-        flush_tlb_mask(mask);
+        flush_tlb_mask(&mask);
     }
 
     return pg;
xen/include/asm-ia64/tlbflush.h +1 -1
@@ -39,7 +39,7 @@ void domain_flush_tlb_vhpt(struct domain
 void flush_tlb_for_log_dirty(struct domain *d);
 
 /* Flush v-tlb on cpus set in mask for current domain.  */
-void flush_tlb_mask(cpumask_t mask);
+void flush_tlb_mask(const cpumask_t *mask);
 
 /* Flush local machine TLB.  */
 void local_flush_tlb_all (void);
xen/include/asm-x86/flushtlb.h +5 -5
@@ -90,12 +90,12 @@ void flush_area_local(const void *va, un
 #define flush_local(flags) flush_area_local(NULL, flags)
 
 /* Flush specified CPUs' TLBs/caches */
-void flush_area_mask(cpumask_t, const void *va, unsigned int flags);
+void flush_area_mask(const cpumask_t *, const void *va, unsigned int flags);
 #define flush_mask(mask, flags) flush_area_mask(mask, NULL, flags)
 
 /* Flush all CPUs' TLBs/caches */
-#define flush_area_all(va, flags) flush_area_mask(cpu_online_map, va, flags)
-#define flush_all(flags) flush_mask(cpu_online_map, flags)
+#define flush_area_all(va, flags) flush_area_mask(&cpu_online_map, va, flags)
+#define flush_all(flags) flush_mask(&cpu_online_map, flags)
 
 /* Flush local TLBs */
 #define flush_tlb_local()                       \
@@ -111,8 +111,8 @@ void flush_area_mask(cpumask_t, const vo
 
 /* Flush all CPUs' TLBs */
 #define flush_tlb_all()                         \
-    flush_tlb_mask(cpu_online_map)
+    flush_tlb_mask(&cpu_online_map)
 #define flush_tlb_one_all(v)                    \
-    flush_tlb_one_mask(cpu_online_map, v)
+    flush_tlb_one_mask(&cpu_online_map, v)
 
 #endif /* __FLUSHTLB_H__ */
xen/include/asm-x86/genapic.h +4 -4
@@ -35,7 +35,7 @@ struct genapic { 
 	void (*clustered_apic_check)(void);
 	cpumask_t (*target_cpus)(void);
 	unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
-	void (*send_IPI_mask)(cpumask_t mask, int vector);
+	void (*send_IPI_mask)(const cpumask_t *mask, int vector);
 };
 
 #define APICFUNC(x) .x = x
@@ -52,7 +52,7 @@ void init_apic_ldr_flat(void);
 void clustered_apic_check_flat(void);
 cpumask_t target_cpus_flat(void);
 unsigned int cpu_mask_to_apicid_flat(cpumask_t cpumask);
-void send_IPI_mask_flat(cpumask_t mask, int vector);
+void send_IPI_mask_flat(const cpumask_t *mask, int vector);
 #define GENAPIC_FLAT \
 	.int_delivery_mode = dest_LowestPrio, \
 	.int_dest_mode = 1 /* logical delivery */, \
@@ -66,7 +66,7 @@ void init_apic_ldr_x2apic(void);
 void clustered_apic_check_x2apic(void);
 cpumask_t target_cpus_x2apic(void);
 unsigned int cpu_mask_to_apicid_x2apic(cpumask_t cpumask);
-void send_IPI_mask_x2apic(cpumask_t mask, int vector);
+void send_IPI_mask_x2apic(const cpumask_t *mask, int vector);
 #define GENAPIC_X2APIC \
 	.int_delivery_mode = dest_Fixed, \
 	.int_dest_mode = 0 /* physical delivery */, \
@@ -80,7 +80,7 @@ void init_apic_ldr_phys(void);
 void clustered_apic_check_phys(void);
 cpumask_t target_cpus_phys(void);
 unsigned int cpu_mask_to_apicid_phys(cpumask_t cpumask);
-void send_IPI_mask_phys(cpumask_t mask, int vector);
+void send_IPI_mask_phys(const cpumask_t *mask, int vector);
 #define GENAPIC_PHYS \
 	.int_delivery_mode = dest_Fixed, \
 	.int_dest_mode = 0 /* physical delivery */, \
xen/include/xen/cpumask.h +17 -12
@@ -80,7 +80,6 @@
 #include <xen/kernel.h>
 
 typedef struct { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
-extern cpumask_t _unused_cpumask_arg_;
 
 #define cpu_set(cpu, dst) __cpu_set((cpu), &(dst))
 static inline void __cpu_set(int cpu, volatile cpumask_t *dstp)
@@ -244,17 +243,23 @@ static inline int __cycle_cpu(int n, con
     return nxt;
 }
 
-#define cpumask_of_cpu(cpu)						\
-({									\
-	typeof(_unused_cpumask_arg_) m;					\
-	if (sizeof(m) == sizeof(unsigned long)) {			\
-		m.bits[0] = 1UL<<(cpu);					\
-	} else {							\
-		cpus_clear(m);						\
-		cpu_set((cpu), m);					\
-	}								\
-	m;								\
-})
+/*
+ * Special-case data structure for "single bit set only" constant CPU masks.
+ *
+ * We pre-generate all the 64 (or 32) possible bit positions, with enough
+ * padding to the left and the right, and return the constant pointer
+ * appropriately offset.
+ */
+extern const unsigned long
+	cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];
+
+static inline const cpumask_t *cpumask_of(unsigned int cpu)
+{
+	const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
+	return (const cpumask_t *)(p - cpu / BITS_PER_LONG);
+}
+
+#define cpumask_of_cpu(cpu) (*cpumask_of(cpu))
 
 #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
 
xen/include/xen/smp.h +4 -4
@@ -9,9 +9,9 @@
  */
 extern void smp_send_stop(void);
 
-extern void smp_send_event_check_mask(cpumask_t mask);
+extern void smp_send_event_check_mask(const cpumask_t *mask);
 #define smp_send_event_check_cpu(cpu) \
-    smp_send_event_check_mask(cpumask_of_cpu(cpu))
+    smp_send_event_check_mask(cpumask_of(cpu))
 
 /*
  * Prepare machine for booting other CPUs.
@@ -41,7 +41,7 @@ extern int smp_call_function(
  * Call a function on a selection of processors
  */
 extern int on_selected_cpus(
-    cpumask_t selected,
+    const cpumask_t *selected,
     void (*func) (void *info),
     void *info,
     int retry,
@@ -62,7 +62,7 @@ static inline int on_each_cpu(
     int retry,
     int wait)
 {
-    return on_selected_cpus(cpu_online_map, func, info, retry, wait);
+    return on_selected_cpus(&cpu_online_map, func, info, retry, wait);
 }
 
 #define smp_processor_id() raw_smp_processor_id()
xen/include/xen/softirq.h +1 -1
@@ -39,7 +39,7 @@ static inline void cpumask_raise_softirq
             cpu_clear(cpu, mask);
     }
 
-    smp_send_event_check_mask(mask);
+    smp_send_event_check_mask(&mask);
 }
 
 static inline void cpu_raise_softirq(unsigned int cpu, unsigned int nr)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel