ccan: Add likely implementation
PATCH 1/1 ccan: Add likely implementation
Add likely/unlikely macros to ccan directory. This change includes adjustments to various providers, who defined it locally (nes, mlx4, mlx5 and hns).
The code of i40iw had such definitions too, but without actual usage and this patch removed this dead code.
--- ccan/CMakeLists.txt | 2 + ccan/likely.c | 136 ++++++++++++++++++++++++++++++++++++++++++ ccan/likely.h | 111 ++++++++++++++++++++++++++++++++++ providers/hns/hns_roce_u.h | 5 +- providers/i40iw/i40iw_umain.h | 7 --- providers/mlx4/mlx4.h | 8 --- providers/mlx4/qp.c | 1 + providers/mlx5/mlx5.h | 6 +- providers/nes/nes_umain.h | 8 +-- 9 files changed, 253 insertions(+), 31 deletions(-) create mode 100644 ccan/likely.c create mode 100644 ccan/likely.h
ccan/CMakeLists.txt +2 -0
@@ -6,11 +6,13 @@ publish_internal_headers(ccan minmax.h str.h str_debug.h + likely.h ) set(C_FILES list.c str.c + likely.c ) add_library(ccan STATIC ${C_FILES}) add_library(ccan_pic STATIC ${C_FILES})
ccan/likely.c new file +136 -0
136 lines not on this page · raw message
ccan/likely.h new file +111 -0
111 lines not on this page · raw message
providers/hns/hns_roce_u.h +1 -4
@@ -39,6 +39,7 @@#include <infiniband/arch.h> #include <infiniband/verbs.h> #include <ccan/container_of.h> +#include <ccan/likely.h> #define HNS_ROCE_CQE_ENTRY_SIZE 0x20
@@ -51,10 +52,6 @@#define PFX "hns: " -#ifndef likely -#define likely (x) __builtin_expect(!!(x), 1) -#endif -#define roce_get_field (origin, mask, shift) \ (((origin) & (mask)) >> (shift))
providers/i40iw/i40iw_umain.h +0 -7
@@ -47,13 +47,6 @@#include "i40iw_status.h" #include "i40iw_user.h" -#ifndef likely -#define likely (x) __builtin_expect((x), 1) -#endif -#ifndef unlikely -#define unlikely (x) __builtin_expect((x), 0) -#endif -#define PFX "libi40iw-"#define I40IW_BASE_PUSH_PAGE 1
providers/mlx4/mlx4.h +0 -8
@@ -51,14 +51,6 @@ enum {MLX4_STAT_RATE_OFFSET =5 }; -#ifndef likely -#ifdef __GNUC__ -#define likely (x) __builtin_expect(!!(x),1) -#else -#define likely (x) (x) -#endif -#endif -enum {MLX4_QP_TABLE_BITS =8 ,MLX4_QP_TABLE_SIZE =1 <<MLX4_QP_TABLE_BITS ,
providers/mlx4/qp.c +1 -0
@@ -40,6 +40,7 @@#include <string.h> #include <errno.h> #include <util/compiler.h> +#include <ccan/likely.h> #include "mlx4.h" #include "doorbell.h"
providers/mlx5/mlx5.h +1 -5
@@ -42,11 +42,7 @@#include <ccan/list.h> #include "bitmap.h" #include <ccan/minmax.h> - -#ifdef __GNUC__ -#define likely (x) __builtin_expect((x), 1) -#define unlikely (x) __builtin_expect((x), 0) -#endif +#include <ccan/likely.h> #include <valgrind/memcheck.h>
providers/nes/nes_umain.h +1 -7
@@ -40,13 +40,7 @@#include <infiniband/driver.h> #include <infiniband/arch.h> - -#ifndef likely -#define likely (x) __builtin_expect((x),1) -#endif -#ifndef unlikely -#define unlikely (x) __builtin_expect((x),0) -#endif +#include <ccan/likely.h> #define PFX "libnes: "
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1479318011-26878-1-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Quoted 4 lines · Leon Romanovsky
index b5de515..153426f 100644
+++b/ccan/CMakeLists.txtccan/CMakeLists.txt +0
-0@@ -6,11 +6,13 @@ publish_internal_headers(ccan minmax.h
ccan/CMakeLists.txt publish_internal_headers(ccan · line 16
Quoted 10 lines
ccan/CMakeLists.txt +2
-0str.h str_debug.h + likely.h ) set(C_FILES list.c str.c + likely.c )
Keep these lists sorted please
ccan/likely.c line 5
Quoted 7 lines
ccan/likely.c new file +6
-0+++ b/ccan/likely.c@@ -0,0 +1,136 @@ +/* CC0 (Public domain) - see LICENSE file for details. */ +#ifdef CCAN_LIKELY_DEBUG +#include <ccan/likely/likely.h> +#include <ccan/hash/hash.h> +#include <ccan/htable/htable_type.h>
Hmm, this isn't going to compile if the debug is set, maybe drop the .c - but this seems really interesting to see if likely is being used sensibly....
ccan/likely.h line 8
Quoted 2 lines
ccan/likely.h new file +2
-0+#ifndef CCAN_LIKELY_DEBUG +#if HAVE_BUILTIN_EXPECT
You need to add '#define HAVE_BUILTIN_EXPECT 1' to buildlib/config.h.in - or this doesn't work at all.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20161116201343.GB19593-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Quoted 11 lines · Jason Gunthorpe
Quoted 9 lines · Leon Romanovsky
index b5de515..153426f 100644
+++b/ccan/CMakeLists.txtccan/CMakeLists.txt +1
-0@@ -6,11 +6,13 @@ publish_internal_headers(ccan minmax.h str.h str_debug.h + likely.h )
Quoted 7 lines
ccan/CMakeLists.txt publish_internal_headers(ccan · line 16
Quoted 5 lines
ccan/CMakeLists.txt +1
-0set(C_FILES list.c str.c + likely.c )Keep these lists sorted please
Sure
Quoted 13 lines
ccan/likely.c line 5
Quoted 8 lines
ccan/likely.c new file +6
-0+++ b/ccan/likely.c@@ -0,0 +1,136 @@ +/* CC0 (Public domain) - see LICENSE file for details. */ +#ifdef CCAN_LIKELY_DEBUG +#include <ccan/likely/likely.h> +#include <ccan/hash/hash.h> +#include <ccan/htable/htable_type.h> Hmm, this isn't going to compile if the debug is set, maybe drop the .c - but this seems really interesting to see if likely is being used sensibly....
Quoted 5 lines
ccan/likely.h line 8
Quoted 2 lines
ccan/likely.h new file +2
-0+#ifndef CCAN_LIKELY_DEBUG +#if HAVE_BUILTIN_EXPECT You need to add '#define
HAVE_BUILTIN_EXPECT1' to buildlib/config.h.in - or this doesn't work at all.
This is exactly what I wanted to discuss over ML.
From one side, I wanted to ensure that ccan files are similar to official ones, so upgrade to new versions will be seamless.
From another side, I don't see the real usage of likely/unlikely debug facilities.
So my approach was to add these files as is, but don't connect debug functionality.
Quoted 2 lines
Jason