[ovs-dev,PATCHv2,3/6] lib: Introduce ovs_u128_is_zero().
diff mbox

Message ID 1442531068-41423-4-git-send-email-joestringer@nicira.com
State Awaiting Upstream
Headers show

Commit Message

Joe Stringer Sept. 17, 2015, 11:04 p.m. UTC
From: Daniele Di Proietto <diproiettod@vmware.com>

is_all_zeros() is quite slow for u128 initialization because:
- It is not inlined
- It checks byte by byte

This commit introduces a new function to perform this function, which
improves performance in the DPDK packet processing path for upcoming
commits that regularly check u128 values.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
---
 lib/util.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Ben Pfaff Sept. 18, 2015, 5:01 p.m. UTC | #1
On Thu, Sep 17, 2015 at 04:04:25PM -0700, Joe Stringer wrote:
> From: Daniele Di Proietto <diproiettod@vmware.com>
> 
> is_all_zeros() is quite slow for u128 initialization because:
> - It is not inlined
> - It checks byte by byte
> 
> This commit introduces a new function to perform this function, which
> improves performance in the DPDK packet processing path for upcoming
> commits that regularly check u128 values.
> 
> Signed-off-by: Joe Stringer <joestringer@nicira.com>
> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>

Acked-by: Ben Pfaff <blp@nicira.com>

Patch
diff mbox

diff --git a/lib/util.h b/lib/util.h
index 7080a0c..eebc6e9 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -568,6 +568,13 @@  ovs_u128_equals(const ovs_u128 *a, const ovs_u128 *b)
     return (a->u64.hi == b->u64.hi) && (a->u64.lo == b->u64.lo);
 }
 
+/* Returns true if 'val' is 0. */
+static inline bool
+ovs_u128_is_zero(const ovs_u128 *val)
+{
+    return !(val->u64.hi || val->u64.lo);
+}
+
 void xsleep(unsigned int seconds);
 
 #ifdef _WIN32