[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xenbus: Clarify and simplify barrier usage.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1174041745 0
# Node ID 422a61ebac541a40d60eee66e5ddf87d4855201e
# Parent  26a1378d5eced58122ca0f499c23b6697d94e4aa
xenbus: Clarify and simplify barrier usage.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff -r 26a1378d5ece -r 422a61ebac54 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c    Fri Mar 16 
10:24:56 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c    Fri Mar 16 
10:42:25 2007 +0000
@@ -110,7 +110,6 @@ int xb_write(const void *data, unsigned 
                /* Read indexes, then verify. */
                cons = intf->req_cons;
                prod = intf->req_prod;
-               mb();
                if (!check_indexes(cons, prod)) {
                        intf->req_cons = intf->req_prod = 0;
                        return -EIO;
@@ -122,15 +121,18 @@ int xb_write(const void *data, unsigned 
                if (avail > len)
                        avail = len;
 
+               /* Must write data /after/ reading the consumer index. */
+               mb();
+
                memcpy(dst, data, avail);
                data += avail;
                len -= avail;
 
-               /* Other side must not see new header until data is there. */
+               /* Other side must not see new producer until data is there. */
                wmb();
                intf->req_prod += avail;
 
-               /* This implies mb() before other side sees interrupt. */
+               /* Implies mb(): other side will see the updated producer. */
                notify_remote_via_evtchn(xen_store_evtchn);
        }
 
@@ -165,7 +167,6 @@ int xb_read(void *data, unsigned len)
                /* Read indexes, then verify. */
                cons = intf->rsp_cons;
                prod = intf->rsp_prod;
-               mb();
                if (!check_indexes(cons, prod)) {
                        intf->rsp_cons = intf->rsp_prod = 0;
                        return -EIO;
@@ -177,7 +178,7 @@ int xb_read(void *data, unsigned len)
                if (avail > len)
                        avail = len;
 
-               /* We must read header before we read data. */
+               /* Must read data /after/ reading the producer index. */
                rmb();
 
                memcpy(data, src, avail);
@@ -190,7 +191,7 @@ int xb_read(void *data, unsigned len)
 
                pr_debug("Finished read of %i bytes (%i to go)\n", avail, len);
 
-               /* Implies mb(): they will see new header. */
+               /* Implies mb(): other side will see the updated consumer. */
                notify_remote_via_evtchn(xen_store_evtchn);
        }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.