ia64/xen-unstable

changeset 18544:50170dc8649c

x2apic: Clean up send_IPI_mask_x2apic() and add a memory barrier.

The barrier is required to prevent the WRMSR from executing before the
processor has written synchronising data to be received by remote
CPUs.

At the same time remove needless wmb() from on_selected_cpus(). We now
assume send_IPI_mask() is a sufficient compiler and CPU memory
barrier.

Original patch by Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Sep 25 10:03:04 2008 +0100 (2008-09-25)
parents b53b02976633
children d4a093819310
files xen/arch/x86/genapic/x2apic.c xen/arch/x86/smp.c
line diff
     1.1 --- a/xen/arch/x86/genapic/x2apic.c	Wed Sep 24 12:47:33 2008 +0100
     1.2 +++ b/xen/arch/x86/genapic/x2apic.c	Thu Sep 25 10:03:04 2008 +0100
     1.3 @@ -58,21 +58,26 @@ unsigned int cpu_mask_to_apicid_x2apic(c
     1.4  
     1.5  void send_IPI_mask_x2apic(cpumask_t cpumask, int vector)
     1.6  {
     1.7 -    unsigned int query_cpu;
     1.8 -    u32 cfg, dest;
     1.9 +    unsigned int cpu, cfg;
    1.10      unsigned long flags;
    1.11  
    1.12 -    ASSERT(cpus_subset(cpumask, cpu_online_map));
    1.13 -    ASSERT(!cpus_empty(cpumask));
    1.14 +    /*
    1.15 +     * Ensure that any synchronisation data written in program order by this
    1.16 +     * CPU is seen by notified remote CPUs. The WRMSR contained within
    1.17 +     * apic_icr_write() can otherwise be executed early.
    1.18 +     * 
    1.19 +     * The reason mb() is sufficient here is subtle: the register arguments
    1.20 +     * to WRMSR must depend on a memory read executed after the barrier. This
    1.21 +     * is guaranteed by cpu_physical_id(), which reads from a global array (and
    1.22 +     * so cannot be hoisted above the barrier even by a clever compiler).
    1.23 +     */
    1.24 +    mb();
    1.25  
    1.26      local_irq_save(flags);
    1.27  
    1.28      cfg = APIC_DM_FIXED | 0 /* no shorthand */ | APIC_DEST_PHYSICAL | vector;
    1.29 -    for_each_cpu_mask(query_cpu, cpumask)
    1.30 -    {
    1.31 -        dest =  cpu_physical_id(query_cpu);
    1.32 -        apic_icr_write(cfg, dest);
    1.33 -    }
    1.34 +    for_each_cpu_mask ( cpu, cpumask )
    1.35 +        apic_wrmsr(APIC_ICR, cfg, cpu_physical_id(cpu));
    1.36  
    1.37      local_irq_restore(flags);
    1.38  }
     2.1 --- a/xen/arch/x86/smp.c	Wed Sep 24 12:47:33 2008 +0100
     2.2 +++ b/xen/arch/x86/smp.c	Thu Sep 25 10:03:04 2008 +0100
     2.3 @@ -280,7 +280,6 @@ int on_selected_cpus(
     2.4      spin_lock(&call_lock);
     2.5  
     2.6      call_data = &data;
     2.7 -    wmb();
     2.8  
     2.9      send_IPI_mask(selected, CALL_FUNCTION_VECTOR);
    2.10