net/intel: ensure correct Rx path is selected
PATCH 1/1 net/intel: ensure correct Rx path is selected
The common rx path selection logic iterates through an array of candidate paths and selects the best fit for the requested features. Currently, in the event that two potential candidates are identified, the one with the fewer offloads (and thus less complex path) is selected. However this is not correct, because if the path with more offloads has a greater SIMD width, that should be chosen. This commit reworks the logic so that the number of offloads is only taken into consideration when choosing between two paths with the same SIMD width.
Since the paths arrays are ordered from lowest SIMD width to highest, and vector paths tend to have fewer offloads enabled than scalar paths, "new" candidate paths with greater SIMDs widths tended to have fewer or equal offloads than the "current" candidate paths and thus were correctly accepted as the best candidate. For this reason the incorrect logic did not cause any incorrect path selections in practise.
--- drivers/net/intel/common/rx.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/intel/common/rx.h +5 -2
@@ -300,8 +300,11 @@ ci_rx_path_select(struct ci_rx_path_features req_features,/* Do not select paths with lower SIMD width than the current path. */ if (path_features->simd_width < current_features->simd_width)continue ; -/* Do not select paths with more offloads enabled than the current path. */ -if (rte_popcount32 (path_features->rx_offloads) > +/* Do not select paths with more offloads enabled than the current path if +* the SIMD widths are the same. +*/ +if (path_features->simd_width == current_features->simd_width && +rte_popcount32 (path_features->rx_offloads) >rte_popcount32 (current_features->rx_offloads))continue ;/* Do not select paths without bulk alloc support if requested and the
Signature · 1 line
2.34.1
Quoted 16 lines · Ciara Loftus
The common rx path selection logic iterates through an array of candidate paths and selects the best fit for the requested features. Currently, in the event that two potential candidates are identified, the one with the fewer offloads (and thus less complex path) is selected. However this is not correct, because if the path with more offloads has a greater SIMD width, that should be chosen. This commit reworks the logic so that the number of offloads is only taken into consideration when choosing between two paths with the same SIMD width.
Since the paths arrays are ordered from lowest SIMD width to highest, and vector paths tend to have fewer offloads enabled than scalar paths, "new" candidate paths with greater SIMDs widths tended to have fewer or equal offloads than the "current" candidate paths and thus were correctly accepted as the best candidate. For this reason the incorrect logic did not cause any incorrect path selections in practise.
Quoted 4 lines
Fixes 9d99641d80a0 ("net/intel: introduce infrastructure for Rx path selection")Signed-off-by Ciara Loftus <[email protected]>---
But see one comment inline below.
Quoted 10 lines
drivers/net/intel/common/rx.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/intel/common/rx.h +0
-0@@ -300,8 +300,11 @@ ci_rx_path_select(struct ci_rx_path_features req_features,/* Do not select paths with lower SIMD width than the current path. */ if (path_features->simd_width < current_features->simd_width)
drivers/net/intel/common/rx.h ci_rx_path_select(struct ci_rx_path_features req_features, · line 309
Quoted 10 lines
drivers/net/intel/common/rx.h +5
-2continue ; -/* Do not select paths with more offloads enabled than the current path. */ -if (rte_popcount32 (path_features->rx_offloads) > +/* Do not select paths with more offloads enabled than the current path if +* the SIMD widths are the same. +*/ +if (path_features->simd_width == current_features->simd_width && +rte_popcount32 (path_features->rx_offloads) >rte_popcount32 (current_features->rx_offloads))continue ;
The logic is correct, but reviewing this in isolation is a little confusing because of the naming. Normally "current" implies the item we are currently checking, so I assumed that path was the currently selected path, but it's not. The roles are actually reversed, and "path" is the one being checked, and current is the chosen one.
A simple fix that I think would help readability is to rename "current" to "chosen_path". We could also rename "path" to "curr_path" in that case, but I think it's unnecessary, as "chosen_path" and "path" should be relatively clear.
What do you think?
Quoted 4 lines
drivers/net/intel/common/rx.h +0
-0/* Do not select paths without bulk alloc support if requested and the Signature · 1 line
2.34.1
Quoted 64 lines · Ciara Loftus
Quoted 8 lines
The common rx path selection logic iterates through an array of candidate paths and selects the best fit for the requested features. Currently, in the event that two potential candidates are identified, the one with the fewer offloads (and thus less complex path) is selected. However this is not correct, because if the path with more offloads has a greater SIMD width, that should be chosen. This commit reworks the logic so that the number of offloads is only taken into consideration when choosing between two paths with the same SIMD
width.
Quoted 9 lines
Since the paths arrays are ordered from lowest SIMD width to highest, and vector paths tend to have fewer offloads enabled than scalar paths, "new" candidate paths with greater SIMDs widths tended to have fewer or equal offloads than the "current" candidate paths and thus were correctly accepted as the best candidate. For this reason the incorrect logic did not cause any incorrect path selections in practise.
Fixes 9d99641d80a0 ("net/intel: introduce infrastructure for Rx pathselection")
Quoted 3 lines
Signed-off-by Ciara Loftus <[email protected]>---
Acked-by Bruce Richardson <[email protected]>But see one comment inline below.
drivers/net/intel/common/rx.h ci_rx_path_select(struct ci_rx_path_features
Quoted 8 lines
drivers/net/intel/common/rx.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/intel/common/rx.h +0
-0@@ -300,8 +300,11 @@ ci_rx_path_select(struct ci_rx_path_features
req_features,drivers/net/intel/common/rx.h ci_rx_path_select(struct ci_rx_path_features · line 300
Quoted 1 line
drivers/net/intel/common/rx.h +0
-0/* Do not select paths with lower SIMD width than the current path. */
drivers/net/intel/common/rx.h ci_rx_path_select(struct ci_rx_path_features · line 304
Quoted 4 lines
drivers/net/intel/common/rx.h +0
-1if (path_features->simd_width < current_features- simd_width)continue ; -/* Do not select paths with more offloads enabled than the current path. */
drivers/net/intel/common/rx.h ci_rx_path_select(struct ci_rx_path_features · line 304
Quoted 2 lines
drivers/net/intel/common/rx.h +1
-1- if (rte_popcount32(path_features->rx_offloads) > +/* Do not select paths with more offloads enabled than the current path if
Quoted 9 lines
drivers/net/intel/common/rx.h +3
-0+* the SIMD widths are the same. +*/ + if (path_features->simd_width == current_features-
simd_width&&drivers/net/intel/common/rx.h +1
-0+ rte_popcount32(path_features-
rx_offloads) >
rte_popcount32(current_features-rx_offloads))
continue;The logic is correct, but reviewing this in isolation is a little confusing because of the naming. Normally "current" implies the item we are currently checking, so I assumed that path was the currently selected path, but it's not. The roles are actually reversed, and "path" is the one being checked, and current is the chosen one.
Quoted 6 lines
A simple fix that I think would help readability is to rename "current" to "
chosen_path". We could also rename "path" to "curr_path" in that case, but I think it's unnecessary, as "chosen_path" and "path" should be relatively clear.What do you think?
+1 definitely agree the naming could be improved. I'll submit a follow-on patch.
Quoted 6 lines
Quoted 2 lines
/* Do not select paths without bulk alloc support if
requested and the
Quoted 3 lines
--
2.34.1
Quoted 64 lines · Ciara
Quoted 64 lines · Ciara Loftus
Quoted 8 lines
The common rx path selection logic iterates through an array of candidate paths and selects the best fit for the requested features. Currently, in the event that two potential candidates are identified, the one with the fewer offloads (and thus less complex path) is selected. However this is not correct, because if the path with more offloads has a greater SIMD width, that should be chosen. This commit reworks the logic so that the number of offloads is only taken into consideration when choosing between two paths with the same SIMD
width.
Quoted 9 lines
Since the paths arrays are ordered from lowest SIMD width to highest, and vector paths tend to have fewer offloads enabled than scalar paths, "new" candidate paths with greater SIMDs widths tended to have fewer or equal offloads than the "current" candidate paths and thus were correctly accepted as the best candidate. For this reason the incorrect logic did not cause any incorrect path selections in practise.
Fixes 9d99641d80a0 ("net/intel: introduce infrastructure for Rx pathselection")
Quoted 3 lines
Signed-off-by Ciara Loftus <[email protected]>---
Acked-by Bruce Richardson <[email protected]>But see one comment inline below.
drivers/net/intel/common/rx.h ci_rx_path_select(struct ci_rx_path_features
Quoted 8 lines
drivers/net/intel/common/rx.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/intel/common/rx.h +0
-0@@ -300,8 +300,11 @@ ci_rx_path_select(struct ci_rx_path_features
req_features,drivers/net/intel/common/rx.h ci_rx_path_select(struct ci_rx_path_features · line 300
Quoted 1 line
drivers/net/intel/common/rx.h +0
-0/* Do not select paths with lower SIMD width than the current path. */
drivers/net/intel/common/rx.h ci_rx_path_select(struct ci_rx_path_features · line 304
Quoted 4 lines
drivers/net/intel/common/rx.h +0
-1if (path_features->simd_width < current_features- simd_width)continue ; -/* Do not select paths with more offloads enabled than the current path. */
drivers/net/intel/common/rx.h ci_rx_path_select(struct ci_rx_path_features · line 304
Quoted 2 lines
drivers/net/intel/common/rx.h +1
-1- if (rte_popcount32(path_features->rx_offloads) > +/* Do not select paths with more offloads enabled than the current path if
Quoted 9 lines
drivers/net/intel/common/rx.h +3
-0+* the SIMD widths are the same. +*/ + if (path_features->simd_width == current_features-
simd_width&&drivers/net/intel/common/rx.h +1
-0+ rte_popcount32(path_features-
rx_offloads) >
rte_popcount32(current_features-rx_offloads))
continue;The logic is correct, but reviewing this in isolation is a little confusing because of the naming. Normally "current" implies the item we are currently checking, so I assumed that path was the currently selected path, but it's not. The roles are actually reversed, and "path" is the one being checked, and current is the chosen one.
Quoted 9 lines
Quoted 6 lines
A simple fix that I think would help readability is to rename "current" to "
chosen_path". We could also rename "path" to "curr_path" in that case, but I think it's unnecessary, as "chosen_path" and "path" should be relatively clear.What do you think?
+1 definitely agree the naming could be improved. I'll submit a follow-on patch.
I'll take this as-is so, and you can base the follow-on on top of this.
Bruce Richardson
AppliedQuoted 19 lines · Ciara
Quoted 19 lines · Ciara Loftus
Quoted 8 lines
The common rx path selection logic iterates through an array of candidate paths and selects the best fit for the requested features. Currently, in the event that two potential candidates are identified, the one with the fewer offloads (and thus less complex path) is selected. However this is not correct, because if the path with more offloads has a greater SIMD width, that should be chosen. This commit reworks the logic so that the number of offloads is only taken into consideration when choosing between two paths with the same SIMD
width.
Quoted 8 lines
Since the paths arrays are ordered from lowest SIMD width to highest, and vector paths tend to have fewer offloads enabled than scalar paths, "new" candidate paths with greater SIMDs widths tended to have fewer or equal offloads than the "current" candidate paths and thus were correctly accepted as the best candidate. For this reason the incorrect logic did not cause any incorrect path selections in practise.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Fixes 9d99641d80a0 ("net/intel: introduce infrastructure for Rx pathselection")
Quoted 3 lines
Signed-off-by Ciara Loftus <[email protected]>---
Acked-by Bruce Richardson <[email protected]>
Applied to dpdk-next-net-intel.
Thanks.
/Bruce