[ovs-dev] [PATCH 11/18] lib/dpif-linux: Use relaxed atomics for 'dump->status'.

Jarno Rajahalme jrajahalme at nicira.com
Fri Aug 22 20:58:22 UTC 2014


'dump->status' does not syncronize the state of any other variable, so
we can use relaxed atomics on it.

Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
 lib/dpif-linux.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index e5067ba..2c387ed 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -1150,7 +1150,8 @@ dpif_linux_flow_dump_destroy(struct dpif_flow_dump *dump_)
     unsigned int nl_status = nl_dump_done(&dump->nl_dump);
     int dump_status;
 
-    atomic_read(&dump->status, &dump_status);
+    /* No other thread has access to 'dump' at this point. */
+    atomic_read_relaxed(&dump->status, &dump_status);
     free(dump);
     return dump_status ? dump_status : nl_status;
 }
@@ -1237,7 +1238,7 @@ dpif_linux_flow_dump_next(struct dpif_flow_dump_thread *thread_,
         /* Convert the flow to our output format. */
         error = dpif_linux_flow_from_ofpbuf(&linux_flow, &nl_flow);
         if (error) {
-            atomic_store(&dump->status, error);
+            atomic_store_relaxed(&dump->status, error);
             break;
         }
 
@@ -1256,7 +1257,7 @@ dpif_linux_flow_dump_next(struct dpif_flow_dump_thread *thread_,
             } else if (error) {
                 VLOG_WARN("error fetching dumped flow: %s",
                           ovs_strerror(error));
-                atomic_store(&dump->status, error);
+                atomic_store_relaxed(&dump->status, error);
                 break;
             }
 
-- 
1.7.10.4




More information about the dev mailing list