recirculation: RCU postpone the free of dpif_backer_recirc_node.
authorAlex Wang <alexw@nicira.com>
Tue, 23 Dec 2014 18:20:50 +0000 (10:20 -0800)
committerAlex Wang <alexw@nicira.com>
Tue, 23 Dec 2014 18:51:04 +0000 (10:51 -0800)
This commit RCU postpones the free of 'struct dpif_backer_recirc_node',
after it is removed from the cmap.  This is in that other threads may
be accessing the struct at the same time.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
ofproto/ofproto-dpif.c

index 2166e91..cdd302a 100644 (file)
@@ -59,6 +59,7 @@
 #include "ofproto-dpif-upcall.h"
 #include "ofproto-dpif-xlate.h"
 #include "poll-loop.h"
+#include "ovs-rcu.h"
 #include "ovs-router.h"
 #include "seq.h"
 #include "simap.h"
@@ -868,7 +869,7 @@ dpif_backer_recirc_clear_ofproto(struct dpif_backer *backer,
                      "is destructed", node->recirc_id, ofproto->up.name);
             cmap_remove(&backer->recirc_map, &node->cmap_node,
                         node->recirc_id);
-            free(node);
+            ovsrcu_postpone(free, node);
         }
     }
     ovs_mutex_unlock(&backer->recirc_mutex);
@@ -5457,7 +5458,9 @@ ofproto_dpif_free_recirc_id(struct ofproto_dpif *ofproto, uint32_t recirc_id)
         cmap_remove(&backer->recirc_map, &node->cmap_node, node->recirc_id);
         ovs_mutex_unlock(&backer->recirc_mutex);
         recirc_id_free(backer->rid_pool, node->recirc_id);
-        free(node);
+        /* RCU postpone the free, since other threads may be referring
+         * to 'node' at same time. */
+        ovsrcu_postpone(free, node);
     }
 }