DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] small RIB optimizations
@ 2022-04-13  2:09 Stephen Hemminger
  2022-04-13  2:09 ` [PATCH 1/2] rib: mark error checks with unlikely Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stephen Hemminger @ 2022-04-13  2:09 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

A couple of small micro optimizations on the RIB code.

Stephen Hemminger (2):
  rib: mark error checks with unlikely
  rib6: mark error tests with unlikely

 lib/rib/rte_rib.c  | 26 +++++++++++++-------------
 lib/rib/rte_rib6.c | 25 ++++++++++++-------------
 2 files changed, 25 insertions(+), 26 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] rib: mark error checks with unlikely
  2022-04-13  2:09 [PATCH 0/2] small RIB optimizations Stephen Hemminger
@ 2022-04-13  2:09 ` Stephen Hemminger
  2022-04-26 14:27   ` Medvedkin, Vladimir
  2022-04-13  2:09 ` [PATCH 2/2] rib6: mark error tests " Stephen Hemminger
  2022-04-13  6:45 ` [PATCH 0/2] small RIB optimizations Morten Brørup
  2 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2022-04-13  2:09 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin

Also mark some conditional functions as const.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/rib/rte_rib.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index cd9e823068d2..2a3de5065a31 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -48,13 +48,13 @@ struct rte_rib {
 };
 
 static inline bool
-is_valid_node(struct rte_rib_node *node)
+is_valid_node(const struct rte_rib_node *node)
 {
 	return (node->flag & RTE_RIB_VALID_NODE) == RTE_RIB_VALID_NODE;
 }
 
 static inline bool
-is_right_node(struct rte_rib_node *node)
+is_right_node(const struct rte_rib_node *node)
 {
 	return node->parent->right == node;
 }
@@ -99,7 +99,7 @@ rte_rib_lookup(struct rte_rib *rib, uint32_t ip)
 {
 	struct rte_rib_node *cur, *prev = NULL;
 
-	if (rib == NULL) {
+	if (unlikely(rib == NULL)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -147,7 +147,7 @@ __rib_lookup_exact(struct rte_rib *rib, uint32_t ip, uint8_t depth)
 struct rte_rib_node *
 rte_rib_lookup_exact(struct rte_rib *rib, uint32_t ip, uint8_t depth)
 {
-	if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
+	if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -167,7 +167,7 @@ rte_rib_get_nxt(struct rte_rib *rib, uint32_t ip,
 {
 	struct rte_rib_node *tmp, *prev = NULL;
 
-	if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
+	if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -244,7 +244,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
 	uint32_t common_prefix;
 	uint8_t common_depth;
 
-	if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
+	if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -342,7 +342,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
 int
 rte_rib_get_ip(const struct rte_rib_node *node, uint32_t *ip)
 {
-	if ((node == NULL) || (ip == NULL)) {
+	if (unlikely(node == NULL || ip == NULL)) {
 		rte_errno = EINVAL;
 		return -1;
 	}
@@ -353,7 +353,7 @@ rte_rib_get_ip(const struct rte_rib_node *node, uint32_t *ip)
 int
 rte_rib_get_depth(const struct rte_rib_node *node, uint8_t *depth)
 {
-	if ((node == NULL) || (depth == NULL)) {
+	if (unlikely(node == NULL || depth == NULL)) {
 		rte_errno = EINVAL;
 		return -1;
 	}
@@ -370,7 +370,7 @@ rte_rib_get_ext(struct rte_rib_node *node)
 int
 rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh)
 {
-	if ((node == NULL) || (nh == NULL)) {
+	if (unlikely(node == NULL || nh == NULL)) {
 		rte_errno = EINVAL;
 		return -1;
 	}
@@ -381,7 +381,7 @@ rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh)
 int
 rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh)
 {
-	if (node == NULL) {
+	if (unlikely(node == NULL)) {
 		rte_errno = EINVAL;
 		return -1;
 	}
@@ -399,7 +399,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 	struct rte_mempool *node_pool;
 
 	/* Check user arguments. */
-	if (name == NULL || conf == NULL || conf->max_nodes <= 0) {
+	if (unlikely(name == NULL || conf == NULL || conf->max_nodes <= 0)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -434,7 +434,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 
 	/* allocate tailq entry */
 	te = rte_zmalloc("RIB_TAILQ_ENTRY", sizeof(*te), 0);
-	if (te == NULL) {
+	if (unlikely(te == NULL)) {
 		RTE_LOG(ERR, LPM,
 			"Can not allocate tailq entry for RIB %s\n", name);
 		rte_errno = ENOMEM;
@@ -444,7 +444,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 	/* Allocate memory to store the RIB data structures. */
 	rib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_rib),	RTE_CACHE_LINE_SIZE, socket_id);
-	if (rib == NULL) {
+	if (unlikely(rib == NULL)) {
 		RTE_LOG(ERR, LPM, "RIB %s memory allocation failed\n", name);
 		rte_errno = ENOMEM;
 		goto free_te;
-- 
2.35.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] rib6: mark error tests with unlikely
  2022-04-13  2:09 [PATCH 0/2] small RIB optimizations Stephen Hemminger
  2022-04-13  2:09 ` [PATCH 1/2] rib: mark error checks with unlikely Stephen Hemminger
@ 2022-04-13  2:09 ` Stephen Hemminger
  2022-04-26 14:27   ` Medvedkin, Vladimir
  2022-04-13  6:45 ` [PATCH 0/2] small RIB optimizations Morten Brørup
  2 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2022-04-13  2:09 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin

Also mark some conditional functions as const.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/rib/rte_rib6.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 042ac1f090bf..650bf1b8f681 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -47,13 +47,13 @@ struct rte_rib6 {
 };
 
 static inline bool
-is_valid_node(struct rte_rib6_node *node)
+is_valid_node(const struct rte_rib6_node *node)
 {
 	return (node->flag & RTE_RIB_VALID_NODE) == RTE_RIB_VALID_NODE;
 }
 
 static inline bool
-is_right_node(struct rte_rib6_node *node)
+is_right_node(const struct rte_rib6_node *node)
 {
 	return node->parent->right == node;
 }
@@ -171,7 +171,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib,
 	uint8_t tmp_ip[RTE_RIB6_IPV6_ADDR_SIZE];
 	int i;
 
-	if ((rib == NULL) || (ip == NULL) || (depth > RIB6_MAXDEPTH)) {
+	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -210,7 +210,7 @@ rte_rib6_get_nxt(struct rte_rib6 *rib,
 	uint8_t tmp_ip[RTE_RIB6_IPV6_ADDR_SIZE];
 	int i;
 
-	if ((rib == NULL) || (ip == NULL) || (depth > RIB6_MAXDEPTH)) {
+	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -293,8 +293,7 @@ rte_rib6_insert(struct rte_rib6 *rib,
 	int i, d;
 	uint8_t common_depth, ip_xor;
 
-	if (unlikely((rib == NULL) || (ip == NULL) ||
-			(depth > RIB6_MAXDEPTH))) {
+	if (unlikely((rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH))) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -413,7 +412,7 @@ int
 rte_rib6_get_ip(const struct rte_rib6_node *node,
 		uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE])
 {
-	if ((node == NULL) || (ip == NULL)) {
+	if (unlikely(node == NULL || ip == NULL)) {
 		rte_errno = EINVAL;
 		return -1;
 	}
@@ -424,7 +423,7 @@ rte_rib6_get_ip(const struct rte_rib6_node *node,
 int
 rte_rib6_get_depth(const struct rte_rib6_node *node, uint8_t *depth)
 {
-	if ((node == NULL) || (depth == NULL)) {
+	if (unlikely(node == NULL || depth == NULL)) {
 		rte_errno = EINVAL;
 		return -1;
 	}
@@ -441,7 +440,7 @@ rte_rib6_get_ext(struct rte_rib6_node *node)
 int
 rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh)
 {
-	if ((node == NULL) || (nh == NULL)) {
+	if (unlikely(node == NULL || nh == NULL)) {
 		rte_errno = EINVAL;
 		return -1;
 	}
@@ -452,7 +451,7 @@ rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh)
 int
 rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh)
 {
-	if (node == NULL) {
+	if (unlikely(node == NULL)) {
 		rte_errno = EINVAL;
 		return -1;
 	}
@@ -471,7 +470,7 @@ rte_rib6_create(const char *name, int socket_id,
 	struct rte_mempool *node_pool;
 
 	/* Check user arguments. */
-	if (name == NULL || conf == NULL || conf->max_nodes <= 0) {
+	if (unlikely(name == NULL || conf == NULL || conf->max_nodes <= 0)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -506,7 +505,7 @@ rte_rib6_create(const char *name, int socket_id,
 
 	/* allocate tailq entry */
 	te = rte_zmalloc("RIB6_TAILQ_ENTRY", sizeof(*te), 0);
-	if (te == NULL) {
+	if (unlikely(te == NULL)) {
 		RTE_LOG(ERR, LPM,
 			"Can not allocate tailq entry for RIB6 %s\n", name);
 		rte_errno = ENOMEM;
@@ -516,7 +515,7 @@ rte_rib6_create(const char *name, int socket_id,
 	/* Allocate memory to store the RIB6 data structures. */
 	rib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_rib6), RTE_CACHE_LINE_SIZE, socket_id);
-	if (rib == NULL) {
+	if (unlikely(rib == NULL)) {
 		RTE_LOG(ERR, LPM, "RIB6 %s memory allocation failed\n", name);
 		rte_errno = ENOMEM;
 		goto free_te;
-- 
2.35.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH 0/2] small RIB optimizations
  2022-04-13  2:09 [PATCH 0/2] small RIB optimizations Stephen Hemminger
  2022-04-13  2:09 ` [PATCH 1/2] rib: mark error checks with unlikely Stephen Hemminger
  2022-04-13  2:09 ` [PATCH 2/2] rib6: mark error tests " Stephen Hemminger
@ 2022-04-13  6:45 ` Morten Brørup
  2022-06-01  8:58   ` Thomas Monjalon
  2 siblings, 1 reply; 7+ messages in thread
From: Morten Brørup @ 2022-04-13  6:45 UTC (permalink / raw)
  To: Stephen Hemminger, dev

> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Wednesday, 13 April 2022 04.10
> 
> A couple of small micro optimizations on the RIB code.
> 
> Stephen Hemminger (2):
>   rib: mark error checks with unlikely
>   rib6: mark error tests with unlikely
> 
>  lib/rib/rte_rib.c  | 26 +++++++++++++-------------
>  lib/rib/rte_rib6.c | 25 ++++++++++++-------------
>  2 files changed, 25 insertions(+), 26 deletions(-)
> 
> --
> 2.35.1
> 

Series-Acked-by: Morten Brørup <mb@smartsharesystems.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] rib: mark error checks with unlikely
  2022-04-13  2:09 ` [PATCH 1/2] rib: mark error checks with unlikely Stephen Hemminger
@ 2022-04-26 14:27   ` Medvedkin, Vladimir
  0 siblings, 0 replies; 7+ messages in thread
From: Medvedkin, Vladimir @ 2022-04-26 14:27 UTC (permalink / raw)
  To: Stephen Hemminger, dev



On 13/04/2022 03:09, Stephen Hemminger wrote:
> Also mark some conditional functions as const.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/rib/rte_rib.c | 26 +++++++++++++-------------
>   1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
> index cd9e823068d2..2a3de5065a31 100644
> --- a/lib/rib/rte_rib.c
> +++ b/lib/rib/rte_rib.c
> @@ -48,13 +48,13 @@ struct rte_rib {
>   };
>   
>   static inline bool
> -is_valid_node(struct rte_rib_node *node)
> +is_valid_node(const struct rte_rib_node *node)
>   {
>   	return (node->flag & RTE_RIB_VALID_NODE) == RTE_RIB_VALID_NODE;
>   }
>   
>   static inline bool
> -is_right_node(struct rte_rib_node *node)
> +is_right_node(const struct rte_rib_node *node)
>   {
>   	return node->parent->right == node;
>   }
> @@ -99,7 +99,7 @@ rte_rib_lookup(struct rte_rib *rib, uint32_t ip)
>   {
>   	struct rte_rib_node *cur, *prev = NULL;
>   
> -	if (rib == NULL) {
> +	if (unlikely(rib == NULL)) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> @@ -147,7 +147,7 @@ __rib_lookup_exact(struct rte_rib *rib, uint32_t ip, uint8_t depth)
>   struct rte_rib_node *
>   rte_rib_lookup_exact(struct rte_rib *rib, uint32_t ip, uint8_t depth)
>   {
> -	if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
> +	if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> @@ -167,7 +167,7 @@ rte_rib_get_nxt(struct rte_rib *rib, uint32_t ip,
>   {
>   	struct rte_rib_node *tmp, *prev = NULL;
>   
> -	if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
> +	if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> @@ -244,7 +244,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
>   	uint32_t common_prefix;
>   	uint8_t common_depth;
>   
> -	if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
> +	if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> @@ -342,7 +342,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
>   int
>   rte_rib_get_ip(const struct rte_rib_node *node, uint32_t *ip)
>   {
> -	if ((node == NULL) || (ip == NULL)) {
> +	if (unlikely(node == NULL || ip == NULL)) {
>   		rte_errno = EINVAL;
>   		return -1;
>   	}
> @@ -353,7 +353,7 @@ rte_rib_get_ip(const struct rte_rib_node *node, uint32_t *ip)
>   int
>   rte_rib_get_depth(const struct rte_rib_node *node, uint8_t *depth)
>   {
> -	if ((node == NULL) || (depth == NULL)) {
> +	if (unlikely(node == NULL || depth == NULL)) {
>   		rte_errno = EINVAL;
>   		return -1;
>   	}
> @@ -370,7 +370,7 @@ rte_rib_get_ext(struct rte_rib_node *node)
>   int
>   rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh)
>   {
> -	if ((node == NULL) || (nh == NULL)) {
> +	if (unlikely(node == NULL || nh == NULL)) {
>   		rte_errno = EINVAL;
>   		return -1;
>   	}
> @@ -381,7 +381,7 @@ rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh)
>   int
>   rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh)
>   {
> -	if (node == NULL) {
> +	if (unlikely(node == NULL)) {
>   		rte_errno = EINVAL;
>   		return -1;
>   	}
> @@ -399,7 +399,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
>   	struct rte_mempool *node_pool;
>   
>   	/* Check user arguments. */
> -	if (name == NULL || conf == NULL || conf->max_nodes <= 0) {
> +	if (unlikely(name == NULL || conf == NULL || conf->max_nodes <= 0)) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> @@ -434,7 +434,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
>   
>   	/* allocate tailq entry */
>   	te = rte_zmalloc("RIB_TAILQ_ENTRY", sizeof(*te), 0);
> -	if (te == NULL) {
> +	if (unlikely(te == NULL)) {
>   		RTE_LOG(ERR, LPM,
>   			"Can not allocate tailq entry for RIB %s\n", name);
>   		rte_errno = ENOMEM;
> @@ -444,7 +444,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
>   	/* Allocate memory to store the RIB data structures. */
>   	rib = rte_zmalloc_socket(mem_name,
>   		sizeof(struct rte_rib),	RTE_CACHE_LINE_SIZE, socket_id);
> -	if (rib == NULL) {
> +	if (unlikely(rib == NULL)) {
>   		RTE_LOG(ERR, LPM, "RIB %s memory allocation failed\n", name);
>   		rte_errno = ENOMEM;
>   		goto free_te;

Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

-- 
Regards,
Vladimir

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] rib6: mark error tests with unlikely
  2022-04-13  2:09 ` [PATCH 2/2] rib6: mark error tests " Stephen Hemminger
@ 2022-04-26 14:27   ` Medvedkin, Vladimir
  0 siblings, 0 replies; 7+ messages in thread
From: Medvedkin, Vladimir @ 2022-04-26 14:27 UTC (permalink / raw)
  To: Stephen Hemminger, dev



On 13/04/2022 03:09, Stephen Hemminger wrote:
> Also mark some conditional functions as const.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/rib/rte_rib6.c | 25 ++++++++++++-------------
>   1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
> index 042ac1f090bf..650bf1b8f681 100644
> --- a/lib/rib/rte_rib6.c
> +++ b/lib/rib/rte_rib6.c
> @@ -47,13 +47,13 @@ struct rte_rib6 {
>   };
>   
>   static inline bool
> -is_valid_node(struct rte_rib6_node *node)
> +is_valid_node(const struct rte_rib6_node *node)
>   {
>   	return (node->flag & RTE_RIB_VALID_NODE) == RTE_RIB_VALID_NODE;
>   }
>   
>   static inline bool
> -is_right_node(struct rte_rib6_node *node)
> +is_right_node(const struct rte_rib6_node *node)
>   {
>   	return node->parent->right == node;
>   }
> @@ -171,7 +171,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib,
>   	uint8_t tmp_ip[RTE_RIB6_IPV6_ADDR_SIZE];
>   	int i;
>   
> -	if ((rib == NULL) || (ip == NULL) || (depth > RIB6_MAXDEPTH)) {
> +	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> @@ -210,7 +210,7 @@ rte_rib6_get_nxt(struct rte_rib6 *rib,
>   	uint8_t tmp_ip[RTE_RIB6_IPV6_ADDR_SIZE];
>   	int i;
>   
> -	if ((rib == NULL) || (ip == NULL) || (depth > RIB6_MAXDEPTH)) {
> +	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> @@ -293,8 +293,7 @@ rte_rib6_insert(struct rte_rib6 *rib,
>   	int i, d;
>   	uint8_t common_depth, ip_xor;
>   
> -	if (unlikely((rib == NULL) || (ip == NULL) ||
> -			(depth > RIB6_MAXDEPTH))) {
> +	if (unlikely((rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH))) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> @@ -413,7 +412,7 @@ int
>   rte_rib6_get_ip(const struct rte_rib6_node *node,
>   		uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE])
>   {
> -	if ((node == NULL) || (ip == NULL)) {
> +	if (unlikely(node == NULL || ip == NULL)) {
>   		rte_errno = EINVAL;
>   		return -1;
>   	}
> @@ -424,7 +423,7 @@ rte_rib6_get_ip(const struct rte_rib6_node *node,
>   int
>   rte_rib6_get_depth(const struct rte_rib6_node *node, uint8_t *depth)
>   {
> -	if ((node == NULL) || (depth == NULL)) {
> +	if (unlikely(node == NULL || depth == NULL)) {
>   		rte_errno = EINVAL;
>   		return -1;
>   	}
> @@ -441,7 +440,7 @@ rte_rib6_get_ext(struct rte_rib6_node *node)
>   int
>   rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh)
>   {
> -	if ((node == NULL) || (nh == NULL)) {
> +	if (unlikely(node == NULL || nh == NULL)) {
>   		rte_errno = EINVAL;
>   		return -1;
>   	}
> @@ -452,7 +451,7 @@ rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh)
>   int
>   rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh)
>   {
> -	if (node == NULL) {
> +	if (unlikely(node == NULL)) {
>   		rte_errno = EINVAL;
>   		return -1;
>   	}
> @@ -471,7 +470,7 @@ rte_rib6_create(const char *name, int socket_id,
>   	struct rte_mempool *node_pool;
>   
>   	/* Check user arguments. */
> -	if (name == NULL || conf == NULL || conf->max_nodes <= 0) {
> +	if (unlikely(name == NULL || conf == NULL || conf->max_nodes <= 0)) {
>   		rte_errno = EINVAL;
>   		return NULL;
>   	}
> @@ -506,7 +505,7 @@ rte_rib6_create(const char *name, int socket_id,
>   
>   	/* allocate tailq entry */
>   	te = rte_zmalloc("RIB6_TAILQ_ENTRY", sizeof(*te), 0);
> -	if (te == NULL) {
> +	if (unlikely(te == NULL)) {
>   		RTE_LOG(ERR, LPM,
>   			"Can not allocate tailq entry for RIB6 %s\n", name);
>   		rte_errno = ENOMEM;
> @@ -516,7 +515,7 @@ rte_rib6_create(const char *name, int socket_id,
>   	/* Allocate memory to store the RIB6 data structures. */
>   	rib = rte_zmalloc_socket(mem_name,
>   		sizeof(struct rte_rib6), RTE_CACHE_LINE_SIZE, socket_id);
> -	if (rib == NULL) {
> +	if (unlikely(rib == NULL)) {
>   		RTE_LOG(ERR, LPM, "RIB6 %s memory allocation failed\n", name);
>   		rte_errno = ENOMEM;
>   		goto free_te;

Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

-- 
Regards,
Vladimir

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] small RIB optimizations
  2022-04-13  6:45 ` [PATCH 0/2] small RIB optimizations Morten Brørup
@ 2022-06-01  8:58   ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2022-06-01  8:58 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Morten Brørup, vladimir.medvedkin

13/04/2022 08:45, Morten Brørup:
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Wednesday, 13 April 2022 04.10
> > 
> > A couple of small micro optimizations on the RIB code.
> > 
> > Stephen Hemminger (2):
> >   rib: mark error checks with unlikely
> >   rib6: mark error tests with unlikely
> 
> Series-Acked-by: Morten Brørup <mb@smartsharesystems.com>

Squashed and applied, thanks.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-01  8:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13  2:09 [PATCH 0/2] small RIB optimizations Stephen Hemminger
2022-04-13  2:09 ` [PATCH 1/2] rib: mark error checks with unlikely Stephen Hemminger
2022-04-26 14:27   ` Medvedkin, Vladimir
2022-04-13  2:09 ` [PATCH 2/2] rib6: mark error tests " Stephen Hemminger
2022-04-26 14:27   ` Medvedkin, Vladimir
2022-04-13  6:45 ` [PATCH 0/2] small RIB optimizations Morten Brørup
2022-06-01  8:58   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).