Skip to contentSkip to conversation

net/ixgbe: fix inverted test and set conditional

PATCH New Tyler Retzlaff 4 participants 6 messages Jun 15, 2023 – Jun 19, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ixgbe: fix inverted test and set conditional

net/ixgbe: fix inverted test and set conditional

I either dropped ! in the offending series or just failed to notice that the return value for __atomic_test_and_set is inverted relative to rte_atomic32_test_and_set.

Tyler Retzlaff (1):
net/ixgbe: fix inverted test and set conditional

 drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 net/ixgbe: fix inverted test and set conditional

Correct a mistake when converting ixgbe to use __atomic_test_and_set instead of rte_atomic32_test_and_set. The return value from __atomic_test_and_set is inverted relative to rte_atomic32_test_and_set.

Fixes e90baf6b82f6 ("net/ixgbe: replace legacy atomics with GCC builtin atomics")
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
index 43aea2e..5f73ae8 100644
@@ -4322,7 +4322,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 		if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
 			ixgbe_dev_wait_setup_link_complete(dev, 0);
 			/* NOTE: review for potential ordering optimization */
-			if (__atomic_test_and_set(&ad->link_thread_running, __ATOMIC_SEQ_CST)) {
+			if (!__atomic_test_and_set(&ad->link_thread_running, __ATOMIC_SEQ_CST)) {
 				/* To avoid race condition between threads, set
 				 * the IXGBE_FLAG_NEED_LINK_CONFIG flag only
 				 * when there is no link thread running.
Signature · 1 line
1.8.3.1
Tested-by on v1 1/1
#2 lore raw
Quoted 14 lines

-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Friday, June 16, 2023 3:30 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Wenjun1 <[email protected]>; [email protected]; Tyler Retzlaff <[email protected]>; [email protected]
Subject: [PATCH] net/ixgbe: fix inverted test and set conditional

Correct a mistake when converting ixgbe to use __atomic_test_and_set instead of rte_atomic32_test_and_set. The return value from __atomic_test_and_set is inverted relative to rte_atomic32_test_and_set.

Quoted 8 lines
Fixes e90baf6b82f6 ("net/ixgbe: replace legacy atomics with GCC builtin

atomics")
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---

Reviewed-by on v1 1/1
#3 lore raw
In reply to Tyler Retzlaff
Quoted 8 lines · Tyler Retzlaff

Correct a mistake when converting ixgbe to use __atomic_test_and_set instead of rte_atomic32_test_and_set. The return value from __atomic_test_and_set is inverted relative to rte_atomic32_test_and_set.

Fixes e90baf6b82f6 ("net/ixgbe: replace legacy atomics with GCC builtin atomics")

Thanks for the fix Tyler.

Signature · 1 line
David Marchand
#4 lore raw
Quoted 10 lines

From: David Marchand [mailto:[email protected]]
Sent: Monday, 19 June 2023 09.54

Quoted 5 lines · Tyler Retzlaff

Correct a mistake when converting ixgbe to use __atomic_test_and_set instead of rte_atomic32_test_and_set. The return value from __atomic_test_and_set is inverted relative to rte_atomic32_test_and_set.

Quoted 7 lines
Quoted 1 line
Fixes e90baf6b82f6 ("net/ixgbe: replace legacy atomics with GCC builtin

atomics")

Quoted 2 lines

Thanks for the fix Tyler.

rte_atomic32_test_and_set() returns the inverse of __atomic_test_and_set()!

We need to provide a prominent warning about this when deprecating rte_atomic32_test_and_set(), or everyone else will make the same mistake as Tyler, i.e. perform a simple search/replace with the new function name, not noticing that the function's return value is inverted. Perhaps we can also add some build time warning when using rte_atomic32_test_and_set()?

PS:
Tyler, the Solarflare driver also uses rte_atomic32_test_and_set(); maybe you missed in the original patch series.
https://elixir.bootlin.com/dpdk/v23.07-rc1/A/ident/rte_atomic32_test_and_set

#5 lore raw
Quoted 14 lines · Morten Brørup
Quoted 14 lines

From: David Marchand [mailto:[email protected]]
Sent: Monday, 19 June 2023 09.54

Quoted 6 lines · Tyler Retzlaff

Correct a mistake when converting ixgbe to use __atomic_test_and_set instead of rte_atomic32_test_and_set. The return value from __atomic_test_and_set is inverted relative to rte_atomic32_test_and_set.

Fixes e90baf6b82f6 ("net/ixgbe: replace legacy atomics with GCC builtin

atomics")

Quoted 2 lines
Quoted 8 lines
Quoted 3 lines

Thanks for the fix Tyler.

rte_atomic32_test_and_set() returns the inverse of __atomic_test_and_set()!

We need to provide a prominent warning about this when deprecating rte_atomic32_test_and_set(), or everyone else will make the same mistake as Tyler, i.e. perform a simple search/replace with the new function name, not noticing that the function's return value is inverted. Perhaps we can also add some build time warning when using rte_atomic32_test_and_set()?

i'll probably take care of this work myself after stdatomics (assuming it is something people want) and hopefully i won't make that mistake again. for now i don't want to confuse the dev list with too many patches about 'atomics' to avoid overload/confusion for david and thomas.

Quoted 3 lines

PS:
Tyler, the Solarflare driver also uses rte_atomic32_test_and_set(); maybe you missed in the original patch series.

it was intentionally skipped (for now). i only did the conversion for drivers that are built on windows. the assumption being the rte_atomicXX api deprecation is independent of switching to C11 stdatomic.

i don't intend to ever make available rte_atomicXX on msvc/windows combination since it is being deprecated. as mentioned above as i expand the code that is built for msvc/windows it will then force me to adapt more of the rte_atomicsXX code eventually leading to most of it being gone (at least for libraries).

Quoted 2 lines

https://elixir.bootlin.com/dpdk/v23.07-rc1/A/ident/rte_atomic32_test_and_set