diff mbox

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

Message ID 1475857062-55311-4-git-send-email-bhanuprakash.bodireddy@intel.com
State Changes Requested
Delegated to: Daniele Di Proietto
Headers show

Commit Message

Bodireddy, Bhanuprakash Oct. 7, 2016, 4:17 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>
Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
---
 lib/flow.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Jarno Rajahalme Oct. 7, 2016, 9:08 p.m. UTC | #1
With the nit below,

Acked-by: Jarno Rajahalme <jarno@ovn.org>

> On Oct 7, 2016, at 9:17 AM, Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> wrote:
> 
> 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>
> Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
> ---
> lib/flow.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/flow.h b/lib/flow.h
> index 4eb19ae..8cfd243 100644
> --- a/lib/flow.h
> +++ b/lib/flow.h
> @@ -609,11 +609,13 @@ mf_get_next_in_map(struct mf_for_each_in_map_aux *aux,
>          * corresponding data chunks should be skipped accordingly. */
>         map_t trash = *fmap & (rm1bit - 1);
> 
> -        *fmap -= trash;
> +        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'. */

You should update the comment, as we now avoid calling count_1bits().

> -        aux->values += count_1bits(trash);
> +            aux->values += count_1bits(trash);
> +        }
> 
>         *value = *aux->values;
>     } else {
> -- 
> 2.4.11
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
diff mbox

Patch

diff --git a/lib/flow.h b/lib/flow.h
index 4eb19ae..8cfd243 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -609,11 +609,13 @@  mf_get_next_in_map(struct mf_for_each_in_map_aux *aux,
          * corresponding data chunks should be skipped accordingly. */
         map_t trash = *fmap & (rm1bit - 1);
 
-        *fmap -= trash;
+        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'. */
-        aux->values += count_1bits(trash);
+            aux->values += count_1bits(trash);
+        }
 
         *value = *aux->values;
     } else {