diff mbox

[ovs-dev,v4,1/4] flow: Skip invoking expensive count_1bits() with zero input.

Message ID 1476808304-111016-1-git-send-email-bhanuprakash.bodireddy@intel.com
State Accepted
Delegated to: Daniele Di Proietto
Headers show

Commit Message

Bodireddy, Bhanuprakash Oct. 18, 2016, 4:31 p.m. UTC
This patch checks if trash is non-zero and only then resets the flowmap
bit and increment the pointer by set bits as found in trash.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Co-authored-by: Antonio Fischetti <antonio.fischetti@intel.com>
Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
---
 lib/flow.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/lib/flow.h b/lib/flow.h
index ea24e28..15b50b1 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -592,11 +592,12 @@  mf_get_next_in_map(struct mf_for_each_in_map_aux *aux,
     if (OVS_LIKELY(*fmap & rm1bit)) {
         map_t trash = *fmap & (rm1bit - 1);
 
-        *fmap -= trash;
-        /* count_1bits() is fast for systems where speed matters (e.g.,
-         * DPDK), so we don't try avoid using it.
-         * Advance 'aux->values' to point to the value for 'rm1bit'. */
-        aux->values += count_1bits(trash);
+        /* Avoid resetting 'fmap' and calling count_1bits() when trash is
+         * zero. */
+        if (trash) {
+            *fmap -= trash;
+            aux->values += count_1bits(trash);
+        }
 
         *value = *aux->values;
     } else {