Skip to contentSkip to conversation

rte_flow: mark rte_flow_error_set as cold

PATCH In review Stephen Hemminger 3 participants 4 messages May 20, 2019 – May 21, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rte_flow: mark rte_flow_error_set as cold

A minor optimization that save a few cycles during flow setup.

Use the GCC cold attribute for the rte_flow_error_set function. This attribute implicitly marks all code paths that arrive at this function as unlikely.

---
 lib/librte_ethdev/rte_flow.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
lib/librte_ethdev/rte_flow.h +7 -1
index 63f84fca65c4..dc821be43f19 100644
@@ -2591,7 +2591,13 @@ rte_flow_error_set(struct rte_flow_error *error,
 		   int code,
 		   enum rte_flow_error_type type,
 		   const void *cause,
-		   const char *message);
+		   const char *message)
+#ifdef __GNUC__
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
+	__attribute__((cold))
+#endif
+#endif
+	;
 
 /**
  * @deprecated
Signature · 1 line
2.20.1
#1 lore raw
Quoted 7 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Monday, May 20, 2019 11:52 PM
To: [email protected]
Cc: [email protected]; Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH] rte_flow: mark rte_flow_error_set as cold

Quoted 5 lines

A minor optimization that save a few cycles during flow setup.

Use the GCC cold attribute for the rte_flow_error_set function. This attribute implicitly marks all code paths that arrive at this function as unlikely.

Interesting - wasn't aware this is what the "cold" attribute does.

Quoted 9 lines
 lib/librte_ethdev/rte_flow.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
lib/librte_ethdev/rte_flow.h +0 -0
index 63f84fca65c4..dc821be43f19 100644
@@ -2591,7 +2591,13 @@ rte_flow_error_set(struct rte_flow_error *error,
 		   int code,

lib/librte_ethdev/rte_flow.h rte_flow_error_set(struct rte_flow_error *error, · line 2600

Quoted 10 lines
lib/librte_ethdev/rte_flow.h +7 -1
 		   enum rte_flow_error_type type,
 		   const void *cause,
-		   const char *message);
+		   const char *message)
+#ifdef __GNUC__
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
+	__attribute__((cold))
+#endif
+#endif
+	;

Would it be worth making an __rte_attribute_cold or similar? Less in-place #ifdefs and there are probably other locations in DPDK that would also benefit from such an annotation.

-Harry

#2 lore raw
Quoted 41 lines · Harry
Quoted 7 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Monday, May 20, 2019 11:52 PM
To: [email protected]
Cc: [email protected]; Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH] rte_flow: mark rte_flow_error_set as cold

Quoted 5 lines

A minor optimization that save a few cycles during flow setup.

Use the GCC cold attribute for the rte_flow_error_set function. This attribute implicitly marks all code paths that arrive at this function as unlikely.

Interesting - wasn't aware this is what the "cold" attribute does.

Quoted 9 lines
 lib/librte_ethdev/rte_flow.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
lib/librte_ethdev/rte_flow.h +0 -0
index 63f84fca65c4..dc821be43f19 100644
@@ -2591,7 +2591,13 @@ rte_flow_error_set(struct rte_flow_error *error,
 		   int code,

lib/librte_ethdev/rte_flow.h rte_flow_error_set(struct rte_flow_error *error, · line 2600

Quoted 10 lines
lib/librte_ethdev/rte_flow.h +7 -1
 		   enum rte_flow_error_type type,
 		   const void *cause,
-		   const char *message);
+		   const char *message)
+#ifdef __GNUC__
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
+	__attribute__((cold))
+#endif
+#endif
+	;  

Would it be worth making an __rte_attribute_cold or similar? Less in-place #ifdefs and there are probably other locations in DPDK that would also benefit from such an annotation.

Quoted 1 line

-Harry

I just cloned what was already on rte_log.

#3 lore raw
Quoted 35 lines · Stephen Hemminger
Quoted 32 lines · Harry
Quoted 7 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Monday, May 20, 2019 11:52 PM
To: [email protected]
Cc: [email protected]; Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH] rte_flow: mark rte_flow_error_set as cold

Quoted 5 lines

A minor optimization that save a few cycles during flow setup.

Use the GCC cold attribute for the rte_flow_error_set function. This attribute implicitly marks all code paths that arrive at this function as unlikely.

Interesting - wasn't aware this is what the "cold" attribute does.

Quoted 16 lines
 lib/librte_ethdev/rte_flow.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
lib/librte_ethdev/rte_flow.h +4 -1
index 63f84fca65c4..dc821be43f19 100644
@@ -2591,7 +2591,13 @@ rte_flow_error_set(struct rte_flow_error *error,
 		   int code,
 		   enum rte_flow_error_type type,
 		   const void *cause,
-		   const char *message);
+		   const char *message)
+#ifdef __GNUC__
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
+	__attribute__((cold))
Quoted 8 lines
Quoted 8 lines

lib/librte_ethdev/rte_flow.h rte_flow_error_set(struct rte_flow_error *error, · line 2600

Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3 -0
+#endif
+#endif
+	;  

Would it be worth making an __rte_attribute_cold or similar? Less in-place #ifdefs and there are probably other locations in DPDK that would also benefit from such an annotation.

+1 to define '__rte_cold' [1] in 'lib/librte_eal/common/include/rte_common.h' as defined other similar compiler attributes there.

[1]
or '__rte_attribute_cold' but all other attribute defines are missing 'attribute' keyword, so I think can be skipped here as well

Quoted 5 lines
Quoted 2 lines

-Harry

I just cloned what was already on rte_log.