]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ofproto-dpif-upcall: Only call ovsrcu_postpone() on active actions
authorEelco Chaudron <echaudro@redhat.com>
Thu, 19 Apr 2018 11:24:06 +0000 (13:24 +0200)
committerBen Pfaff <blp@ovn.org>
Thu, 19 Apr 2018 16:29:22 +0000 (09:29 -0700)
Currently, ovsrcu_postpone() is called even with a NULL argument,
i.e. when there is no data to be freed. This is causing additional
overhead because work is scheduled for the urcu thread. This change
avoids adding the postpone callback if no work needs to be done.

This especially helps for the OVS-DPDK case where the PMD threads
might no longer have to do a write() due to the latch_set(), and thus
saving a syscall.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
ofproto/ofproto-dpif-upcall.c

index 00160e1eec119b582ab7e0fe82a231004c8633a6..d26f201f46292259ad326e5e827fff9ee81bd06f 100644 (file)
@@ -1621,8 +1621,13 @@ ukey_get_actions(struct udpif_key *ukey, const struct nlattr **actions, size_t *
 static void
 ukey_set_actions(struct udpif_key *ukey, const struct ofpbuf *actions)
 {
-    ovsrcu_postpone(ofpbuf_delete,
-                    ovsrcu_get_protected(struct ofpbuf *, &ukey->actions));
+    struct ofpbuf *old_actions = ovsrcu_get_protected(struct ofpbuf *,
+                                                      &ukey->actions);
+
+    if (old_actions) {
+        ovsrcu_postpone(ofpbuf_delete, old_actions);
+    }
+
     ovsrcu_set(&ukey->actions, ofpbuf_clone(actions));
 }