Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] net: atlantic: aq_utils_obj_{set|clear} optimizations
@ 2026-06-02  9:29 Lei Zhu
  2026-06-02 20:18 ` kernel test robot
  2026-06-02 20:49 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Lei Zhu @ 2026-06-02  9:29 UTC (permalink / raw)
  To: kuba, sukhdeeps, davem, andrew+netdev; +Cc: netdev

From: Lei Zhu <zhulei@kylinos.cn>

Adopting atomic_try_cmpxchg() which is slightly more efficient.

Signed-off-by: Lei Zhu <zhulei@kylinos.cn>
---
 drivers/net/ethernet/aquantia/atlantic/aq_utils.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_utils.h b/drivers/net/ethernet/aquantia/atlantic/aq_utils.h
index d3a0b2ec0279..61cd08771385 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_utils.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_utils.h
@@ -15,20 +15,20 @@ static inline void aq_utils_obj_set(atomic_t *flags, u32 mask)
 {
 	unsigned long flags_old, flags_new;
 
+	flags_old = atomic_read(flags);
 	do {
-		flags_old = atomic_read(flags);
 		flags_new = flags_old | (mask);
-	} while (atomic_cmpxchg(flags, flags_old, flags_new) != flags_old);
+	} while (!atomic_try_cmpxchg(flags, &flags_old, flags_new));
 }
 
 static inline void aq_utils_obj_clear(atomic_t *flags, u32 mask)
 {
 	unsigned long flags_old, flags_new;
 
+	flags_old = atomic_read(flags);
 	do {
-		flags_old = atomic_read(flags);
 		flags_new = flags_old & ~(mask);
-	} while (atomic_cmpxchg(flags, flags_old, flags_new) != flags_old);
+	} while (!atomic_try_cmpxchg(flags, &flags_old, flags_new));
 }
 
 static inline bool aq_utils_obj_test(atomic_t *flags, u32 mask)
-- 
2.25.1


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

end of thread, other threads:[~2026-06-02 20:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-02  9:29 [PATCH net-next] net: atlantic: aq_utils_obj_{set|clear} optimizations Lei Zhu
2026-06-02 20:18 ` kernel test robot
2026-06-02 20:49 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox