[ovs-dev] [PATCH v3 03/12] flow: Skip invoking expensive count_1bits() with zero input.

Bhanuprakash Bodireddy bhanuprakash.bodireddy at intel.com
Fri Oct 14 14:37:06 UTC 2016


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 at intel.com>
Co-authored-by: Antonio Fischetti <antonio.fischetti at intel.com>
Signed-off-by: Antonio Fischetti <antonio.fischetti at intel.com>
Acked-by: Jarno Rajahalme <jarno at ovn.org>
---
 lib/flow.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/flow.h b/lib/flow.h
index 5a14941..74e75d6 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -614,11 +614,16 @@ mf_get_next_in_map(struct mf_for_each_in_map_aux *aux,
          * to ‘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;
+            /* 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' only.
+             */
+            aux->values += count_1bits(trash);
+        }
 
         *value = *aux->values;
     } else {
-- 
2.4.11




More information about the dev mailing list