diff mbox

[ovs-dev,v4,1/2] odp-execute : Apply clone action on batch of packets instead of one by one.

Message ID 1486654914-26397-2-git-send-email-sugesh.chandran@intel.com
State Accepted
Headers show

Commit Message

Chandran, Sugesh Feb. 9, 2017, 3:41 p.m. UTC
Clone action is optimized by cloning a batch of packets together instead of
executing independently on every packet in a batch.

Rebased onto commit: edb417cc256e7d5f02f230867865c8cf7f26e542
                     ovs-ofctl: fix memory leak reported by valgrind.

Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Signed-off-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
---
 lib/odp-execute.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Ben Pfaff March 8, 2017, 1:05 a.m. UTC | #1
On Thu, Feb 09, 2017 at 03:41:53PM +0000, Sugesh Chandran wrote:
> Clone action is optimized by cloning a batch of packets together instead of
> executing independently on every packet in a batch.
> 
> Rebased onto commit: edb417cc256e7d5f02f230867865c8cf7f26e542
>                      ovs-ofctl: fix memory leak reported by valgrind.
> 
> Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
> Signed-off-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
> Co-authored-by: Zoltán Balogh <zoltan.balogh@ericsson.com>

I applied this to master.  Thank you!x
diff mbox

Patch

diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 1f6812a..9cb85c1 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -537,23 +537,26 @@  odp_execute_sample(void *dp, struct dp_packet *packet, bool steal,
 }
 
 static void
-odp_execute_clone(void *dp, struct dp_packet *packet, bool steal,
+odp_execute_clone(void *dp, struct dp_packet_batch *batch, bool steal,
                    const struct nlattr *actions,
                    odp_execute_cb dp_execute_action)
 {
-    struct dp_packet_batch pb;
-
     if (!steal) {
         /* The 'actions' may modify the packet, but the modification
          * should not propagate beyond this clone action. Make a copy
          * the packet in case we don't own the packet, so that the
          * 'actions' are only applied to the clone.  'odp_execute_actions'
          * will free the clone.  */
-        packet = dp_packet_clone(packet);
-    }
-    dp_packet_batch_init_packet(&pb, packet);
-    odp_execute_actions(dp, &pb, true, nl_attr_get(actions),
+        struct dp_packet_batch clone_pkt_batch;
+        dp_packet_batch_clone(&clone_pkt_batch, batch);
+        dp_packet_batch_reset_cutlen(batch);
+        odp_execute_actions(dp, &clone_pkt_batch, true, nl_attr_get(actions),
                         nl_attr_get_size(actions), dp_execute_action);
+    }
+    else {
+        odp_execute_actions(dp, batch, true, nl_attr_get(actions),
+                            nl_attr_get_size(actions), dp_execute_action);
+    }
 }
 
 static bool
@@ -712,11 +715,8 @@  odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
         }
 
         case OVS_ACTION_ATTR_CLONE:
-            DP_PACKET_BATCH_FOR_EACH (packet, batch) {
-                odp_execute_clone(dp, packet, steal && last_action, a,
-                                  dp_execute_action);
-            }
-
+            odp_execute_clone(dp, batch, steal && last_action, a,
+                                                dp_execute_action);
             if (last_action) {
                 /* We do not need to free the packets. odp_execute_clone() has
                  * stolen them.  */