]> xenbits.xensource.com Git - xen.git/commitdiff
use SMP barrier in common code dealing with shared memory protocols
authorIan Campbell <ian.campbell@citrix.com>
Thu, 4 Jul 2013 08:32:44 +0000 (10:32 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 4 Jul 2013 08:32:44 +0000 (10:32 +0200)
Xen currently makes no strong distinction between the SMP barriers (smp_mb
etc) and the regular barrier (mb etc). In Linux, where we inherited these
names from having imported Linux code which uses them, the SMP barriers are
intended to be sufficient for implementing shared-memory protocols between
processors in an SMP system while the standard barriers are useful for MMIO
etc.

On x86 with the stronger ordering model there is not much practical difference
here but ARM has weaker barriers available which are suitable for use as SMP
barriers.

Therefore ensure that common code uses the SMP barriers when that is all which
is required.

On both ARM and x86 both types of barrier are currently identical so there is
no actual change. A future patch will change smp_mb to a weaker barrier on
ARM.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
xen/common/domain.c
xen/common/domctl.c
xen/common/grant_table.c
xen/common/page_alloc.c
xen/common/smp.c
xen/common/spinlock.c
xen/common/tmem_xen.c
xen/common/trace.c
xen/drivers/char/console.c
xen/include/xen/event.h
xen/xsm/flask/ss/sidtab.c

index 5b041726287bfbf1247498d694e93c6c8e658741..6c264a5a025087ff6e49aa0e7a06d9693caa343f 100644 (file)
@@ -932,7 +932,7 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset)
     v->vcpu_info_mfn = page_to_mfn(page);
 
     /* Set new vcpu_info pointer /before/ setting pending flags. */
-    wmb();
+    smp_wmb();
 
     /*
      * Mark everything as being pending just to make sure nothing gets
index 9bd8f8068d5d321f06e433a0669d6c5fe6e1a50d..c653efb74b67ac17cd8e8b6a70557aab607867ae 100644 (file)
@@ -533,7 +533,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
 
             /* Install vcpu array /then/ update max_vcpus. */
             d->vcpu = vcpus;
-            wmb();
+            smp_wmb();
             d->max_vcpus = max;
         }
 
index 3f9732853a1f3ee826a17503e1f95a7b4f8a24c0..eb50288c4fd08e443b1ec23853d1d7ad0ce47cbb 100644 (file)
@@ -426,7 +426,7 @@ static int _set_status_v2(domid_t  domid,
 
     /* Make sure guest sees status update before checking if flags are
        still valid */
-    mb();
+    smp_mb();
 
     scombo.word = *(u32 *)shah;
     barrier();
@@ -1670,7 +1670,7 @@ gnttab_transfer(
             guest_physmap_add_page(e, sha->full_page.frame, mfn, 0);
             sha->full_page.frame = mfn;
         }
-        wmb();
+        smp_wmb();
         shared_entry_header(e->grant_table, gop.ref)->flags |=
             GTF_transfer_completed;
 
index 2162ef14d41b737dfdcbecaa0b3b806487acee3d..25a7d3daaf1ed20636729cf3e39ecb16adff2928 100644 (file)
@@ -1472,7 +1472,7 @@ int assign_pages(
         ASSERT(page_get_owner(&pg[i]) == NULL);
         ASSERT((pg[i].count_info & ~(PGC_allocated | 1)) == 0);
         page_set_owner(&pg[i], d);
-        wmb(); /* Domain pointer must be visible before updating refcnt. */
+        smp_wmb(); /* Domain pointer must be visible before updating refcnt. */
         pg[i].count_info = PGC_allocated | 1;
         page_list_add_tail(&pg[i], &d->page_list);
     }
index b2b056b5e5480bb82c2a40e9a0c873f49d606962..482a203b02ee6e8f2557f9954b83e53af3406e7d 100644 (file)
@@ -89,12 +89,12 @@ void smp_call_function_interrupt(void)
     if ( call_data.wait )
     {
         (*func)(info);
-        mb();
+        smp_mb();
         cpumask_clear_cpu(cpu, &call_data.selected);
     }
     else
     {
-        mb();
+        smp_mb();
         cpumask_clear_cpu(cpu, &call_data.selected);
         (*func)(info);
     }
index bfb96707cad2f2180d64c3b354b2fd2b89ef831a..575cc6db2e2249f8d5102c1d621fc412b4038937 100644 (file)
@@ -218,7 +218,7 @@ void _spin_barrier(spinlock_t *lock)
     u64      loop = 0;
 
     check_barrier(&lock->debug);
-    do { mb(); loop++;} while ( _raw_spin_is_locked(&lock->raw) );
+    do { smp_mb(); loop++;} while ( _raw_spin_is_locked(&lock->raw) );
     if ((loop > 1) && lock->profile)
     {
         lock->profile->time_block += NOW() - block;
@@ -226,9 +226,9 @@ void _spin_barrier(spinlock_t *lock)
     }
 #else
     check_barrier(&lock->debug);
-    do { mb(); } while ( _raw_spin_is_locked(&lock->raw) );
+    do { smp_mb(); } while ( _raw_spin_is_locked(&lock->raw) );
 #endif
-    mb();
+    smp_mb();
 }
 
 int _spin_trylock_recursive(spinlock_t *lock)
index 736a8c30fab211cb618741d7d3225a94adc01479..54ec09f9df0a3a414fbedbea0dd7ed4988931485 100644 (file)
@@ -173,7 +173,7 @@ EXPORT int tmh_copy_from_client(pfp_t *pfp,
             return -EFAULT;
         }
     }
-    mb();
+    smp_mb();
     if ( len == PAGE_SIZE && !tmem_offset && !pfn_offset && cli_va )
         tmh_copy_page(tmem_va, cli_va);
     else if ( (tmem_offset+len <= PAGE_SIZE) &&
@@ -216,7 +216,7 @@ EXPORT int tmh_compress_from_client(tmem_cli_mfn_t cmfn,
         return 0;
     else if ( copy_from_guest(scratch, clibuf, PAGE_SIZE) )
         return -EFAULT;
-    mb();
+    smp_mb();
     ret = lzo1x_1_compress(cli_va ?: scratch, PAGE_SIZE, dmem, out_len, wmem);
     ASSERT(ret == LZO_E_OK);
     *out_va = dmem;
@@ -260,7 +260,7 @@ EXPORT int tmh_copy_to_client(tmem_cli_mfn_t cmfn, pfp_t *pfp,
     unmap_domain_page(tmem_va);
     if ( cli_va )
         cli_put_page(cli_va, cli_pfp, cli_mfn, 1);
-    mb();
+    smp_mb();
     return rc;
 }
 
@@ -289,7 +289,7 @@ EXPORT int tmh_decompress_to_client(tmem_cli_mfn_t cmfn, void *tmem_va,
         cli_put_page(cli_va, cli_pfp, cli_mfn, 1);
     else if ( copy_to_guest(clibuf, scratch, PAGE_SIZE) )
         return -EFAULT;
-    mb();
+    smp_mb();
     return 1;
 }
 
@@ -311,7 +311,7 @@ EXPORT int tmh_copy_tze_to_client(tmem_cli_mfn_t cmfn, void *tmem_va,
     if ( len < PAGE_SIZE )
         memset((char *)cli_va+len,0,PAGE_SIZE-len);
     cli_put_page(cli_va, cli_pfp, cli_mfn, 1);
-    mb();
+    smp_mb();
     return 1;
 }
 
index fd4ac489ee99f9b6ebc4fdac1e0cf558d21b9edc..63ea0b7ba042a3edd8a0b69994f9de94c82d462d 100644 (file)
@@ -255,7 +255,7 @@ static int alloc_trace_bufs(unsigned int pages)
     opt_tbuf_size = pages;
 
     printk("xentrace: initialised\n");
-    wmb(); /* above must be visible before tb_init_done flag set */
+    smp_wmb(); /* above must be visible before tb_init_done flag set */
     tb_init_done = 1;
 
     return 0;
@@ -414,7 +414,7 @@ int tb_control(xen_sysctl_tbuf_op_t *tbc)
         int i;
 
         tb_init_done = 0;
-        wmb();
+        smp_wmb();
         /* Clear any lost-record info so we don't get phantom lost records next time we
          * start tracing.  Grab the lock to make sure we're not racing anyone.  After this
          * hypercall returns, no more records should be placed into the buffers. */
@@ -607,7 +607,7 @@ static inline void __insert_record(struct t_buf *buf,
         memcpy(next_page, (char *)rec + remaining, rec_size - remaining);
     }
 
-    wmb();
+    smp_wmb();
 
     next += rec_size;
     if ( next >= 2*data_size )
@@ -718,7 +718,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,
         return;
 
     /* Read tb_init_done /before/ t_bufs. */
-    rmb();
+    smp_rmb();
 
     spin_lock_irqsave(&this_cpu(t_lock), flags);
 
index 7cd7bf66452e3368cba73d2b4d2014aa36ba6d61..b696b3e54da9b9c6ff8d03de99a3a1da6d0663ee 100644 (file)
@@ -648,7 +648,7 @@ void __init console_init_postirq(void)
     for ( i = conringc ; i != conringp; i++ )
         ring[i & (opt_conring_size - 1)] = conring[i & (conring_size - 1)];
     conring = ring;
-    wmb(); /* Allow users of console_force_unlock() to see larger buffer. */
+    smp_wmb(); /* Allow users of console_force_unlock() to see larger buffer. */
     conring_size = opt_conring_size;
     spin_unlock_irq(&console_lock);
 
index 4ac39ad5eedd97734b263ea1a48fdbba47e89ef0..6f6016285d633a9639c459af44175e040ac2af0a 100644 (file)
@@ -85,7 +85,7 @@ void notify_via_xen_event_channel(struct domain *ld, int lport);
         if ( condition )                                                \
             break;                                                      \
         set_bit(_VPF_blocked_in_xen, &current->pause_flags);            \
-        mb(); /* set blocked status /then/ re-evaluate condition */     \
+        smp_mb(); /* set blocked status /then/ re-evaluate condition */ \
         if ( condition )                                                \
         {                                                               \
             clear_bit(_VPF_blocked_in_xen, &current->pause_flags);      \
@@ -99,7 +99,7 @@ void notify_via_xen_event_channel(struct domain *ld, int lport);
     do {                                                                \
         set_bit(_VPF_blocked_in_xen, &current->pause_flags);            \
         raise_softirq(SCHEDULE_SOFTIRQ);                                \
-        mb(); /* set blocked status /then/ caller does his work */      \
+        smp_mb(); /* set blocked status /then/ caller does his work */  \
     } while ( 0 )
 
 #endif /* __XEN_EVENT_H__ */
index 586033cfe1f2c08d8fcee85d2958980e46e114ae..cd1360cb4a08ebd87f7446a79abc4232a65088e7 100644 (file)
@@ -79,13 +79,13 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context)
     if ( prev )
     {
         newnode->next = prev->next;
-        wmb();
+        smp_wmb();
         prev->next = newnode;
     }
     else
     {
         newnode->next = s->htable[hvalue];
-        wmb();
+        smp_wmb();
         s->htable[hvalue] = newnode;
     }