DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 00/16] use __atomic operations returning new value
@ 2023-03-10 22:15 Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
                   ` (17 more replies)
  0 siblings, 18 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

This series replaces uses of __atomic_{add,and,or,sub,xor}_fetch with
__atomic_fetch_{add,and,or,sub,xor} intrinsics where the return value
is used.

This series is being separated from the other similar series in
an effort to reduce the chance of mistakes being spotted in review
since the usages in this case consume the returned / new value.

Tyler Retzlaff (16):
  app/test: use previous value atomic fetch operations
  common/cnxk: use previous value atomic fetch operations
  common/mlx5: use previous value atomic fetch operations
  drivers/event: use previous value atomic fetch operations
  net/af_xdp: use previous value atomic fetch operations
  net/cnxk: use previous value atomic fetch operations
  net/cxgbe: use previous value atomic fetch operations
  net/iavf: use previous value atomic fetch operations
  net/mlx5: use previous value atomic fetch operations
  net/octeontx: use previous value atomic fetch operations
  raw/ifpga: use previous value atomic fetch operations
  bbdev: use previous value atomic fetch operations
  eal: use previous value atomic fetch operations
  ipsec: use previous value atomic fetch operations
  mbuf: use previous value atomic fetch operations
  rcu: use previous value atomic fetch operations

 app/test/test_ring_perf.c               |  2 +-
 drivers/common/cnxk/roc_ae.c            |  2 +-
 drivers/common/cnxk/roc_ae_fpm_tables.c |  2 +-
 drivers/common/cnxk/roc_npa.c           |  2 +-
 drivers/common/mlx5/linux/mlx5_nl.c     |  2 +-
 drivers/common/mlx5/mlx5_common_mr.c    |  8 ++++----
 drivers/common/mlx5/mlx5_common_utils.c |  8 ++++----
 drivers/event/cnxk/cnxk_tim_worker.h    |  2 +-
 drivers/event/dsw/dsw_event.c           |  4 ++--
 drivers/event/octeontx/timvf_worker.h   |  2 +-
 drivers/net/af_xdp/rte_eth_af_xdp.c     |  4 ++--
 drivers/net/cnxk/cn10k_tx.h             |  4 ++--
 drivers/net/cxgbe/clip_tbl.c            |  2 +-
 drivers/net/cxgbe/mps_tcam.c            |  2 +-
 drivers/net/iavf/iavf_vchnl.c           |  8 ++++----
 drivers/net/mlx5/linux/mlx5_verbs.c     |  2 +-
 drivers/net/mlx5/mlx5.c                 |  4 ++--
 drivers/net/mlx5/mlx5_flow.c            |  8 ++++----
 drivers/net/mlx5/mlx5_flow_dv.c         | 12 ++++++------
 drivers/net/mlx5/mlx5_flow_hw.c         | 14 +++++++-------
 drivers/net/mlx5/mlx5_hws_cnt.c         |  4 ++--
 drivers/net/mlx5/mlx5_rxq.c             |  6 +++---
 drivers/net/mlx5/mlx5_txq.c             |  2 +-
 drivers/net/octeontx/octeontx_ethdev.c  |  2 +-
 drivers/raw/ifpga/ifpga_rawdev.c        |  2 +-
 lib/bbdev/rte_bbdev.c                   |  4 ++--
 lib/eal/include/generic/rte_rwlock.h    |  8 ++++----
 lib/eal/ppc/include/rte_atomic.h        | 16 ++++++++--------
 lib/ipsec/ipsec_sqn.h                   |  2 +-
 lib/mbuf/rte_mbuf.h                     | 12 ++++++------
 lib/rcu/rte_rcu_qsbr.h                  |  2 +-
 31 files changed, 77 insertions(+), 77 deletions(-)

-- 
1.8.3.1


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

* [PATCH 01/16] app/test: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 02/16] common/cnxk: " Tyler Retzlaff
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_ring_perf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 2d8bb67..3972fd9 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -186,7 +186,7 @@ struct thread_params {
 	void *burst = NULL;
 
 #ifdef RTE_USE_C11_MEM_MODEL
-	if (__atomic_add_fetch(&lcore_count, 1, __ATOMIC_RELAXED) != 2)
+	if (__atomic_fetch_add(&lcore_count, 1, __ATOMIC_RELAXED) + 1 != 2)
 #else
 	if (__sync_add_and_fetch(&lcore_count, 1) != 2)
 #endif
-- 
1.8.3.1


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

* [PATCH 02/16] common/cnxk: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 03/16] common/mlx5: " Tyler Retzlaff
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/common/cnxk/roc_ae.c            | 2 +-
 drivers/common/cnxk/roc_ae_fpm_tables.c | 2 +-
 drivers/common/cnxk/roc_npa.c           | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/common/cnxk/roc_ae.c b/drivers/common/cnxk/roc_ae.c
index 929da05..336b927 100644
--- a/drivers/common/cnxk/roc_ae.c
+++ b/drivers/common/cnxk/roc_ae.c
@@ -203,6 +203,6 @@ struct ae_ec_grp_tbl {
 
 	ec_grp = mz->addr;
 	/* Decrement number of devices using EC grp table */
-	if (__atomic_sub_fetch(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+	if (__atomic_fetch_sub(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
 		plt_memzone_free(mz);
 }
diff --git a/drivers/common/cnxk/roc_ae_fpm_tables.c b/drivers/common/cnxk/roc_ae_fpm_tables.c
index afb2a50..f915702 100644
--- a/drivers/common/cnxk/roc_ae_fpm_tables.c
+++ b/drivers/common/cnxk/roc_ae_fpm_tables.c
@@ -1135,6 +1135,6 @@ struct ae_fpm_tbl {
 
 	fpm = (struct ae_fpm_tbl *)mz->addr;
 	/* Decrement number of devices using FPM table */
-	if (__atomic_sub_fetch(&fpm->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+	if (__atomic_fetch_sub(&fpm->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
 		plt_memzone_free(mz);
 }
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 69c3d8d..20637fb 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -946,7 +946,7 @@
 		return NPA_ERR_ALLOC;
 
 	/* Not the last PCI device */
-	if (__atomic_sub_fetch(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) != 0)
+	if (__atomic_fetch_sub(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) - 1 != 0)
 		return 0;
 
 	npa_unregister_irqs(idev->npa);
-- 
1.8.3.1


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

* [PATCH 03/16] common/mlx5: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 02/16] common/cnxk: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 04/16] drivers/event: " Tyler Retzlaff
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/common/mlx5/linux/mlx5_nl.c     | 2 +-
 drivers/common/mlx5/mlx5_common_mr.c    | 8 ++++----
 drivers/common/mlx5/mlx5_common_utils.c | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c
index 5d04857..33670bb 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.c
+++ b/drivers/common/mlx5/linux/mlx5_nl.c
@@ -178,7 +178,7 @@ struct mlx5_nl_port_info {
 uint32_t atomic_sn;
 
 /* Generate Netlink sequence number. */
-#define MLX5_NL_SN_GENERATE __atomic_add_fetch(&atomic_sn, 1, __ATOMIC_RELAXED)
+#define MLX5_NL_SN_GENERATE (__atomic_fetch_add(&atomic_sn, 1, __ATOMIC_RELAXED) + 1)
 
 /**
  * Opens a Netlink socket.
diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c
index 0e1d243..037a4d8 100644
--- a/drivers/common/mlx5/mlx5_common_mr.c
+++ b/drivers/common/mlx5/mlx5_common_mr.c
@@ -58,8 +58,8 @@ struct mlx5_mempool_reg {
 
 	if (__atomic_load_n(&buf->refcnt, __ATOMIC_RELAXED) == 1) {
 		rte_mempool_put(buf->mp, buf);
-	} else if (unlikely(__atomic_sub_fetch(&buf->refcnt, 1,
-					       __ATOMIC_RELAXED) == 0)) {
+	} else if (unlikely(__atomic_fetch_sub(&buf->refcnt, 1,
+					       __ATOMIC_RELAXED) - 1 == 0)) {
 		__atomic_store_n(&buf->refcnt, 1, __ATOMIC_RELAXED);
 		rte_mempool_put(buf->mp, buf);
 	}
@@ -1665,8 +1665,8 @@ struct mlx5_mempool_get_extmem_data {
 	bool ret = false;
 
 	for (i = 0; i < mpr->mrs_n; i++)
-		ret |= __atomic_sub_fetch(&mpr->mrs[i].refcnt, 1,
-					  __ATOMIC_RELAXED) == 0;
+		ret |= __atomic_fetch_sub(&mpr->mrs[i].refcnt, 1,
+					  __ATOMIC_RELAXED) - 1 == 0;
 	return ret;
 }
 
diff --git a/drivers/common/mlx5/mlx5_common_utils.c b/drivers/common/mlx5/mlx5_common_utils.c
index 58d744b..06b5b9b 100644
--- a/drivers/common/mlx5/mlx5_common_utils.c
+++ b/drivers/common/mlx5/mlx5_common_utils.c
@@ -81,8 +81,8 @@ struct mlx5_list *
 	while (entry != NULL) {
 		if (l_const->cb_match(l_const->ctx, entry, ctx) == 0) {
 			if (reuse) {
-				ret = __atomic_add_fetch(&entry->ref_cnt, 1,
-							 __ATOMIC_RELAXED) - 1;
+				ret = __atomic_fetch_add(&entry->ref_cnt, 1,
+							 __ATOMIC_RELAXED);
 				DRV_LOG(DEBUG, "mlx5 list %s entry %p ref: %u.",
 					l_const->name, (void *)entry,
 					entry->ref_cnt);
@@ -285,7 +285,7 @@ struct mlx5_list_entry *
 {
 	struct mlx5_list_entry *gentry = entry->gentry;
 
-	if (__atomic_sub_fetch(&entry->ref_cnt, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_fetch_sub(&entry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0)
 		return 1;
 	if (entry->lcore_idx == (uint32_t)lcore_idx) {
 		LIST_REMOVE(entry, next);
@@ -303,7 +303,7 @@ struct mlx5_list_entry *
 			l_const->name, (void *)entry);
 		return 0;
 	}
-	if (__atomic_sub_fetch(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_fetch_sub(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0)
 		return 1;
 	rte_rwlock_write_lock(&l_inconst->lock);
 	if (likely(gentry->ref_cnt == 0)) {
-- 
1.8.3.1


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

* [PATCH 04/16] drivers/event: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (2 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 03/16] common/mlx5: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-13  7:02   ` [EXT] " Pavan Nikhilesh Bhagavatula
  2023-03-10 22:15 ` [PATCH 05/16] net/af_xdp: " Tyler Retzlaff
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/event/cnxk/cnxk_tim_worker.h  | 2 +-
 drivers/event/dsw/dsw_event.c         | 4 ++--
 drivers/event/octeontx/timvf_worker.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/event/cnxk/cnxk_tim_worker.h b/drivers/event/cnxk/cnxk_tim_worker.h
index a326d55..0bd66ec 100644
--- a/drivers/event/cnxk/cnxk_tim_worker.h
+++ b/drivers/event/cnxk/cnxk_tim_worker.h
@@ -123,7 +123,7 @@
 	const uint64_t v =
 		~(TIM_BUCKET_W1_M_NUM_ENTRIES << TIM_BUCKET_W1_S_NUM_ENTRIES);
 
-	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
+	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) & v;
 }
 
 static inline uint64_t
diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c
index 9932caf..cbdc03f 100644
--- a/drivers/event/dsw/dsw_event.c
+++ b/drivers/event/dsw/dsw_event.c
@@ -45,8 +45,8 @@
 	 * allocation.
 	 */
 	new_total_on_loan =
-	    __atomic_add_fetch(&dsw->credits_on_loan, acquired_credits,
-			       __ATOMIC_RELAXED);
+	    __atomic_fetch_add(&dsw->credits_on_loan, acquired_credits,
+			       __ATOMIC_RELAXED) + acquired_credits;
 
 	if (unlikely(new_total_on_loan > dsw->max_inflight)) {
 		/* Some other port took the last credits */
diff --git a/drivers/event/octeontx/timvf_worker.h b/drivers/event/octeontx/timvf_worker.h
index 3f1e77f..aa729f8 100644
--- a/drivers/event/octeontx/timvf_worker.h
+++ b/drivers/event/octeontx/timvf_worker.h
@@ -135,7 +135,7 @@
 {
 	const uint64_t v = ~(TIM_BUCKET_W1_M_NUM_ENTRIES <<
 			TIM_BUCKET_W1_S_NUM_ENTRIES);
-	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
+	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) & v;
 }
 
 static inline struct tim_mem_entry *
-- 
1.8.3.1


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

* [PATCH 05/16] net/af_xdp: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (3 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 04/16] drivers/event: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 06/16] net/cnxk: " Tyler Retzlaff
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 2a20a69..c7786cc 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -979,7 +979,7 @@ static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
 			break;
 		xsk_socket__delete(rxq->xsk);
 
-		if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE)
+		if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1
 				== 0) {
 			(void)xsk_umem__delete(rxq->umem->umem);
 			xdp_umem_destroy(rxq->umem);
@@ -1710,7 +1710,7 @@ struct msg_internal {
 out_xsk:
 	xsk_socket__delete(rxq->xsk);
 out_umem:
-	if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) == 0)
+	if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0)
 		xdp_umem_destroy(rxq->umem);
 
 	return ret;
-- 
1.8.3.1


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

* [PATCH 06/16] net/cnxk: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (4 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 05/16] net/af_xdp: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-13  6:45   ` [EXT] " Nithin Kumar Dabilpuram
  2023-03-10 22:15 ` [PATCH 07/16] net/cxgbe: " Tyler Retzlaff
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/cnxk/cn10k_tx.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/cnxk/cn10k_tx.h b/drivers/net/cnxk/cn10k_tx.h
index a72a803..c9ec01c 100644
--- a/drivers/net/cnxk/cn10k_tx.h
+++ b/drivers/net/cnxk/cn10k_tx.h
@@ -108,7 +108,7 @@
 retry:
 	while (__atomic_load_n(&txq->fc_cache_pkts, __ATOMIC_RELAXED) < 0)
 		;
-	cached = __atomic_sub_fetch(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE);
+	cached = __atomic_fetch_sub(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE) - req;
 	/* Check if there is enough space, else update and retry. */
 	if (cached < 0) {
 		/* Check if we have space else retry. */
@@ -302,7 +302,7 @@
 
 again:
 	fc_sw = txq->cpt_fc_sw;
-	val = __atomic_sub_fetch(fc_sw, nb_pkts, __ATOMIC_RELAXED);
+	val = __atomic_fetch_sub(fc_sw, nb_pkts, __ATOMIC_RELAXED) - nb_pkts;
 	if (likely(val >= 0))
 		return;
 
-- 
1.8.3.1


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

* [PATCH 07/16] net/cxgbe: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (5 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 06/16] net/cnxk: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 08/16] net/iavf: " Tyler Retzlaff
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/cxgbe/clip_tbl.c | 2 +-
 drivers/net/cxgbe/mps_tcam.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/cxgbe/clip_tbl.c b/drivers/net/cxgbe/clip_tbl.c
index 072fc74..f64b922 100644
--- a/drivers/net/cxgbe/clip_tbl.c
+++ b/drivers/net/cxgbe/clip_tbl.c
@@ -55,7 +55,7 @@ void cxgbe_clip_release(struct rte_eth_dev *dev, struct clip_entry *ce)
 	int ret;
 
 	t4_os_lock(&ce->lock);
-	if (__atomic_sub_fetch(&ce->refcnt, 1, __ATOMIC_RELAXED) == 0) {
+	if (__atomic_fetch_sub(&ce->refcnt, 1, __ATOMIC_RELAXED) - 1 == 0) {
 		ret = clip6_release_mbox(dev, ce->addr);
 		if (ret)
 			dev_debug(adap, "CLIP FW DEL CMD failed: %d", ret);
diff --git a/drivers/net/cxgbe/mps_tcam.c b/drivers/net/cxgbe/mps_tcam.c
index abbf06e..c7cdf29 100644
--- a/drivers/net/cxgbe/mps_tcam.c
+++ b/drivers/net/cxgbe/mps_tcam.c
@@ -195,7 +195,7 @@ int cxgbe_mpstcam_remove(struct port_info *pi, u16 idx)
 					   entry->mask, idx, 1, pi->port_id,
 					   false);
 	else
-		ret = __atomic_sub_fetch(&entry->refcnt, 1, __ATOMIC_RELAXED);
+		ret = __atomic_fetch_sub(&entry->refcnt, 1, __ATOMIC_RELAXED) - 1;
 
 	if (ret == 0) {
 		reset_mpstcam_entry(entry);
-- 
1.8.3.1


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

* [PATCH 08/16] net/iavf: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (6 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 07/16] net/cxgbe: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 09/16] net/mlx5: " Tyler Retzlaff
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/iavf/iavf_vchnl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 9adaadb..51d4fc7 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -120,7 +120,7 @@ struct iavf_event_handler {
 {
 	struct iavf_event_handler *handler = &event_handler;
 
-	if (__atomic_add_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 1)
+	if (__atomic_fetch_add(&handler->ndev, 1, __ATOMIC_RELAXED) + 1 != 1)
 		return 0;
 #if defined(RTE_EXEC_ENV_IS_WINDOWS) && RTE_EXEC_ENV_IS_WINDOWS != 0
 	int err = _pipe(handler->fd, MAX_EVENT_PENDING, O_BINARY);
@@ -149,7 +149,7 @@ struct iavf_event_handler {
 {
 	struct iavf_event_handler *handler = &event_handler;
 
-	if (__atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED) - 1 != 0)
 		return;
 
 	int unused = pthread_cancel(handler->tid);
@@ -533,8 +533,8 @@ struct iavf_event_handler {
 				/* read message and it's expected one */
 				if (msg_opc == vf->pend_cmd) {
 					uint32_t cmd_count =
-					__atomic_sub_fetch(&vf->pend_cmd_count,
-							1, __ATOMIC_RELAXED);
+					__atomic_fetch_sub(&vf->pend_cmd_count,
+							1, __ATOMIC_RELAXED) - 1;
 					if (cmd_count == 0)
 						_notify_cmd(vf, msg_ret);
 				} else {
-- 
1.8.3.1


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

* [PATCH 09/16] net/mlx5: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (7 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 08/16] net/iavf: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 10/16] net/octeontx: " Tyler Retzlaff
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/mlx5/linux/mlx5_verbs.c |  2 +-
 drivers/net/mlx5/mlx5.c             |  4 ++--
 drivers/net/mlx5/mlx5_flow.c        |  8 ++++----
 drivers/net/mlx5/mlx5_flow_dv.c     | 12 ++++++------
 drivers/net/mlx5/mlx5_flow_hw.c     | 14 +++++++-------
 drivers/net/mlx5/mlx5_hws_cnt.c     |  4 ++--
 drivers/net/mlx5/mlx5_rxq.c         |  6 +++---
 drivers/net/mlx5/mlx5_txq.c         |  2 +-
 8 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 67a7bec..ee5d072 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -1183,7 +1183,7 @@
 	if (!priv->lb_used)
 		return;
 	MLX5_ASSERT(__atomic_load_n(&sh->self_lb.refcnt, __ATOMIC_RELAXED));
-	if (!(__atomic_sub_fetch(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED))) {
+	if (!(__atomic_fetch_sub(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED) - 1)) {
 		if (sh->self_lb.qp) {
 			claim_zero(mlx5_glue->destroy_qp(sh->self_lb.qp));
 			sh->self_lb.qp = NULL;
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 41b1b12..044012d 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1068,7 +1068,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 		DRV_LOG(ERR, "Dynamic flex parser is not supported");
 		return -ENOTSUP;
 	}
-	if (__atomic_add_fetch(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) > 1)
+	if (__atomic_fetch_add(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) + 1 > 1)
 		return 0;
 
 	node.header_length_mode = MLX5_GRAPH_NODE_LEN_FIELD;
@@ -1123,7 +1123,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_internal_flex_parser_profile *fp = &priv->sh->srh_flex_parser;
 
-	if (__atomic_sub_fetch(&fp->refcnt, 1, __ATOMIC_RELAXED))
+	if (__atomic_fetch_sub(&fp->refcnt, 1, __ATOMIC_RELAXED) - 1)
 		return;
 	if (fp->fp)
 		mlx5_devx_cmd_destroy(fp->fp);
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 75f7d87..0bf527e 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -7833,7 +7833,7 @@ struct rte_flow *
 
 		tunnel = mlx5_find_tunnel_id(dev, flow->tunnel_id);
 		RTE_VERIFY(tunnel);
-		if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+		if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
 			mlx5_flow_tunnel_free(dev, tunnel);
 	}
 	flow_mreg_del_copy_action(dev, flow);
@@ -9742,9 +9742,9 @@ struct mlx5_flow_workspace*
 					 __ATOMIC_RELAXED);
 			continue;
 		}
-		if (__atomic_add_fetch(&age_param->sec_since_last_hit,
+		if (__atomic_fetch_add(&age_param->sec_since_last_hit,
 				       time_delta,
-				       __ATOMIC_RELAXED) <= age_param->timeout)
+				       __ATOMIC_RELAXED) + time_delta <= age_param->timeout)
 			continue;
 		/**
 		 * Hold the lock first, or if between the
@@ -11387,7 +11387,7 @@ struct tunnel_db_element_release_ctx {
 {
 	struct tunnel_db_element_release_ctx *ctx = x;
 	ctx->ret = 0;
-	if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+	if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
 		mlx5_flow_tunnel_free(dev, tunnel);
 }
 
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ca26f39..f04160e 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -6723,8 +6723,8 @@ struct mlx5_list_entry *
 		 * indirect action API, shared info is 1 before the reduction,
 		 * so this condition is failed and function doesn't return here.
 		 */
-		if (__atomic_sub_fetch(&cnt->shared_info.refcnt, 1,
-				       __ATOMIC_RELAXED))
+		if (__atomic_fetch_sub(&cnt->shared_info.refcnt, 1,
+				       __ATOMIC_RELAXED) - 1)
 			return;
 	}
 	cnt->pool = pool;
@@ -12797,7 +12797,7 @@ struct mlx5_list_entry *
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_aso_age_mng *mng = priv->sh->aso_age_mng;
 	struct mlx5_aso_age_action *age = flow_aso_age_get_by_idx(dev, age_idx);
-	uint32_t ret = __atomic_sub_fetch(&age->refcnt, 1, __ATOMIC_RELAXED);
+	uint32_t ret = __atomic_fetch_sub(&age->refcnt, 1, __ATOMIC_RELAXED) - 1;
 
 	if (!ret) {
 		flow_dv_aso_age_remove_from_age(dev, age);
@@ -13193,7 +13193,7 @@ struct mlx5_list_entry *
 	/* Cannot release when CT is in the ASO SQ. */
 	if (state == ASO_CONNTRACK_WAIT || state == ASO_CONNTRACK_QUERY)
 		return -1;
-	ret = __atomic_sub_fetch(&ct->refcnt, 1, __ATOMIC_RELAXED);
+	ret = __atomic_fetch_sub(&ct->refcnt, 1, __ATOMIC_RELAXED) - 1;
 	if (!ret) {
 		if (ct->dr_action_orig) {
 #ifdef HAVE_MLX5_DR_ACTION_ASO_CT
@@ -15582,8 +15582,8 @@ struct mlx5_list_entry *
 				sh->geneve_tlv_option_resource;
 	rte_spinlock_lock(&sh->geneve_tlv_opt_sl);
 	if (geneve_opt_resource) {
-		if (!(__atomic_sub_fetch(&geneve_opt_resource->refcnt, 1,
-					 __ATOMIC_RELAXED))) {
+		if (!(__atomic_fetch_sub(&geneve_opt_resource->refcnt, 1,
+					 __ATOMIC_RELAXED) - 1)) {
 			claim_zero(mlx5_devx_cmd_destroy
 					(geneve_opt_resource->obj));
 			mlx5_free(sh->geneve_tlv_option_resource);
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 9392727..109aab1 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -458,7 +458,7 @@ static int flow_hw_translate_group(struct rte_eth_dev *dev,
 	}
 
 	if (acts->mark)
-		if (!__atomic_sub_fetch(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED))
+		if (!(__atomic_fetch_sub(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED) - 1))
 			flow_hw_rxq_flag_set(dev, false);
 
 	if (acts->jump) {
@@ -3268,8 +3268,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
 			rte_errno = EINVAL;
 			goto it_error;
 		}
-		ret = __atomic_add_fetch(&item_templates[i]->refcnt, 1,
-					 __ATOMIC_RELAXED);
+		ret = __atomic_fetch_add(&item_templates[i]->refcnt, 1,
+					 __ATOMIC_RELAXED) + 1;
 		if (ret <= 1) {
 			rte_errno = EINVAL;
 			goto it_error;
@@ -3282,8 +3282,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
 	for (i = 0; i < nb_action_templates; i++) {
 		uint32_t ret;
 
-		ret = __atomic_add_fetch(&action_templates[i]->refcnt, 1,
-					 __ATOMIC_RELAXED);
+		ret = __atomic_fetch_add(&action_templates[i]->refcnt, 1,
+					 __ATOMIC_RELAXED) + 1;
 		if (ret <= 1) {
 			rte_errno = EINVAL;
 			goto at_error;
@@ -7624,8 +7624,8 @@ void flow_hw_clear_tags_set(struct rte_eth_dev *dev)
 {
 	uint32_t refcnt;
 
-	refcnt = __atomic_sub_fetch(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
-				    __ATOMIC_RELAXED);
+	refcnt = __atomic_fetch_sub(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
+				    __ATOMIC_RELAXED) - 1;
 	if (refcnt > 0)
 		return;
 	mlx5_flow_hw_flow_metadata_esw_en = 0;
diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c
index d6a017a..d98df68 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.c
+++ b/drivers/net/mlx5/mlx5_hws_cnt.c
@@ -192,8 +192,8 @@
 			}
 			param->accumulator_hits = 0;
 		}
-		if (__atomic_add_fetch(&param->sec_since_last_hit, time_delta,
-				       __ATOMIC_RELAXED) <=
+		if (__atomic_fetch_add(&param->sec_since_last_hit, time_delta,
+				       __ATOMIC_RELAXED) + time_delta <=
 		   __atomic_load_n(&param->timeout, __ATOMIC_RELAXED))
 			continue;
 		/* Prepare the relevant ring for this AGE parameter */
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 6e99c4d..ad8fd13 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2042,7 +2042,7 @@ struct mlx5_rxq_priv *
 
 	if (rxq == NULL)
 		return 0;
-	return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+	return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
 }
 
 /**
@@ -2141,7 +2141,7 @@ struct mlx5_external_rxq *
 {
 	struct mlx5_external_rxq *rxq = mlx5_ext_rxq_get(dev, idx);
 
-	return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+	return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
 }
 
 /**
@@ -2462,7 +2462,7 @@ struct mlx5_ind_table_obj *
 	unsigned int ret;
 
 	rte_rwlock_write_lock(&priv->ind_tbls_lock);
-	ret = __atomic_sub_fetch(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
+	ret = __atomic_fetch_sub(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED) - 1;
 	if (!ret)
 		LIST_REMOVE(ind_tbl, next);
 	rte_rwlock_write_unlock(&priv->ind_tbls_lock);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 1e0e61a..8cb52b0 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -1203,7 +1203,7 @@ struct mlx5_txq_ctrl *
 	if (priv->txqs == NULL || (*priv->txqs)[idx] == NULL)
 		return 0;
 	txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
-	if (__atomic_sub_fetch(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) > 1)
+	if (__atomic_fetch_sub(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) - 1 > 1)
 		return 1;
 	if (txq_ctrl->obj) {
 		priv->obj_ops.txq_obj_release(txq_ctrl->obj);
-- 
1.8.3.1


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

* [PATCH 10/16] net/octeontx: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (8 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 09/16] net/mlx5: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 11/16] raw/ifpga: " Tyler Retzlaff
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/octeontx/octeontx_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index d52a3e7..a21ed80 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -559,7 +559,7 @@ enum octeontx_link_speed {
 		return 0;
 
 	/* Stopping/closing event device once all eth ports are closed. */
-	if (__atomic_sub_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) == 0) {
+	if (__atomic_fetch_sub(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0) {
 		rte_event_dev_stop(nic->evdev);
 		rte_event_dev_close(nic->evdev);
 	}
-- 
1.8.3.1


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

* [PATCH 11/16] raw/ifpga: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (9 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 10/16] net/octeontx: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 12/16] bbdev: " Tyler Retzlaff
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 1020adc..ae3f79d 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -573,7 +573,7 @@ static int set_surprise_link_check_aer(
 
 	dev->poll_enabled = 0;
 
-	if (!__atomic_sub_fetch(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) &&
+	if (!(__atomic_fetch_sub(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) - 1) &&
 		ifpga_monitor_start_thread) {
 		ret = pthread_cancel(ifpga_monitor_start_thread);
 		if (ret)
-- 
1.8.3.1


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

* [PATCH 12/16] bbdev: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (10 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 11/16] raw/ifpga: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 13/16] eal: " Tyler Retzlaff
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/bbdev/rte_bbdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c
index 1521cdb..9df0837 100644
--- a/lib/bbdev/rte_bbdev.c
+++ b/lib/bbdev/rte_bbdev.c
@@ -250,8 +250,8 @@ struct rte_bbdev *
 	}
 
 	/* clear shared BBDev Data if no process is using the device anymore */
-	if (__atomic_sub_fetch(&bbdev->data->process_cnt, 1,
-			      __ATOMIC_RELAXED) == 0)
+	if (__atomic_fetch_sub(&bbdev->data->process_cnt, 1,
+			      __ATOMIC_RELAXED) - 1 == 0)
 		memset(bbdev->data, 0, sizeof(*bbdev->data));
 
 	memset(bbdev, 0, sizeof(*bbdev));
-- 
1.8.3.1


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

* [PATCH 13/16] eal: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (11 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 12/16] bbdev: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 14/16] ipsec: " Tyler Retzlaff
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/include/generic/rte_rwlock.h |  8 ++++----
 lib/eal/ppc/include/rte_atomic.h     | 16 ++++++++--------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/eal/include/generic/rte_rwlock.h b/lib/eal/include/generic/rte_rwlock.h
index d45c22c..71e2d8d 100644
--- a/lib/eal/include/generic/rte_rwlock.h
+++ b/lib/eal/include/generic/rte_rwlock.h
@@ -97,8 +97,8 @@
 			rte_pause();
 
 		/* Try to get read lock */
-		x = __atomic_add_fetch(&rwl->cnt, RTE_RWLOCK_READ,
-				       __ATOMIC_ACQUIRE);
+		x = __atomic_fetch_add(&rwl->cnt, RTE_RWLOCK_READ,
+				       __ATOMIC_ACQUIRE) + RTE_RWLOCK_READ;
 
 		/* If no writer, then acquire was successful */
 		if (likely(!(x & RTE_RWLOCK_MASK)))
@@ -134,8 +134,8 @@
 		return -EBUSY;
 
 	/* Try to get read lock */
-	x = __atomic_add_fetch(&rwl->cnt, RTE_RWLOCK_READ,
-			       __ATOMIC_ACQUIRE);
+	x = __atomic_fetch_add(&rwl->cnt, RTE_RWLOCK_READ,
+			       __ATOMIC_ACQUIRE) + RTE_RWLOCK_READ;
 
 	/* Back out if writer raced in */
 	if (unlikely(x & RTE_RWLOCK_MASK)) {
diff --git a/lib/eal/ppc/include/rte_atomic.h b/lib/eal/ppc/include/rte_atomic.h
index 663b4d3..ffabd98 100644
--- a/lib/eal/ppc/include/rte_atomic.h
+++ b/lib/eal/ppc/include/rte_atomic.h
@@ -71,12 +71,12 @@ static inline int rte_atomic16_test_and_set(rte_atomic16_t *v)
 
 static inline int rte_atomic16_inc_and_test(rte_atomic16_t *v)
 {
-	return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0;
 }
 
 static inline int rte_atomic16_dec_and_test(rte_atomic16_t *v)
 {
-	return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0;
 }
 
 static inline uint16_t
@@ -113,12 +113,12 @@ static inline int rte_atomic32_test_and_set(rte_atomic32_t *v)
 
 static inline int rte_atomic32_inc_and_test(rte_atomic32_t *v)
 {
-	return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0;
 }
 
 static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)
 {
-	return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0;
 }
 
 static inline uint32_t
@@ -181,23 +181,23 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)
 static inline int64_t
 rte_atomic64_add_return(rte_atomic64_t *v, int64_t inc)
 {
-	return __atomic_add_fetch(&v->cnt, inc, __ATOMIC_ACQUIRE);
+	return __atomic_fetch_add(&v->cnt, inc, __ATOMIC_ACQUIRE) + inc;
 }
 
 static inline int64_t
 rte_atomic64_sub_return(rte_atomic64_t *v, int64_t dec)
 {
-	return __atomic_sub_fetch(&v->cnt, dec, __ATOMIC_ACQUIRE);
+	return __atomic_fetch_sub(&v->cnt, dec, __ATOMIC_ACQUIRE) - dec;
 }
 
 static inline int rte_atomic64_inc_and_test(rte_atomic64_t *v)
 {
-	return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0;
 }
 
 static inline int rte_atomic64_dec_and_test(rte_atomic64_t *v)
 {
-	return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0;
 }
 
 static inline int rte_atomic64_test_and_set(rte_atomic64_t *v)
-- 
1.8.3.1


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

* [PATCH 14/16] ipsec: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (12 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 13/16] eal: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 15/16] mbuf: " Tyler Retzlaff
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/ipsec/ipsec_sqn.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ipsec/ipsec_sqn.h b/lib/ipsec/ipsec_sqn.h
index 2636cb1..505950e 100644
--- a/lib/ipsec/ipsec_sqn.h
+++ b/lib/ipsec/ipsec_sqn.h
@@ -128,7 +128,7 @@
 
 	n = *num;
 	if (SQN_ATOMIC(sa))
-		sqn = __atomic_add_fetch(&sa->sqn.outb, n, __ATOMIC_RELAXED);
+		sqn = __atomic_fetch_add(&sa->sqn.outb, n, __ATOMIC_RELAXED) + n;
 	else {
 		sqn = sa->sqn.outb + n;
 		sa->sqn.outb = sqn;
-- 
1.8.3.1


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

* [PATCH 15/16] mbuf: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (13 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 14/16] ipsec: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-10 22:15 ` [PATCH 16/16] rcu: " Tyler Retzlaff
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/mbuf/rte_mbuf.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
index 3a82eb1..5da4cbe 100644
--- a/lib/mbuf/rte_mbuf.h
+++ b/lib/mbuf/rte_mbuf.h
@@ -381,8 +381,8 @@ struct rte_pktmbuf_pool_private {
 static inline uint16_t
 __rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value)
 {
-	return __atomic_add_fetch(&m->refcnt, (uint16_t)value,
-				 __ATOMIC_ACQ_REL);
+	return __atomic_fetch_add(&m->refcnt, (uint16_t)value,
+				 __ATOMIC_ACQ_REL) + (uint16_t)value;
 }
 
 /**
@@ -502,8 +502,8 @@ struct rte_pktmbuf_pool_private {
 		return (uint16_t)value;
 	}
 
-	return __atomic_add_fetch(&shinfo->refcnt, (uint16_t)value,
-				 __ATOMIC_ACQ_REL);
+	return __atomic_fetch_add(&shinfo->refcnt, (uint16_t)value,
+				 __ATOMIC_ACQ_REL) + (uint16_t)value;
 }
 
 /** Mbuf prefetch */
@@ -1315,8 +1315,8 @@ static inline int __rte_pktmbuf_pinned_extbuf_decref(struct rte_mbuf *m)
 	 * Direct usage of add primitive to avoid
 	 * duplication of comparing with one.
 	 */
-	if (likely(__atomic_add_fetch(&shinfo->refcnt, (uint16_t)-1,
-				     __ATOMIC_ACQ_REL)))
+	if (likely(__atomic_fetch_add(&shinfo->refcnt, (uint16_t)-1,
+				     __ATOMIC_ACQ_REL) + (uint16_t)-1))
 		return 1;
 
 	/* Reinitialize counter before mbuf freeing. */
-- 
1.8.3.1


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

* [PATCH 16/16] rcu: use previous value atomic fetch operations
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (14 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 15/16] mbuf: " Tyler Retzlaff
@ 2023-03-10 22:15 ` Tyler Retzlaff
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-10 22:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/rcu/rte_rcu_qsbr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h
index ccae5d5..1aa078e 100644
--- a/lib/rcu/rte_rcu_qsbr.h
+++ b/lib/rcu/rte_rcu_qsbr.h
@@ -462,7 +462,7 @@ struct rte_rcu_qsbr_dq_parameters {
 	 * structure are visible to the workers before the token
 	 * update is visible.
 	 */
-	t = __atomic_add_fetch(&v->token, 1, __ATOMIC_RELEASE);
+	t = __atomic_fetch_add(&v->token, 1, __ATOMIC_RELEASE) + 1;
 
 	return t;
 }
-- 
1.8.3.1


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

* RE: [EXT] [PATCH 06/16] net/cnxk: use previous value atomic fetch operations
  2023-03-10 22:15 ` [PATCH 06/16] net/cnxk: " Tyler Retzlaff
@ 2023-03-13  6:45   ` Nithin Kumar Dabilpuram
  0 siblings, 0 replies; 59+ messages in thread
From: Nithin Kumar Dabilpuram @ 2023-03-13  6:45 UTC (permalink / raw)
  To: Tyler Retzlaff, dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas

Acked-by:  Nithin Dabilpuram <ndabilpuram@marvell.com>

> -----Original Message-----
> From: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Sent: Saturday, March 11, 2023 3:45 AM
> To: dev@dpdk.org
> Cc: Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com; thomas@monjalon.net;
> Tyler Retzlaff <roretzla@linux.microsoft.com>
> Subject: [EXT] [PATCH 06/16] net/cnxk: use previous value atomic fetch operations
> 
> External Email
> 
> ----------------------------------------------------------------------
> Use __atomic_fetch_{add,and,or,sub,xor} instead of
> __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
> allow consumption of the resulting value.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  drivers/net/cnxk/cn10k_tx.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/cnxk/cn10k_tx.h b/drivers/net/cnxk/cn10k_tx.h
> index a72a803..c9ec01c 100644
> --- a/drivers/net/cnxk/cn10k_tx.h
> +++ b/drivers/net/cnxk/cn10k_tx.h
> @@ -108,7 +108,7 @@
>  retry:
>  	while (__atomic_load_n(&txq->fc_cache_pkts, __ATOMIC_RELAXED) < 0)
>  		;
> -	cached = __atomic_sub_fetch(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE);
> +	cached = __atomic_fetch_sub(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE) -
> req;
>  	/* Check if there is enough space, else update and retry. */
>  	if (cached < 0) {
>  		/* Check if we have space else retry. */
> @@ -302,7 +302,7 @@
> 
>  again:
>  	fc_sw = txq->cpt_fc_sw;
> -	val = __atomic_sub_fetch(fc_sw, nb_pkts, __ATOMIC_RELAXED);
> +	val = __atomic_fetch_sub(fc_sw, nb_pkts, __ATOMIC_RELAXED) - nb_pkts;
>  	if (likely(val >= 0))
>  		return;
> 
> --
> 1.8.3.1


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

* RE: [EXT] [PATCH 04/16] drivers/event: use previous value atomic fetch operations
  2023-03-10 22:15 ` [PATCH 04/16] drivers/event: " Tyler Retzlaff
@ 2023-03-13  7:02   ` Pavan Nikhilesh Bhagavatula
  0 siblings, 0 replies; 59+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2023-03-13  7:02 UTC (permalink / raw)
  To: Tyler Retzlaff, dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas



> -----Original Message-----
> From: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Sent: Saturday, March 11, 2023 3:45 AM
> To: dev@dpdk.org
> Cc: Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> thomas@monjalon.net; Tyler Retzlaff <roretzla@linux.microsoft.com>
> Subject: [EXT] [PATCH 04/16] drivers/event: use previous value atomic fetch
> operations
> 
> External Email
> 
> ----------------------------------------------------------------------
> Use __atomic_fetch_{add,and,or,sub,xor} instead of
> __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
> allow consumption of the resulting value.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>

> ---
>  drivers/event/cnxk/cnxk_tim_worker.h  | 2 +-
>  drivers/event/dsw/dsw_event.c         | 4 ++--
>  drivers/event/octeontx/timvf_worker.h | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/event/cnxk/cnxk_tim_worker.h
> b/drivers/event/cnxk/cnxk_tim_worker.h
> index a326d55..0bd66ec 100644
> --- a/drivers/event/cnxk/cnxk_tim_worker.h
> +++ b/drivers/event/cnxk/cnxk_tim_worker.h
> @@ -123,7 +123,7 @@
>  	const uint64_t v =
>  		~(TIM_BUCKET_W1_M_NUM_ENTRIES <<
> TIM_BUCKET_W1_S_NUM_ENTRIES);
> 
> -	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
> +	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) &
> v;
>  }
> 
>  static inline uint64_t
> diff --git a/drivers/event/dsw/dsw_event.c
> b/drivers/event/dsw/dsw_event.c
> index 9932caf..cbdc03f 100644
> --- a/drivers/event/dsw/dsw_event.c
> +++ b/drivers/event/dsw/dsw_event.c
> @@ -45,8 +45,8 @@
>  	 * allocation.
>  	 */
>  	new_total_on_loan =
> -	    __atomic_add_fetch(&dsw->credits_on_loan, acquired_credits,
> -			       __ATOMIC_RELAXED);
> +	    __atomic_fetch_add(&dsw->credits_on_loan, acquired_credits,
> +			       __ATOMIC_RELAXED) + acquired_credits;
> 
>  	if (unlikely(new_total_on_loan > dsw->max_inflight)) {
>  		/* Some other port took the last credits */
> diff --git a/drivers/event/octeontx/timvf_worker.h
> b/drivers/event/octeontx/timvf_worker.h
> index 3f1e77f..aa729f8 100644
> --- a/drivers/event/octeontx/timvf_worker.h
> +++ b/drivers/event/octeontx/timvf_worker.h
> @@ -135,7 +135,7 @@
>  {
>  	const uint64_t v = ~(TIM_BUCKET_W1_M_NUM_ENTRIES <<
>  			TIM_BUCKET_W1_S_NUM_ENTRIES);
> -	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
> +	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) &
> v;
>  }
> 
>  static inline struct tim_mem_entry *
> --
> 1.8.3.1


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

* [PATCH v2 00/16] replace __atomic operations returning new value
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (15 preceding siblings ...)
  2023-03-10 22:15 ` [PATCH 16/16] rcu: " Tyler Retzlaff
@ 2023-03-15 21:15 ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
                     ` (17 more replies)
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
  17 siblings, 18 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

This series replaces uses of __atomic_{add,and,or,sub,xor}_fetch with
__atomic_fetch_{add,and,or,sub,xor} intrinsics where the new value
is used.

This series is being separated from the other similar series in
an effort to reduce the chance of mistakes being spotted in review
since the usages in this case consume the returned / new value.

v2:
    * remove unnecessary casts of signed to unsigned arguments when
      using generic __atomic builtins.
    * remove inappropriate cast of signed negative value on addend.

Tyler Retzlaff (16):
  app/test: use previous value atomic fetch operations
  common/cnxk: use previous value atomic fetch operations
  common/mlx5: use previous value atomic fetch operations
  drivers/event: use previous value atomic fetch operations
  net/af_xdp: use previous value atomic fetch operations
  net/cnxk: use previous value atomic fetch operations
  net/cxgbe: use previous value atomic fetch operations
  net/iavf: use previous value atomic fetch operations
  net/mlx5: use previous value atomic fetch operations
  net/octeontx: use previous value atomic fetch operations
  raw/ifpga: use previous value atomic fetch operations
  bbdev: use previous value atomic fetch operations
  eal: use previous value atomic fetch operations
  ipsec: use previous value atomic fetch operations
  mbuf: use previous value atomic fetch operations
  rcu: use previous value atomic fetch operations

 app/test/test_ring_perf.c               |  2 +-
 drivers/common/cnxk/roc_ae.c            |  2 +-
 drivers/common/cnxk/roc_ae_fpm_tables.c |  2 +-
 drivers/common/cnxk/roc_npa.c           |  2 +-
 drivers/common/mlx5/linux/mlx5_nl.c     |  2 +-
 drivers/common/mlx5/mlx5_common_mr.c    |  8 ++++----
 drivers/common/mlx5/mlx5_common_utils.c |  8 ++++----
 drivers/event/cnxk/cnxk_tim_worker.h    |  2 +-
 drivers/event/dsw/dsw_event.c           |  4 ++--
 drivers/event/octeontx/timvf_worker.h   |  2 +-
 drivers/net/af_xdp/rte_eth_af_xdp.c     |  4 ++--
 drivers/net/cnxk/cn10k_tx.h             |  4 ++--
 drivers/net/cxgbe/clip_tbl.c            |  2 +-
 drivers/net/cxgbe/mps_tcam.c            |  2 +-
 drivers/net/iavf/iavf_vchnl.c           |  8 ++++----
 drivers/net/mlx5/linux/mlx5_verbs.c     |  2 +-
 drivers/net/mlx5/mlx5.c                 |  4 ++--
 drivers/net/mlx5/mlx5_flow.c            |  8 ++++----
 drivers/net/mlx5/mlx5_flow_dv.c         | 12 ++++++------
 drivers/net/mlx5/mlx5_flow_hw.c         | 14 +++++++-------
 drivers/net/mlx5/mlx5_hws_cnt.c         |  4 ++--
 drivers/net/mlx5/mlx5_rxq.c             |  6 +++---
 drivers/net/mlx5/mlx5_txq.c             |  2 +-
 drivers/net/octeontx/octeontx_ethdev.c  |  2 +-
 drivers/raw/ifpga/ifpga_rawdev.c        |  2 +-
 lib/bbdev/rte_bbdev.c                   |  4 ++--
 lib/eal/include/generic/rte_rwlock.h    |  8 ++++----
 lib/eal/ppc/include/rte_atomic.h        | 16 ++++++++--------
 lib/ipsec/ipsec_sqn.h                   |  2 +-
 lib/mbuf/rte_mbuf.h                     | 12 ++++++------
 lib/rcu/rte_rcu_qsbr.h                  |  2 +-
 31 files changed, 77 insertions(+), 77 deletions(-)

-- 
1.8.3.1


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

* [PATCH v2 01/16] app/test: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 02/16] common/cnxk: " Tyler Retzlaff
                     ` (16 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_ring_perf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 2d8bb67..3972fd9 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -186,7 +186,7 @@ struct thread_params {
 	void *burst = NULL;
 
 #ifdef RTE_USE_C11_MEM_MODEL
-	if (__atomic_add_fetch(&lcore_count, 1, __ATOMIC_RELAXED) != 2)
+	if (__atomic_fetch_add(&lcore_count, 1, __ATOMIC_RELAXED) + 1 != 2)
 #else
 	if (__sync_add_and_fetch(&lcore_count, 1) != 2)
 #endif
-- 
1.8.3.1


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

* [PATCH v2 02/16] common/cnxk: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 03/16] common/mlx5: " Tyler Retzlaff
                     ` (15 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/common/cnxk/roc_ae.c            | 2 +-
 drivers/common/cnxk/roc_ae_fpm_tables.c | 2 +-
 drivers/common/cnxk/roc_npa.c           | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/common/cnxk/roc_ae.c b/drivers/common/cnxk/roc_ae.c
index 929da05..336b927 100644
--- a/drivers/common/cnxk/roc_ae.c
+++ b/drivers/common/cnxk/roc_ae.c
@@ -203,6 +203,6 @@ struct ae_ec_grp_tbl {
 
 	ec_grp = mz->addr;
 	/* Decrement number of devices using EC grp table */
-	if (__atomic_sub_fetch(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+	if (__atomic_fetch_sub(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
 		plt_memzone_free(mz);
 }
diff --git a/drivers/common/cnxk/roc_ae_fpm_tables.c b/drivers/common/cnxk/roc_ae_fpm_tables.c
index afb2a50..f915702 100644
--- a/drivers/common/cnxk/roc_ae_fpm_tables.c
+++ b/drivers/common/cnxk/roc_ae_fpm_tables.c
@@ -1135,6 +1135,6 @@ struct ae_fpm_tbl {
 
 	fpm = (struct ae_fpm_tbl *)mz->addr;
 	/* Decrement number of devices using FPM table */
-	if (__atomic_sub_fetch(&fpm->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+	if (__atomic_fetch_sub(&fpm->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
 		plt_memzone_free(mz);
 }
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 69c3d8d..20637fb 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -946,7 +946,7 @@
 		return NPA_ERR_ALLOC;
 
 	/* Not the last PCI device */
-	if (__atomic_sub_fetch(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) != 0)
+	if (__atomic_fetch_sub(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) - 1 != 0)
 		return 0;
 
 	npa_unregister_irqs(idev->npa);
-- 
1.8.3.1


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

* [PATCH v2 03/16] common/mlx5: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 02/16] common/cnxk: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 04/16] drivers/event: " Tyler Retzlaff
                     ` (14 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/common/mlx5/linux/mlx5_nl.c     | 2 +-
 drivers/common/mlx5/mlx5_common_mr.c    | 8 ++++----
 drivers/common/mlx5/mlx5_common_utils.c | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c
index 5d04857..33670bb 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.c
+++ b/drivers/common/mlx5/linux/mlx5_nl.c
@@ -178,7 +178,7 @@ struct mlx5_nl_port_info {
 uint32_t atomic_sn;
 
 /* Generate Netlink sequence number. */
-#define MLX5_NL_SN_GENERATE __atomic_add_fetch(&atomic_sn, 1, __ATOMIC_RELAXED)
+#define MLX5_NL_SN_GENERATE (__atomic_fetch_add(&atomic_sn, 1, __ATOMIC_RELAXED) + 1)
 
 /**
  * Opens a Netlink socket.
diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c
index 0e1d243..037a4d8 100644
--- a/drivers/common/mlx5/mlx5_common_mr.c
+++ b/drivers/common/mlx5/mlx5_common_mr.c
@@ -58,8 +58,8 @@ struct mlx5_mempool_reg {
 
 	if (__atomic_load_n(&buf->refcnt, __ATOMIC_RELAXED) == 1) {
 		rte_mempool_put(buf->mp, buf);
-	} else if (unlikely(__atomic_sub_fetch(&buf->refcnt, 1,
-					       __ATOMIC_RELAXED) == 0)) {
+	} else if (unlikely(__atomic_fetch_sub(&buf->refcnt, 1,
+					       __ATOMIC_RELAXED) - 1 == 0)) {
 		__atomic_store_n(&buf->refcnt, 1, __ATOMIC_RELAXED);
 		rte_mempool_put(buf->mp, buf);
 	}
@@ -1665,8 +1665,8 @@ struct mlx5_mempool_get_extmem_data {
 	bool ret = false;
 
 	for (i = 0; i < mpr->mrs_n; i++)
-		ret |= __atomic_sub_fetch(&mpr->mrs[i].refcnt, 1,
-					  __ATOMIC_RELAXED) == 0;
+		ret |= __atomic_fetch_sub(&mpr->mrs[i].refcnt, 1,
+					  __ATOMIC_RELAXED) - 1 == 0;
 	return ret;
 }
 
diff --git a/drivers/common/mlx5/mlx5_common_utils.c b/drivers/common/mlx5/mlx5_common_utils.c
index 58d744b..06b5b9b 100644
--- a/drivers/common/mlx5/mlx5_common_utils.c
+++ b/drivers/common/mlx5/mlx5_common_utils.c
@@ -81,8 +81,8 @@ struct mlx5_list *
 	while (entry != NULL) {
 		if (l_const->cb_match(l_const->ctx, entry, ctx) == 0) {
 			if (reuse) {
-				ret = __atomic_add_fetch(&entry->ref_cnt, 1,
-							 __ATOMIC_RELAXED) - 1;
+				ret = __atomic_fetch_add(&entry->ref_cnt, 1,
+							 __ATOMIC_RELAXED);
 				DRV_LOG(DEBUG, "mlx5 list %s entry %p ref: %u.",
 					l_const->name, (void *)entry,
 					entry->ref_cnt);
@@ -285,7 +285,7 @@ struct mlx5_list_entry *
 {
 	struct mlx5_list_entry *gentry = entry->gentry;
 
-	if (__atomic_sub_fetch(&entry->ref_cnt, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_fetch_sub(&entry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0)
 		return 1;
 	if (entry->lcore_idx == (uint32_t)lcore_idx) {
 		LIST_REMOVE(entry, next);
@@ -303,7 +303,7 @@ struct mlx5_list_entry *
 			l_const->name, (void *)entry);
 		return 0;
 	}
-	if (__atomic_sub_fetch(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_fetch_sub(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0)
 		return 1;
 	rte_rwlock_write_lock(&l_inconst->lock);
 	if (likely(gentry->ref_cnt == 0)) {
-- 
1.8.3.1


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

* [PATCH v2 04/16] drivers/event: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (2 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 03/16] common/mlx5: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 05/16] net/af_xdp: " Tyler Retzlaff
                     ` (13 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 drivers/event/cnxk/cnxk_tim_worker.h  | 2 +-
 drivers/event/dsw/dsw_event.c         | 4 ++--
 drivers/event/octeontx/timvf_worker.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/event/cnxk/cnxk_tim_worker.h b/drivers/event/cnxk/cnxk_tim_worker.h
index a326d55..0bd66ec 100644
--- a/drivers/event/cnxk/cnxk_tim_worker.h
+++ b/drivers/event/cnxk/cnxk_tim_worker.h
@@ -123,7 +123,7 @@
 	const uint64_t v =
 		~(TIM_BUCKET_W1_M_NUM_ENTRIES << TIM_BUCKET_W1_S_NUM_ENTRIES);
 
-	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
+	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) & v;
 }
 
 static inline uint64_t
diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c
index 9932caf..cbdc03f 100644
--- a/drivers/event/dsw/dsw_event.c
+++ b/drivers/event/dsw/dsw_event.c
@@ -45,8 +45,8 @@
 	 * allocation.
 	 */
 	new_total_on_loan =
-	    __atomic_add_fetch(&dsw->credits_on_loan, acquired_credits,
-			       __ATOMIC_RELAXED);
+	    __atomic_fetch_add(&dsw->credits_on_loan, acquired_credits,
+			       __ATOMIC_RELAXED) + acquired_credits;
 
 	if (unlikely(new_total_on_loan > dsw->max_inflight)) {
 		/* Some other port took the last credits */
diff --git a/drivers/event/octeontx/timvf_worker.h b/drivers/event/octeontx/timvf_worker.h
index 3f1e77f..aa729f8 100644
--- a/drivers/event/octeontx/timvf_worker.h
+++ b/drivers/event/octeontx/timvf_worker.h
@@ -135,7 +135,7 @@
 {
 	const uint64_t v = ~(TIM_BUCKET_W1_M_NUM_ENTRIES <<
 			TIM_BUCKET_W1_S_NUM_ENTRIES);
-	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
+	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) & v;
 }
 
 static inline struct tim_mem_entry *
-- 
1.8.3.1


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

* [PATCH v2 05/16] net/af_xdp: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (3 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 04/16] drivers/event: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 06/16] net/cnxk: " Tyler Retzlaff
                     ` (12 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 2a20a69..c7786cc 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -979,7 +979,7 @@ static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
 			break;
 		xsk_socket__delete(rxq->xsk);
 
-		if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE)
+		if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1
 				== 0) {
 			(void)xsk_umem__delete(rxq->umem->umem);
 			xdp_umem_destroy(rxq->umem);
@@ -1710,7 +1710,7 @@ struct msg_internal {
 out_xsk:
 	xsk_socket__delete(rxq->xsk);
 out_umem:
-	if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) == 0)
+	if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0)
 		xdp_umem_destroy(rxq->umem);
 
 	return ret;
-- 
1.8.3.1


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

* [PATCH v2 06/16] net/cnxk: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (4 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 05/16] net/af_xdp: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 07/16] net/cxgbe: " Tyler Retzlaff
                     ` (11 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by:  Nithin Dabilpuram <ndabilpuram@marvell.com>
---
 drivers/net/cnxk/cn10k_tx.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/cnxk/cn10k_tx.h b/drivers/net/cnxk/cn10k_tx.h
index a72a803..c9ec01c 100644
--- a/drivers/net/cnxk/cn10k_tx.h
+++ b/drivers/net/cnxk/cn10k_tx.h
@@ -108,7 +108,7 @@
 retry:
 	while (__atomic_load_n(&txq->fc_cache_pkts, __ATOMIC_RELAXED) < 0)
 		;
-	cached = __atomic_sub_fetch(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE);
+	cached = __atomic_fetch_sub(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE) - req;
 	/* Check if there is enough space, else update and retry. */
 	if (cached < 0) {
 		/* Check if we have space else retry. */
@@ -302,7 +302,7 @@
 
 again:
 	fc_sw = txq->cpt_fc_sw;
-	val = __atomic_sub_fetch(fc_sw, nb_pkts, __ATOMIC_RELAXED);
+	val = __atomic_fetch_sub(fc_sw, nb_pkts, __ATOMIC_RELAXED) - nb_pkts;
 	if (likely(val >= 0))
 		return;
 
-- 
1.8.3.1


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

* [PATCH v2 07/16] net/cxgbe: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (5 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 06/16] net/cnxk: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 08/16] net/iavf: " Tyler Retzlaff
                     ` (10 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/cxgbe/clip_tbl.c | 2 +-
 drivers/net/cxgbe/mps_tcam.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/cxgbe/clip_tbl.c b/drivers/net/cxgbe/clip_tbl.c
index 072fc74..f64b922 100644
--- a/drivers/net/cxgbe/clip_tbl.c
+++ b/drivers/net/cxgbe/clip_tbl.c
@@ -55,7 +55,7 @@ void cxgbe_clip_release(struct rte_eth_dev *dev, struct clip_entry *ce)
 	int ret;
 
 	t4_os_lock(&ce->lock);
-	if (__atomic_sub_fetch(&ce->refcnt, 1, __ATOMIC_RELAXED) == 0) {
+	if (__atomic_fetch_sub(&ce->refcnt, 1, __ATOMIC_RELAXED) - 1 == 0) {
 		ret = clip6_release_mbox(dev, ce->addr);
 		if (ret)
 			dev_debug(adap, "CLIP FW DEL CMD failed: %d", ret);
diff --git a/drivers/net/cxgbe/mps_tcam.c b/drivers/net/cxgbe/mps_tcam.c
index abbf06e..c7cdf29 100644
--- a/drivers/net/cxgbe/mps_tcam.c
+++ b/drivers/net/cxgbe/mps_tcam.c
@@ -195,7 +195,7 @@ int cxgbe_mpstcam_remove(struct port_info *pi, u16 idx)
 					   entry->mask, idx, 1, pi->port_id,
 					   false);
 	else
-		ret = __atomic_sub_fetch(&entry->refcnt, 1, __ATOMIC_RELAXED);
+		ret = __atomic_fetch_sub(&entry->refcnt, 1, __ATOMIC_RELAXED) - 1;
 
 	if (ret == 0) {
 		reset_mpstcam_entry(entry);
-- 
1.8.3.1


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

* [PATCH v2 08/16] net/iavf: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (6 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 07/16] net/cxgbe: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 09/16] net/mlx5: " Tyler Retzlaff
                     ` (9 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/iavf/iavf_vchnl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 9adaadb..51d4fc7 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -120,7 +120,7 @@ struct iavf_event_handler {
 {
 	struct iavf_event_handler *handler = &event_handler;
 
-	if (__atomic_add_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 1)
+	if (__atomic_fetch_add(&handler->ndev, 1, __ATOMIC_RELAXED) + 1 != 1)
 		return 0;
 #if defined(RTE_EXEC_ENV_IS_WINDOWS) && RTE_EXEC_ENV_IS_WINDOWS != 0
 	int err = _pipe(handler->fd, MAX_EVENT_PENDING, O_BINARY);
@@ -149,7 +149,7 @@ struct iavf_event_handler {
 {
 	struct iavf_event_handler *handler = &event_handler;
 
-	if (__atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED) - 1 != 0)
 		return;
 
 	int unused = pthread_cancel(handler->tid);
@@ -533,8 +533,8 @@ struct iavf_event_handler {
 				/* read message and it's expected one */
 				if (msg_opc == vf->pend_cmd) {
 					uint32_t cmd_count =
-					__atomic_sub_fetch(&vf->pend_cmd_count,
-							1, __ATOMIC_RELAXED);
+					__atomic_fetch_sub(&vf->pend_cmd_count,
+							1, __ATOMIC_RELAXED) - 1;
 					if (cmd_count == 0)
 						_notify_cmd(vf, msg_ret);
 				} else {
-- 
1.8.3.1


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

* [PATCH v2 09/16] net/mlx5: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (7 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 08/16] net/iavf: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 10/16] net/octeontx: " Tyler Retzlaff
                     ` (8 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/mlx5/linux/mlx5_verbs.c |  2 +-
 drivers/net/mlx5/mlx5.c             |  4 ++--
 drivers/net/mlx5/mlx5_flow.c        |  8 ++++----
 drivers/net/mlx5/mlx5_flow_dv.c     | 12 ++++++------
 drivers/net/mlx5/mlx5_flow_hw.c     | 14 +++++++-------
 drivers/net/mlx5/mlx5_hws_cnt.c     |  4 ++--
 drivers/net/mlx5/mlx5_rxq.c         |  6 +++---
 drivers/net/mlx5/mlx5_txq.c         |  2 +-
 8 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 67a7bec..ee5d072 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -1183,7 +1183,7 @@
 	if (!priv->lb_used)
 		return;
 	MLX5_ASSERT(__atomic_load_n(&sh->self_lb.refcnt, __ATOMIC_RELAXED));
-	if (!(__atomic_sub_fetch(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED))) {
+	if (!(__atomic_fetch_sub(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED) - 1)) {
 		if (sh->self_lb.qp) {
 			claim_zero(mlx5_glue->destroy_qp(sh->self_lb.qp));
 			sh->self_lb.qp = NULL;
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 41b1b12..044012d 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1068,7 +1068,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 		DRV_LOG(ERR, "Dynamic flex parser is not supported");
 		return -ENOTSUP;
 	}
-	if (__atomic_add_fetch(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) > 1)
+	if (__atomic_fetch_add(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) + 1 > 1)
 		return 0;
 
 	node.header_length_mode = MLX5_GRAPH_NODE_LEN_FIELD;
@@ -1123,7 +1123,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_internal_flex_parser_profile *fp = &priv->sh->srh_flex_parser;
 
-	if (__atomic_sub_fetch(&fp->refcnt, 1, __ATOMIC_RELAXED))
+	if (__atomic_fetch_sub(&fp->refcnt, 1, __ATOMIC_RELAXED) - 1)
 		return;
 	if (fp->fp)
 		mlx5_devx_cmd_destroy(fp->fp);
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 2514b33..332008e 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -7833,7 +7833,7 @@ struct rte_flow *
 
 		tunnel = mlx5_find_tunnel_id(dev, flow->tunnel_id);
 		RTE_VERIFY(tunnel);
-		if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+		if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
 			mlx5_flow_tunnel_free(dev, tunnel);
 	}
 	flow_mreg_del_copy_action(dev, flow);
@@ -9742,9 +9742,9 @@ struct mlx5_flow_workspace*
 					 __ATOMIC_RELAXED);
 			continue;
 		}
-		if (__atomic_add_fetch(&age_param->sec_since_last_hit,
+		if (__atomic_fetch_add(&age_param->sec_since_last_hit,
 				       time_delta,
-				       __ATOMIC_RELAXED) <= age_param->timeout)
+				       __ATOMIC_RELAXED) + time_delta <= age_param->timeout)
 			continue;
 		/**
 		 * Hold the lock first, or if between the
@@ -11387,7 +11387,7 @@ struct tunnel_db_element_release_ctx {
 {
 	struct tunnel_db_element_release_ctx *ctx = x;
 	ctx->ret = 0;
-	if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+	if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
 		mlx5_flow_tunnel_free(dev, tunnel);
 }
 
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ca26f39..f04160e 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -6723,8 +6723,8 @@ struct mlx5_list_entry *
 		 * indirect action API, shared info is 1 before the reduction,
 		 * so this condition is failed and function doesn't return here.
 		 */
-		if (__atomic_sub_fetch(&cnt->shared_info.refcnt, 1,
-				       __ATOMIC_RELAXED))
+		if (__atomic_fetch_sub(&cnt->shared_info.refcnt, 1,
+				       __ATOMIC_RELAXED) - 1)
 			return;
 	}
 	cnt->pool = pool;
@@ -12797,7 +12797,7 @@ struct mlx5_list_entry *
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_aso_age_mng *mng = priv->sh->aso_age_mng;
 	struct mlx5_aso_age_action *age = flow_aso_age_get_by_idx(dev, age_idx);
-	uint32_t ret = __atomic_sub_fetch(&age->refcnt, 1, __ATOMIC_RELAXED);
+	uint32_t ret = __atomic_fetch_sub(&age->refcnt, 1, __ATOMIC_RELAXED) - 1;
 
 	if (!ret) {
 		flow_dv_aso_age_remove_from_age(dev, age);
@@ -13193,7 +13193,7 @@ struct mlx5_list_entry *
 	/* Cannot release when CT is in the ASO SQ. */
 	if (state == ASO_CONNTRACK_WAIT || state == ASO_CONNTRACK_QUERY)
 		return -1;
-	ret = __atomic_sub_fetch(&ct->refcnt, 1, __ATOMIC_RELAXED);
+	ret = __atomic_fetch_sub(&ct->refcnt, 1, __ATOMIC_RELAXED) - 1;
 	if (!ret) {
 		if (ct->dr_action_orig) {
 #ifdef HAVE_MLX5_DR_ACTION_ASO_CT
@@ -15582,8 +15582,8 @@ struct mlx5_list_entry *
 				sh->geneve_tlv_option_resource;
 	rte_spinlock_lock(&sh->geneve_tlv_opt_sl);
 	if (geneve_opt_resource) {
-		if (!(__atomic_sub_fetch(&geneve_opt_resource->refcnt, 1,
-					 __ATOMIC_RELAXED))) {
+		if (!(__atomic_fetch_sub(&geneve_opt_resource->refcnt, 1,
+					 __ATOMIC_RELAXED) - 1)) {
 			claim_zero(mlx5_devx_cmd_destroy
 					(geneve_opt_resource->obj));
 			mlx5_free(sh->geneve_tlv_option_resource);
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 9392727..109aab1 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -458,7 +458,7 @@ static int flow_hw_translate_group(struct rte_eth_dev *dev,
 	}
 
 	if (acts->mark)
-		if (!__atomic_sub_fetch(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED))
+		if (!(__atomic_fetch_sub(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED) - 1))
 			flow_hw_rxq_flag_set(dev, false);
 
 	if (acts->jump) {
@@ -3268,8 +3268,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
 			rte_errno = EINVAL;
 			goto it_error;
 		}
-		ret = __atomic_add_fetch(&item_templates[i]->refcnt, 1,
-					 __ATOMIC_RELAXED);
+		ret = __atomic_fetch_add(&item_templates[i]->refcnt, 1,
+					 __ATOMIC_RELAXED) + 1;
 		if (ret <= 1) {
 			rte_errno = EINVAL;
 			goto it_error;
@@ -3282,8 +3282,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
 	for (i = 0; i < nb_action_templates; i++) {
 		uint32_t ret;
 
-		ret = __atomic_add_fetch(&action_templates[i]->refcnt, 1,
-					 __ATOMIC_RELAXED);
+		ret = __atomic_fetch_add(&action_templates[i]->refcnt, 1,
+					 __ATOMIC_RELAXED) + 1;
 		if (ret <= 1) {
 			rte_errno = EINVAL;
 			goto at_error;
@@ -7624,8 +7624,8 @@ void flow_hw_clear_tags_set(struct rte_eth_dev *dev)
 {
 	uint32_t refcnt;
 
-	refcnt = __atomic_sub_fetch(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
-				    __ATOMIC_RELAXED);
+	refcnt = __atomic_fetch_sub(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
+				    __ATOMIC_RELAXED) - 1;
 	if (refcnt > 0)
 		return;
 	mlx5_flow_hw_flow_metadata_esw_en = 0;
diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c
index d6a017a..d98df68 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.c
+++ b/drivers/net/mlx5/mlx5_hws_cnt.c
@@ -192,8 +192,8 @@
 			}
 			param->accumulator_hits = 0;
 		}
-		if (__atomic_add_fetch(&param->sec_since_last_hit, time_delta,
-				       __ATOMIC_RELAXED) <=
+		if (__atomic_fetch_add(&param->sec_since_last_hit, time_delta,
+				       __ATOMIC_RELAXED) + time_delta <=
 		   __atomic_load_n(&param->timeout, __ATOMIC_RELAXED))
 			continue;
 		/* Prepare the relevant ring for this AGE parameter */
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 6e99c4d..ad8fd13 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2042,7 +2042,7 @@ struct mlx5_rxq_priv *
 
 	if (rxq == NULL)
 		return 0;
-	return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+	return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
 }
 
 /**
@@ -2141,7 +2141,7 @@ struct mlx5_external_rxq *
 {
 	struct mlx5_external_rxq *rxq = mlx5_ext_rxq_get(dev, idx);
 
-	return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+	return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
 }
 
 /**
@@ -2462,7 +2462,7 @@ struct mlx5_ind_table_obj *
 	unsigned int ret;
 
 	rte_rwlock_write_lock(&priv->ind_tbls_lock);
-	ret = __atomic_sub_fetch(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
+	ret = __atomic_fetch_sub(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED) - 1;
 	if (!ret)
 		LIST_REMOVE(ind_tbl, next);
 	rte_rwlock_write_unlock(&priv->ind_tbls_lock);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 1e0e61a..8cb52b0 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -1203,7 +1203,7 @@ struct mlx5_txq_ctrl *
 	if (priv->txqs == NULL || (*priv->txqs)[idx] == NULL)
 		return 0;
 	txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
-	if (__atomic_sub_fetch(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) > 1)
+	if (__atomic_fetch_sub(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) - 1 > 1)
 		return 1;
 	if (txq_ctrl->obj) {
 		priv->obj_ops.txq_obj_release(txq_ctrl->obj);
-- 
1.8.3.1


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

* [PATCH v2 10/16] net/octeontx: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (8 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 09/16] net/mlx5: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 11/16] raw/ifpga: " Tyler Retzlaff
                     ` (7 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/octeontx/octeontx_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index d52a3e7..a21ed80 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -559,7 +559,7 @@ enum octeontx_link_speed {
 		return 0;
 
 	/* Stopping/closing event device once all eth ports are closed. */
-	if (__atomic_sub_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) == 0) {
+	if (__atomic_fetch_sub(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0) {
 		rte_event_dev_stop(nic->evdev);
 		rte_event_dev_close(nic->evdev);
 	}
-- 
1.8.3.1


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

* [PATCH v2 11/16] raw/ifpga: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (9 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 10/16] net/octeontx: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 12/16] bbdev: " Tyler Retzlaff
                     ` (6 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 1020adc..ae3f79d 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -573,7 +573,7 @@ static int set_surprise_link_check_aer(
 
 	dev->poll_enabled = 0;
 
-	if (!__atomic_sub_fetch(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) &&
+	if (!(__atomic_fetch_sub(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) - 1) &&
 		ifpga_monitor_start_thread) {
 		ret = pthread_cancel(ifpga_monitor_start_thread);
 		if (ret)
-- 
1.8.3.1


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

* [PATCH v2 12/16] bbdev: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (10 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 11/16] raw/ifpga: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 13/16] eal: " Tyler Retzlaff
                     ` (5 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/bbdev/rte_bbdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c
index 1521cdb..9df0837 100644
--- a/lib/bbdev/rte_bbdev.c
+++ b/lib/bbdev/rte_bbdev.c
@@ -250,8 +250,8 @@ struct rte_bbdev *
 	}
 
 	/* clear shared BBDev Data if no process is using the device anymore */
-	if (__atomic_sub_fetch(&bbdev->data->process_cnt, 1,
-			      __ATOMIC_RELAXED) == 0)
+	if (__atomic_fetch_sub(&bbdev->data->process_cnt, 1,
+			      __ATOMIC_RELAXED) - 1 == 0)
 		memset(bbdev->data, 0, sizeof(*bbdev->data));
 
 	memset(bbdev, 0, sizeof(*bbdev));
-- 
1.8.3.1


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

* [PATCH v2 13/16] eal: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (11 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 12/16] bbdev: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 14/16] ipsec: " Tyler Retzlaff
                     ` (4 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/include/generic/rte_rwlock.h |  8 ++++----
 lib/eal/ppc/include/rte_atomic.h     | 16 ++++++++--------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/eal/include/generic/rte_rwlock.h b/lib/eal/include/generic/rte_rwlock.h
index d45c22c..71e2d8d 100644
--- a/lib/eal/include/generic/rte_rwlock.h
+++ b/lib/eal/include/generic/rte_rwlock.h
@@ -97,8 +97,8 @@
 			rte_pause();
 
 		/* Try to get read lock */
-		x = __atomic_add_fetch(&rwl->cnt, RTE_RWLOCK_READ,
-				       __ATOMIC_ACQUIRE);
+		x = __atomic_fetch_add(&rwl->cnt, RTE_RWLOCK_READ,
+				       __ATOMIC_ACQUIRE) + RTE_RWLOCK_READ;
 
 		/* If no writer, then acquire was successful */
 		if (likely(!(x & RTE_RWLOCK_MASK)))
@@ -134,8 +134,8 @@
 		return -EBUSY;
 
 	/* Try to get read lock */
-	x = __atomic_add_fetch(&rwl->cnt, RTE_RWLOCK_READ,
-			       __ATOMIC_ACQUIRE);
+	x = __atomic_fetch_add(&rwl->cnt, RTE_RWLOCK_READ,
+			       __ATOMIC_ACQUIRE) + RTE_RWLOCK_READ;
 
 	/* Back out if writer raced in */
 	if (unlikely(x & RTE_RWLOCK_MASK)) {
diff --git a/lib/eal/ppc/include/rte_atomic.h b/lib/eal/ppc/include/rte_atomic.h
index 663b4d3..ffabd98 100644
--- a/lib/eal/ppc/include/rte_atomic.h
+++ b/lib/eal/ppc/include/rte_atomic.h
@@ -71,12 +71,12 @@ static inline int rte_atomic16_test_and_set(rte_atomic16_t *v)
 
 static inline int rte_atomic16_inc_and_test(rte_atomic16_t *v)
 {
-	return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0;
 }
 
 static inline int rte_atomic16_dec_and_test(rte_atomic16_t *v)
 {
-	return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0;
 }
 
 static inline uint16_t
@@ -113,12 +113,12 @@ static inline int rte_atomic32_test_and_set(rte_atomic32_t *v)
 
 static inline int rte_atomic32_inc_and_test(rte_atomic32_t *v)
 {
-	return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0;
 }
 
 static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)
 {
-	return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0;
 }
 
 static inline uint32_t
@@ -181,23 +181,23 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)
 static inline int64_t
 rte_atomic64_add_return(rte_atomic64_t *v, int64_t inc)
 {
-	return __atomic_add_fetch(&v->cnt, inc, __ATOMIC_ACQUIRE);
+	return __atomic_fetch_add(&v->cnt, inc, __ATOMIC_ACQUIRE) + inc;
 }
 
 static inline int64_t
 rte_atomic64_sub_return(rte_atomic64_t *v, int64_t dec)
 {
-	return __atomic_sub_fetch(&v->cnt, dec, __ATOMIC_ACQUIRE);
+	return __atomic_fetch_sub(&v->cnt, dec, __ATOMIC_ACQUIRE) - dec;
 }
 
 static inline int rte_atomic64_inc_and_test(rte_atomic64_t *v)
 {
-	return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0;
 }
 
 static inline int rte_atomic64_dec_and_test(rte_atomic64_t *v)
 {
-	return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0;
 }
 
 static inline int rte_atomic64_test_and_set(rte_atomic64_t *v)
-- 
1.8.3.1


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

* [PATCH v2 14/16] ipsec: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (12 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 13/16] eal: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 15/16] mbuf: " Tyler Retzlaff
                     ` (3 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/ipsec/ipsec_sqn.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ipsec/ipsec_sqn.h b/lib/ipsec/ipsec_sqn.h
index 2636cb1..505950e 100644
--- a/lib/ipsec/ipsec_sqn.h
+++ b/lib/ipsec/ipsec_sqn.h
@@ -128,7 +128,7 @@
 
 	n = *num;
 	if (SQN_ATOMIC(sa))
-		sqn = __atomic_add_fetch(&sa->sqn.outb, n, __ATOMIC_RELAXED);
+		sqn = __atomic_fetch_add(&sa->sqn.outb, n, __ATOMIC_RELAXED) + n;
 	else {
 		sqn = sa->sqn.outb + n;
 		sa->sqn.outb = sqn;
-- 
1.8.3.1


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

* [PATCH v2 15/16] mbuf: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (13 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 14/16] ipsec: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-15 21:15   ` [PATCH v2 16/16] rcu: " Tyler Retzlaff
                     ` (2 subsequent siblings)
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/mbuf/rte_mbuf.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
index 3a82eb1..e5ab4a4 100644
--- a/lib/mbuf/rte_mbuf.h
+++ b/lib/mbuf/rte_mbuf.h
@@ -381,8 +381,8 @@ struct rte_pktmbuf_pool_private {
 static inline uint16_t
 __rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value)
 {
-	return __atomic_add_fetch(&m->refcnt, (uint16_t)value,
-				 __ATOMIC_ACQ_REL);
+	return __atomic_fetch_add(&m->refcnt, value,
+				 __ATOMIC_ACQ_REL) + value;
 }
 
 /**
@@ -502,8 +502,8 @@ struct rte_pktmbuf_pool_private {
 		return (uint16_t)value;
 	}
 
-	return __atomic_add_fetch(&shinfo->refcnt, (uint16_t)value,
-				 __ATOMIC_ACQ_REL);
+	return __atomic_fetch_add(&shinfo->refcnt, value,
+				 __ATOMIC_ACQ_REL) + value;
 }
 
 /** Mbuf prefetch */
@@ -1315,8 +1315,8 @@ static inline int __rte_pktmbuf_pinned_extbuf_decref(struct rte_mbuf *m)
 	 * Direct usage of add primitive to avoid
 	 * duplication of comparing with one.
 	 */
-	if (likely(__atomic_add_fetch(&shinfo->refcnt, (uint16_t)-1,
-				     __ATOMIC_ACQ_REL)))
+	if (likely(__atomic_fetch_add(&shinfo->refcnt, -1,
+				     __ATOMIC_ACQ_REL) - 1))
 		return 1;
 
 	/* Reinitialize counter before mbuf freeing. */
-- 
1.8.3.1


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

* [PATCH v2 16/16] rcu: use previous value atomic fetch operations
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (14 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 15/16] mbuf: " Tyler Retzlaff
@ 2023-03-15 21:15   ` Tyler Retzlaff
  2023-03-16 10:03   ` [PATCH v2 00/16] replace __atomic operations returning new value Bruce Richardson
  2023-03-20 10:24   ` Ruifeng Wang
  17 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-15 21:15 UTC (permalink / raw)
  To: dev; +Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/rcu/rte_rcu_qsbr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h
index ccae5d5..1aa078e 100644
--- a/lib/rcu/rte_rcu_qsbr.h
+++ b/lib/rcu/rte_rcu_qsbr.h
@@ -462,7 +462,7 @@ struct rte_rcu_qsbr_dq_parameters {
 	 * structure are visible to the workers before the token
 	 * update is visible.
 	 */
-	t = __atomic_add_fetch(&v->token, 1, __ATOMIC_RELEASE);
+	t = __atomic_fetch_add(&v->token, 1, __ATOMIC_RELEASE) + 1;
 
 	return t;
 }
-- 
1.8.3.1


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

* Re: [PATCH v2 00/16] replace __atomic operations returning new value
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (15 preceding siblings ...)
  2023-03-15 21:15   ` [PATCH v2 16/16] rcu: " Tyler Retzlaff
@ 2023-03-16 10:03   ` Bruce Richardson
  2023-03-16 15:25     ` Thomas Monjalon
  2023-03-20 10:24   ` Ruifeng Wang
  17 siblings, 1 reply; 59+ messages in thread
From: Bruce Richardson @ 2023-03-16 10:03 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Honnappa.Nagarahalli, Ruifeng.Wang, thomas

On Wed, Mar 15, 2023 at 02:15:29PM -0700, Tyler Retzlaff wrote:
> This series replaces uses of __atomic_{add,and,or,sub,xor}_fetch with
> __atomic_fetch_{add,and,or,sub,xor} intrinsics where the new value
> is used.
> 
> This series is being separated from the other similar series in
> an effort to reduce the chance of mistakes being spotted in review
> since the usages in this case consume the returned / new value.
> 
> v2:
>     * remove unnecessary casts of signed to unsigned arguments when
>       using generic __atomic builtins.
>     * remove inappropriate cast of signed negative value on addend.
> 
> Tyler Retzlaff (16):
>   app/test: use previous value atomic fetch operations
>   common/cnxk: use previous value atomic fetch operations
>   common/mlx5: use previous value atomic fetch operations
>   drivers/event: use previous value atomic fetch operations
>   net/af_xdp: use previous value atomic fetch operations
>   net/cnxk: use previous value atomic fetch operations
>   net/cxgbe: use previous value atomic fetch operations
>   net/iavf: use previous value atomic fetch operations
>   net/mlx5: use previous value atomic fetch operations
>   net/octeontx: use previous value atomic fetch operations
>   raw/ifpga: use previous value atomic fetch operations
>   bbdev: use previous value atomic fetch operations
>   eal: use previous value atomic fetch operations
>   ipsec: use previous value atomic fetch operations
>   mbuf: use previous value atomic fetch operations
>   rcu: use previous value atomic fetch operations
> 
I am wondering how we go about ensuring that we don't introduce any more of
these atomic_X_fetch intrinsics. Is there some way we can add a compiler
warning for them or have a checkpatch check, for example?

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

* Re: [PATCH v2 00/16] replace __atomic operations returning new value
  2023-03-16 10:03   ` [PATCH v2 00/16] replace __atomic operations returning new value Bruce Richardson
@ 2023-03-16 15:25     ` Thomas Monjalon
  2023-03-16 16:17       ` Tyler Retzlaff
  0 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2023-03-16 15:25 UTC (permalink / raw)
  To: Tyler Retzlaff, Bruce Richardson; +Cc: dev, Honnappa.Nagarahalli, Ruifeng.Wang

16/03/2023 11:03, Bruce Richardson:
> On Wed, Mar 15, 2023 at 02:15:29PM -0700, Tyler Retzlaff wrote:
> > This series replaces uses of __atomic_{add,and,or,sub,xor}_fetch with
> > __atomic_fetch_{add,and,or,sub,xor} intrinsics where the new value
> > is used.
[...]
> > Tyler Retzlaff (16):
> >   app/test: use previous value atomic fetch operations
> >   common/cnxk: use previous value atomic fetch operations
> >   common/mlx5: use previous value atomic fetch operations
> >   drivers/event: use previous value atomic fetch operations
> >   net/af_xdp: use previous value atomic fetch operations
> >   net/cnxk: use previous value atomic fetch operations
> >   net/cxgbe: use previous value atomic fetch operations
> >   net/iavf: use previous value atomic fetch operations
> >   net/mlx5: use previous value atomic fetch operations
> >   net/octeontx: use previous value atomic fetch operations
> >   raw/ifpga: use previous value atomic fetch operations
> >   bbdev: use previous value atomic fetch operations
> >   eal: use previous value atomic fetch operations
> >   ipsec: use previous value atomic fetch operations
> >   mbuf: use previous value atomic fetch operations
> >   rcu: use previous value atomic fetch operations
> > 
> I am wondering how we go about ensuring that we don't introduce any more of
> these atomic_X_fetch intrinsics. Is there some way we can add a compiler
> warning for them or have a checkpatch check, for example?

In devtools/checkpatches.sh, we are checking for these patterns:
	rte_atomic[0-9][0-9]_.*\(
	__atomic_thread_fence\(

Feel free to add more "forbidden patterns".




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

* Re: [PATCH v2 00/16] replace __atomic operations returning new value
  2023-03-16 15:25     ` Thomas Monjalon
@ 2023-03-16 16:17       ` Tyler Retzlaff
  2023-04-18 18:11         ` Tyler Retzlaff
  0 siblings, 1 reply; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-16 16:17 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Bruce Richardson, dev, Honnappa.Nagarahalli, Ruifeng.Wang

On Thu, Mar 16, 2023 at 04:25:41PM +0100, Thomas Monjalon wrote:
> 16/03/2023 11:03, Bruce Richardson:
> > On Wed, Mar 15, 2023 at 02:15:29PM -0700, Tyler Retzlaff wrote:
> > > This series replaces uses of __atomic_{add,and,or,sub,xor}_fetch with
> > > __atomic_fetch_{add,and,or,sub,xor} intrinsics where the new value
> > > is used.
> [...]
> > > Tyler Retzlaff (16):
> > >   app/test: use previous value atomic fetch operations
> > >   common/cnxk: use previous value atomic fetch operations
> > >   common/mlx5: use previous value atomic fetch operations
> > >   drivers/event: use previous value atomic fetch operations
> > >   net/af_xdp: use previous value atomic fetch operations
> > >   net/cnxk: use previous value atomic fetch operations
> > >   net/cxgbe: use previous value atomic fetch operations
> > >   net/iavf: use previous value atomic fetch operations
> > >   net/mlx5: use previous value atomic fetch operations
> > >   net/octeontx: use previous value atomic fetch operations
> > >   raw/ifpga: use previous value atomic fetch operations
> > >   bbdev: use previous value atomic fetch operations
> > >   eal: use previous value atomic fetch operations
> > >   ipsec: use previous value atomic fetch operations
> > >   mbuf: use previous value atomic fetch operations
> > >   rcu: use previous value atomic fetch operations
> > > 
> > I am wondering how we go about ensuring that we don't introduce any more of
> > these atomic_X_fetch intrinsics. Is there some way we can add a compiler
> > warning for them or have a checkpatch check, for example?
> 
> In devtools/checkpatches.sh, we are checking for these patterns:
> 	rte_atomic[0-9][0-9]_.*\(
> 	__atomic_thread_fence\(
> 
> Feel free to add more "forbidden patterns".
> 
> 

yes, i was going to do this before end of week but got interrupted by
other work. i will introduce a patch for checkpatches.sh standalone
asap that can be merged before these changes.

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

* RE: [PATCH v2 00/16] replace __atomic operations returning new value
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
                     ` (16 preceding siblings ...)
  2023-03-16 10:03   ` [PATCH v2 00/16] replace __atomic operations returning new value Bruce Richardson
@ 2023-03-20 10:24   ` Ruifeng Wang
  17 siblings, 0 replies; 59+ messages in thread
From: Ruifeng Wang @ 2023-03-20 10:24 UTC (permalink / raw)
  To: Tyler Retzlaff, dev; +Cc: Honnappa Nagarahalli, thomas, nd

> -----Original Message-----
> From: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Sent: Thursday, March 16, 2023 5:15 AM
> To: dev@dpdk.org
> Cc: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; thomas@monjalon.net; Tyler Retzlaff <roretzla@linux.microsoft.com>
> Subject: [PATCH v2 00/16] replace __atomic operations returning new value
> 
> This series replaces uses of __atomic_{add,and,or,sub,xor}_fetch with
> __atomic_fetch_{add,and,or,sub,xor} intrinsics where the new value is used.
> 
> This series is being separated from the other similar series in an effort to reduce the
> chance of mistakes being spotted in review since the usages in this case consume the
> returned / new value.
> 
> v2:
>     * remove unnecessary casts of signed to unsigned arguments when
>       using generic __atomic builtins.
>     * remove inappropriate cast of signed negative value on addend.
> 
> Tyler Retzlaff (16):
>   app/test: use previous value atomic fetch operations
>   common/cnxk: use previous value atomic fetch operations
>   common/mlx5: use previous value atomic fetch operations
>   drivers/event: use previous value atomic fetch operations
>   net/af_xdp: use previous value atomic fetch operations
>   net/cnxk: use previous value atomic fetch operations
>   net/cxgbe: use previous value atomic fetch operations
>   net/iavf: use previous value atomic fetch operations
>   net/mlx5: use previous value atomic fetch operations
>   net/octeontx: use previous value atomic fetch operations
>   raw/ifpga: use previous value atomic fetch operations
>   bbdev: use previous value atomic fetch operations
>   eal: use previous value atomic fetch operations
>   ipsec: use previous value atomic fetch operations
>   mbuf: use previous value atomic fetch operations
>   rcu: use previous value atomic fetch operations
> 
>  app/test/test_ring_perf.c               |  2 +-
>  drivers/common/cnxk/roc_ae.c            |  2 +-
>  drivers/common/cnxk/roc_ae_fpm_tables.c |  2 +-
>  drivers/common/cnxk/roc_npa.c           |  2 +-
>  drivers/common/mlx5/linux/mlx5_nl.c     |  2 +-
>  drivers/common/mlx5/mlx5_common_mr.c    |  8 ++++----
>  drivers/common/mlx5/mlx5_common_utils.c |  8 ++++----
>  drivers/event/cnxk/cnxk_tim_worker.h    |  2 +-
>  drivers/event/dsw/dsw_event.c           |  4 ++--
>  drivers/event/octeontx/timvf_worker.h   |  2 +-
>  drivers/net/af_xdp/rte_eth_af_xdp.c     |  4 ++--
>  drivers/net/cnxk/cn10k_tx.h             |  4 ++--
>  drivers/net/cxgbe/clip_tbl.c            |  2 +-
>  drivers/net/cxgbe/mps_tcam.c            |  2 +-
>  drivers/net/iavf/iavf_vchnl.c           |  8 ++++----
>  drivers/net/mlx5/linux/mlx5_verbs.c     |  2 +-
>  drivers/net/mlx5/mlx5.c                 |  4 ++--
>  drivers/net/mlx5/mlx5_flow.c            |  8 ++++----
>  drivers/net/mlx5/mlx5_flow_dv.c         | 12 ++++++------
>  drivers/net/mlx5/mlx5_flow_hw.c         | 14 +++++++-------
>  drivers/net/mlx5/mlx5_hws_cnt.c         |  4 ++--
>  drivers/net/mlx5/mlx5_rxq.c             |  6 +++---
>  drivers/net/mlx5/mlx5_txq.c             |  2 +-
>  drivers/net/octeontx/octeontx_ethdev.c  |  2 +-
>  drivers/raw/ifpga/ifpga_rawdev.c        |  2 +-
>  lib/bbdev/rte_bbdev.c                   |  4 ++--
>  lib/eal/include/generic/rte_rwlock.h    |  8 ++++----
>  lib/eal/ppc/include/rte_atomic.h        | 16 ++++++++--------
>  lib/ipsec/ipsec_sqn.h                   |  2 +-
>  lib/mbuf/rte_mbuf.h                     | 12 ++++++------
>  lib/rcu/rte_rcu_qsbr.h                  |  2 +-
>  31 files changed, 77 insertions(+), 77 deletions(-)
> 
> --
> 1.8.3.1
Series-reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>

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

* [PATCH v3 00/16] replace __atomic operations returning new value
  2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
                   ` (16 preceding siblings ...)
  2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
@ 2023-03-20 19:00 ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
                     ` (16 more replies)
  17 siblings, 17 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

This series replaces uses of __atomic_{add,and,or,sub,xor}_fetch with
__atomic_fetch_{add,and,or,sub,xor} intrinsics where the new value
is used.

This series is being separated from the other similar series in
an effort to reduce the chance of mistakes being spotted in review
since the usages in this case consume the returned / new value.

v3:
    * incorporate Reviewed-by and Acked-by received so far
    * rebase series on -rc3 to get a fresh CI run

v2:
    * remove unnecessary casts of signed to unsigned arguments when
      using generic __atomic builtins.
    * remove inappropriate cast of signed negative value on addend.

*** BLURB HERE ***

Tyler Retzlaff (16):
  app/test: use previous value atomic fetch operations
  common/cnxk: use previous value atomic fetch operations
  common/mlx5: use previous value atomic fetch operations
  drivers/event: use previous value atomic fetch operations
  net/af_xdp: use previous value atomic fetch operations
  net/cnxk: use previous value atomic fetch operations
  net/cxgbe: use previous value atomic fetch operations
  net/iavf: use previous value atomic fetch operations
  net/mlx5: use previous value atomic fetch operations
  net/octeontx: use previous value atomic fetch operations
  raw/ifpga: use previous value atomic fetch operations
  bbdev: use previous value atomic fetch operations
  eal: use previous value atomic fetch operations
  ipsec: use previous value atomic fetch operations
  mbuf: use previous value atomic fetch operations
  rcu: use previous value atomic fetch operations

 app/test/test_ring_perf.c               |  2 +-
 drivers/common/cnxk/roc_ae.c            |  2 +-
 drivers/common/cnxk/roc_ae_fpm_tables.c |  2 +-
 drivers/common/cnxk/roc_npa.c           |  2 +-
 drivers/common/mlx5/linux/mlx5_nl.c     |  2 +-
 drivers/common/mlx5/mlx5_common_mr.c    |  8 ++++----
 drivers/common/mlx5/mlx5_common_utils.c |  8 ++++----
 drivers/event/cnxk/cnxk_tim_worker.h    |  2 +-
 drivers/event/dsw/dsw_event.c           |  4 ++--
 drivers/event/octeontx/timvf_worker.h   |  2 +-
 drivers/net/af_xdp/rte_eth_af_xdp.c     |  4 ++--
 drivers/net/cnxk/cn10k_tx.h             |  4 ++--
 drivers/net/cxgbe/clip_tbl.c            |  2 +-
 drivers/net/cxgbe/mps_tcam.c            |  2 +-
 drivers/net/iavf/iavf_vchnl.c           |  8 ++++----
 drivers/net/mlx5/linux/mlx5_verbs.c     |  2 +-
 drivers/net/mlx5/mlx5.c                 |  4 ++--
 drivers/net/mlx5/mlx5_flow.c            |  8 ++++----
 drivers/net/mlx5/mlx5_flow_dv.c         | 12 ++++++------
 drivers/net/mlx5/mlx5_flow_hw.c         | 14 +++++++-------
 drivers/net/mlx5/mlx5_hws_cnt.c         |  4 ++--
 drivers/net/mlx5/mlx5_rxq.c             |  6 +++---
 drivers/net/mlx5/mlx5_txq.c             |  2 +-
 drivers/net/octeontx/octeontx_ethdev.c  |  2 +-
 drivers/raw/ifpga/ifpga_rawdev.c        |  2 +-
 lib/bbdev/rte_bbdev.c                   |  4 ++--
 lib/eal/include/generic/rte_rwlock.h    |  8 ++++----
 lib/eal/ppc/include/rte_atomic.h        | 16 ++++++++--------
 lib/ipsec/ipsec_sqn.h                   |  2 +-
 lib/mbuf/rte_mbuf.h                     | 12 ++++++------
 lib/rcu/rte_rcu_qsbr.h                  |  2 +-
 31 files changed, 77 insertions(+), 77 deletions(-)

-- 
1.8.3.1


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

* [PATCH v3 01/16] app/test: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 02/16] common/cnxk: " Tyler Retzlaff
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 app/test/test_ring_perf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 2d8bb67..3972fd9 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -186,7 +186,7 @@ struct thread_params {
 	void *burst = NULL;
 
 #ifdef RTE_USE_C11_MEM_MODEL
-	if (__atomic_add_fetch(&lcore_count, 1, __ATOMIC_RELAXED) != 2)
+	if (__atomic_fetch_add(&lcore_count, 1, __ATOMIC_RELAXED) + 1 != 2)
 #else
 	if (__sync_add_and_fetch(&lcore_count, 1) != 2)
 #endif
-- 
1.8.3.1


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

* [PATCH v3 02/16] common/cnxk: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 03/16] common/mlx5: " Tyler Retzlaff
                     ` (14 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/common/cnxk/roc_ae.c            | 2 +-
 drivers/common/cnxk/roc_ae_fpm_tables.c | 2 +-
 drivers/common/cnxk/roc_npa.c           | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/common/cnxk/roc_ae.c b/drivers/common/cnxk/roc_ae.c
index 929da05..336b927 100644
--- a/drivers/common/cnxk/roc_ae.c
+++ b/drivers/common/cnxk/roc_ae.c
@@ -203,6 +203,6 @@ struct ae_ec_grp_tbl {
 
 	ec_grp = mz->addr;
 	/* Decrement number of devices using EC grp table */
-	if (__atomic_sub_fetch(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+	if (__atomic_fetch_sub(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
 		plt_memzone_free(mz);
 }
diff --git a/drivers/common/cnxk/roc_ae_fpm_tables.c b/drivers/common/cnxk/roc_ae_fpm_tables.c
index afb2a50..f915702 100644
--- a/drivers/common/cnxk/roc_ae_fpm_tables.c
+++ b/drivers/common/cnxk/roc_ae_fpm_tables.c
@@ -1135,6 +1135,6 @@ struct ae_fpm_tbl {
 
 	fpm = (struct ae_fpm_tbl *)mz->addr;
 	/* Decrement number of devices using FPM table */
-	if (__atomic_sub_fetch(&fpm->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+	if (__atomic_fetch_sub(&fpm->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
 		plt_memzone_free(mz);
 }
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 69c3d8d..20637fb 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -946,7 +946,7 @@
 		return NPA_ERR_ALLOC;
 
 	/* Not the last PCI device */
-	if (__atomic_sub_fetch(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) != 0)
+	if (__atomic_fetch_sub(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) - 1 != 0)
 		return 0;
 
 	npa_unregister_irqs(idev->npa);
-- 
1.8.3.1


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

* [PATCH v3 03/16] common/mlx5: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 02/16] common/cnxk: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 04/16] drivers/event: " Tyler Retzlaff
                     ` (13 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/common/mlx5/linux/mlx5_nl.c     | 2 +-
 drivers/common/mlx5/mlx5_common_mr.c    | 8 ++++----
 drivers/common/mlx5/mlx5_common_utils.c | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c
index 5d04857..33670bb 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.c
+++ b/drivers/common/mlx5/linux/mlx5_nl.c
@@ -178,7 +178,7 @@ struct mlx5_nl_port_info {
 uint32_t atomic_sn;
 
 /* Generate Netlink sequence number. */
-#define MLX5_NL_SN_GENERATE __atomic_add_fetch(&atomic_sn, 1, __ATOMIC_RELAXED)
+#define MLX5_NL_SN_GENERATE (__atomic_fetch_add(&atomic_sn, 1, __ATOMIC_RELAXED) + 1)
 
 /**
  * Opens a Netlink socket.
diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c
index 0e1d243..037a4d8 100644
--- a/drivers/common/mlx5/mlx5_common_mr.c
+++ b/drivers/common/mlx5/mlx5_common_mr.c
@@ -58,8 +58,8 @@ struct mlx5_mempool_reg {
 
 	if (__atomic_load_n(&buf->refcnt, __ATOMIC_RELAXED) == 1) {
 		rte_mempool_put(buf->mp, buf);
-	} else if (unlikely(__atomic_sub_fetch(&buf->refcnt, 1,
-					       __ATOMIC_RELAXED) == 0)) {
+	} else if (unlikely(__atomic_fetch_sub(&buf->refcnt, 1,
+					       __ATOMIC_RELAXED) - 1 == 0)) {
 		__atomic_store_n(&buf->refcnt, 1, __ATOMIC_RELAXED);
 		rte_mempool_put(buf->mp, buf);
 	}
@@ -1665,8 +1665,8 @@ struct mlx5_mempool_get_extmem_data {
 	bool ret = false;
 
 	for (i = 0; i < mpr->mrs_n; i++)
-		ret |= __atomic_sub_fetch(&mpr->mrs[i].refcnt, 1,
-					  __ATOMIC_RELAXED) == 0;
+		ret |= __atomic_fetch_sub(&mpr->mrs[i].refcnt, 1,
+					  __ATOMIC_RELAXED) - 1 == 0;
 	return ret;
 }
 
diff --git a/drivers/common/mlx5/mlx5_common_utils.c b/drivers/common/mlx5/mlx5_common_utils.c
index 58d744b..06b5b9b 100644
--- a/drivers/common/mlx5/mlx5_common_utils.c
+++ b/drivers/common/mlx5/mlx5_common_utils.c
@@ -81,8 +81,8 @@ struct mlx5_list *
 	while (entry != NULL) {
 		if (l_const->cb_match(l_const->ctx, entry, ctx) == 0) {
 			if (reuse) {
-				ret = __atomic_add_fetch(&entry->ref_cnt, 1,
-							 __ATOMIC_RELAXED) - 1;
+				ret = __atomic_fetch_add(&entry->ref_cnt, 1,
+							 __ATOMIC_RELAXED);
 				DRV_LOG(DEBUG, "mlx5 list %s entry %p ref: %u.",
 					l_const->name, (void *)entry,
 					entry->ref_cnt);
@@ -285,7 +285,7 @@ struct mlx5_list_entry *
 {
 	struct mlx5_list_entry *gentry = entry->gentry;
 
-	if (__atomic_sub_fetch(&entry->ref_cnt, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_fetch_sub(&entry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0)
 		return 1;
 	if (entry->lcore_idx == (uint32_t)lcore_idx) {
 		LIST_REMOVE(entry, next);
@@ -303,7 +303,7 @@ struct mlx5_list_entry *
 			l_const->name, (void *)entry);
 		return 0;
 	}
-	if (__atomic_sub_fetch(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_fetch_sub(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0)
 		return 1;
 	rte_rwlock_write_lock(&l_inconst->lock);
 	if (likely(gentry->ref_cnt == 0)) {
-- 
1.8.3.1


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

* [PATCH v3 04/16] drivers/event: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (2 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 03/16] common/mlx5: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 05/16] net/af_xdp: " Tyler Retzlaff
                     ` (12 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/event/cnxk/cnxk_tim_worker.h  | 2 +-
 drivers/event/dsw/dsw_event.c         | 4 ++--
 drivers/event/octeontx/timvf_worker.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/event/cnxk/cnxk_tim_worker.h b/drivers/event/cnxk/cnxk_tim_worker.h
index a326d55..0bd66ec 100644
--- a/drivers/event/cnxk/cnxk_tim_worker.h
+++ b/drivers/event/cnxk/cnxk_tim_worker.h
@@ -123,7 +123,7 @@
 	const uint64_t v =
 		~(TIM_BUCKET_W1_M_NUM_ENTRIES << TIM_BUCKET_W1_S_NUM_ENTRIES);
 
-	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
+	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) & v;
 }
 
 static inline uint64_t
diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c
index 9932caf..cbdc03f 100644
--- a/drivers/event/dsw/dsw_event.c
+++ b/drivers/event/dsw/dsw_event.c
@@ -45,8 +45,8 @@
 	 * allocation.
 	 */
 	new_total_on_loan =
-	    __atomic_add_fetch(&dsw->credits_on_loan, acquired_credits,
-			       __ATOMIC_RELAXED);
+	    __atomic_fetch_add(&dsw->credits_on_loan, acquired_credits,
+			       __ATOMIC_RELAXED) + acquired_credits;
 
 	if (unlikely(new_total_on_loan > dsw->max_inflight)) {
 		/* Some other port took the last credits */
diff --git a/drivers/event/octeontx/timvf_worker.h b/drivers/event/octeontx/timvf_worker.h
index 3f1e77f..aa729f8 100644
--- a/drivers/event/octeontx/timvf_worker.h
+++ b/drivers/event/octeontx/timvf_worker.h
@@ -135,7 +135,7 @@
 {
 	const uint64_t v = ~(TIM_BUCKET_W1_M_NUM_ENTRIES <<
 			TIM_BUCKET_W1_S_NUM_ENTRIES);
-	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
+	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) & v;
 }
 
 static inline struct tim_mem_entry *
-- 
1.8.3.1


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

* [PATCH v3 05/16] net/af_xdp: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (3 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 04/16] drivers/event: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 06/16] net/cnxk: " Tyler Retzlaff
                     ` (11 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 2a20a69..c7786cc 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -979,7 +979,7 @@ static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
 			break;
 		xsk_socket__delete(rxq->xsk);
 
-		if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE)
+		if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1
 				== 0) {
 			(void)xsk_umem__delete(rxq->umem->umem);
 			xdp_umem_destroy(rxq->umem);
@@ -1710,7 +1710,7 @@ struct msg_internal {
 out_xsk:
 	xsk_socket__delete(rxq->xsk);
 out_umem:
-	if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) == 0)
+	if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0)
 		xdp_umem_destroy(rxq->umem);
 
 	return ret;
-- 
1.8.3.1


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

* [PATCH v3 06/16] net/cnxk: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (4 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 05/16] net/af_xdp: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 07/16] net/cxgbe: " Tyler Retzlaff
                     ` (10 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/net/cnxk/cn10k_tx.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/cnxk/cn10k_tx.h b/drivers/net/cnxk/cn10k_tx.h
index a72a803..c9ec01c 100644
--- a/drivers/net/cnxk/cn10k_tx.h
+++ b/drivers/net/cnxk/cn10k_tx.h
@@ -108,7 +108,7 @@
 retry:
 	while (__atomic_load_n(&txq->fc_cache_pkts, __ATOMIC_RELAXED) < 0)
 		;
-	cached = __atomic_sub_fetch(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE);
+	cached = __atomic_fetch_sub(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE) - req;
 	/* Check if there is enough space, else update and retry. */
 	if (cached < 0) {
 		/* Check if we have space else retry. */
@@ -302,7 +302,7 @@
 
 again:
 	fc_sw = txq->cpt_fc_sw;
-	val = __atomic_sub_fetch(fc_sw, nb_pkts, __ATOMIC_RELAXED);
+	val = __atomic_fetch_sub(fc_sw, nb_pkts, __ATOMIC_RELAXED) - nb_pkts;
 	if (likely(val >= 0))
 		return;
 
-- 
1.8.3.1


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

* [PATCH v3 07/16] net/cxgbe: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (5 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 06/16] net/cnxk: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 08/16] net/iavf: " Tyler Retzlaff
                     ` (9 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/net/cxgbe/clip_tbl.c | 2 +-
 drivers/net/cxgbe/mps_tcam.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/cxgbe/clip_tbl.c b/drivers/net/cxgbe/clip_tbl.c
index 072fc74..f64b922 100644
--- a/drivers/net/cxgbe/clip_tbl.c
+++ b/drivers/net/cxgbe/clip_tbl.c
@@ -55,7 +55,7 @@ void cxgbe_clip_release(struct rte_eth_dev *dev, struct clip_entry *ce)
 	int ret;
 
 	t4_os_lock(&ce->lock);
-	if (__atomic_sub_fetch(&ce->refcnt, 1, __ATOMIC_RELAXED) == 0) {
+	if (__atomic_fetch_sub(&ce->refcnt, 1, __ATOMIC_RELAXED) - 1 == 0) {
 		ret = clip6_release_mbox(dev, ce->addr);
 		if (ret)
 			dev_debug(adap, "CLIP FW DEL CMD failed: %d", ret);
diff --git a/drivers/net/cxgbe/mps_tcam.c b/drivers/net/cxgbe/mps_tcam.c
index abbf06e..c7cdf29 100644
--- a/drivers/net/cxgbe/mps_tcam.c
+++ b/drivers/net/cxgbe/mps_tcam.c
@@ -195,7 +195,7 @@ int cxgbe_mpstcam_remove(struct port_info *pi, u16 idx)
 					   entry->mask, idx, 1, pi->port_id,
 					   false);
 	else
-		ret = __atomic_sub_fetch(&entry->refcnt, 1, __ATOMIC_RELAXED);
+		ret = __atomic_fetch_sub(&entry->refcnt, 1, __ATOMIC_RELAXED) - 1;
 
 	if (ret == 0) {
 		reset_mpstcam_entry(entry);
-- 
1.8.3.1


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

* [PATCH v3 08/16] net/iavf: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (6 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 07/16] net/cxgbe: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 09/16] net/mlx5: " Tyler Retzlaff
                     ` (8 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/net/iavf/iavf_vchnl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 9adaadb..51d4fc7 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -120,7 +120,7 @@ struct iavf_event_handler {
 {
 	struct iavf_event_handler *handler = &event_handler;
 
-	if (__atomic_add_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 1)
+	if (__atomic_fetch_add(&handler->ndev, 1, __ATOMIC_RELAXED) + 1 != 1)
 		return 0;
 #if defined(RTE_EXEC_ENV_IS_WINDOWS) && RTE_EXEC_ENV_IS_WINDOWS != 0
 	int err = _pipe(handler->fd, MAX_EVENT_PENDING, O_BINARY);
@@ -149,7 +149,7 @@ struct iavf_event_handler {
 {
 	struct iavf_event_handler *handler = &event_handler;
 
-	if (__atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 0)
+	if (__atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED) - 1 != 0)
 		return;
 
 	int unused = pthread_cancel(handler->tid);
@@ -533,8 +533,8 @@ struct iavf_event_handler {
 				/* read message and it's expected one */
 				if (msg_opc == vf->pend_cmd) {
 					uint32_t cmd_count =
-					__atomic_sub_fetch(&vf->pend_cmd_count,
-							1, __ATOMIC_RELAXED);
+					__atomic_fetch_sub(&vf->pend_cmd_count,
+							1, __ATOMIC_RELAXED) - 1;
 					if (cmd_count == 0)
 						_notify_cmd(vf, msg_ret);
 				} else {
-- 
1.8.3.1


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

* [PATCH v3 09/16] net/mlx5: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (7 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 08/16] net/iavf: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 10/16] net/octeontx: " Tyler Retzlaff
                     ` (7 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/net/mlx5/linux/mlx5_verbs.c |  2 +-
 drivers/net/mlx5/mlx5.c             |  4 ++--
 drivers/net/mlx5/mlx5_flow.c        |  8 ++++----
 drivers/net/mlx5/mlx5_flow_dv.c     | 12 ++++++------
 drivers/net/mlx5/mlx5_flow_hw.c     | 14 +++++++-------
 drivers/net/mlx5/mlx5_hws_cnt.c     |  4 ++--
 drivers/net/mlx5/mlx5_rxq.c         |  6 +++---
 drivers/net/mlx5/mlx5_txq.c         |  2 +-
 8 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 67a7bec..ee5d072 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -1183,7 +1183,7 @@
 	if (!priv->lb_used)
 		return;
 	MLX5_ASSERT(__atomic_load_n(&sh->self_lb.refcnt, __ATOMIC_RELAXED));
-	if (!(__atomic_sub_fetch(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED))) {
+	if (!(__atomic_fetch_sub(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED) - 1)) {
 		if (sh->self_lb.qp) {
 			claim_zero(mlx5_glue->destroy_qp(sh->self_lb.qp));
 			sh->self_lb.qp = NULL;
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 41b1b12..044012d 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1068,7 +1068,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 		DRV_LOG(ERR, "Dynamic flex parser is not supported");
 		return -ENOTSUP;
 	}
-	if (__atomic_add_fetch(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) > 1)
+	if (__atomic_fetch_add(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) + 1 > 1)
 		return 0;
 
 	node.header_length_mode = MLX5_GRAPH_NODE_LEN_FIELD;
@@ -1123,7 +1123,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_internal_flex_parser_profile *fp = &priv->sh->srh_flex_parser;
 
-	if (__atomic_sub_fetch(&fp->refcnt, 1, __ATOMIC_RELAXED))
+	if (__atomic_fetch_sub(&fp->refcnt, 1, __ATOMIC_RELAXED) - 1)
 		return;
 	if (fp->fp)
 		mlx5_devx_cmd_destroy(fp->fp);
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 19f7f92..c742675 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -7833,7 +7833,7 @@ struct rte_flow *
 
 		tunnel = mlx5_find_tunnel_id(dev, flow->tunnel_id);
 		RTE_VERIFY(tunnel);
-		if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+		if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
 			mlx5_flow_tunnel_free(dev, tunnel);
 	}
 	flow_mreg_del_copy_action(dev, flow);
@@ -9746,9 +9746,9 @@ struct mlx5_flow_workspace*
 					 __ATOMIC_RELAXED);
 			continue;
 		}
-		if (__atomic_add_fetch(&age_param->sec_since_last_hit,
+		if (__atomic_fetch_add(&age_param->sec_since_last_hit,
 				       time_delta,
-				       __ATOMIC_RELAXED) <= age_param->timeout)
+				       __ATOMIC_RELAXED) + time_delta <= age_param->timeout)
 			continue;
 		/**
 		 * Hold the lock first, or if between the
@@ -11391,7 +11391,7 @@ struct tunnel_db_element_release_ctx {
 {
 	struct tunnel_db_element_release_ctx *ctx = x;
 	ctx->ret = 0;
-	if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+	if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
 		mlx5_flow_tunnel_free(dev, tunnel);
 }
 
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ca26f39..f04160e 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -6723,8 +6723,8 @@ struct mlx5_list_entry *
 		 * indirect action API, shared info is 1 before the reduction,
 		 * so this condition is failed and function doesn't return here.
 		 */
-		if (__atomic_sub_fetch(&cnt->shared_info.refcnt, 1,
-				       __ATOMIC_RELAXED))
+		if (__atomic_fetch_sub(&cnt->shared_info.refcnt, 1,
+				       __ATOMIC_RELAXED) - 1)
 			return;
 	}
 	cnt->pool = pool;
@@ -12797,7 +12797,7 @@ struct mlx5_list_entry *
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_aso_age_mng *mng = priv->sh->aso_age_mng;
 	struct mlx5_aso_age_action *age = flow_aso_age_get_by_idx(dev, age_idx);
-	uint32_t ret = __atomic_sub_fetch(&age->refcnt, 1, __ATOMIC_RELAXED);
+	uint32_t ret = __atomic_fetch_sub(&age->refcnt, 1, __ATOMIC_RELAXED) - 1;
 
 	if (!ret) {
 		flow_dv_aso_age_remove_from_age(dev, age);
@@ -13193,7 +13193,7 @@ struct mlx5_list_entry *
 	/* Cannot release when CT is in the ASO SQ. */
 	if (state == ASO_CONNTRACK_WAIT || state == ASO_CONNTRACK_QUERY)
 		return -1;
-	ret = __atomic_sub_fetch(&ct->refcnt, 1, __ATOMIC_RELAXED);
+	ret = __atomic_fetch_sub(&ct->refcnt, 1, __ATOMIC_RELAXED) - 1;
 	if (!ret) {
 		if (ct->dr_action_orig) {
 #ifdef HAVE_MLX5_DR_ACTION_ASO_CT
@@ -15582,8 +15582,8 @@ struct mlx5_list_entry *
 				sh->geneve_tlv_option_resource;
 	rte_spinlock_lock(&sh->geneve_tlv_opt_sl);
 	if (geneve_opt_resource) {
-		if (!(__atomic_sub_fetch(&geneve_opt_resource->refcnt, 1,
-					 __ATOMIC_RELAXED))) {
+		if (!(__atomic_fetch_sub(&geneve_opt_resource->refcnt, 1,
+					 __ATOMIC_RELAXED) - 1)) {
 			claim_zero(mlx5_devx_cmd_destroy
 					(geneve_opt_resource->obj));
 			mlx5_free(sh->geneve_tlv_option_resource);
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index a4328a9..8882fc7 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -458,7 +458,7 @@ static int flow_hw_translate_group(struct rte_eth_dev *dev,
 	}
 
 	if (acts->mark)
-		if (!__atomic_sub_fetch(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED))
+		if (!(__atomic_fetch_sub(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED) - 1))
 			flow_hw_rxq_flag_set(dev, false);
 
 	if (acts->jump) {
@@ -3268,8 +3268,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
 			rte_errno = EINVAL;
 			goto it_error;
 		}
-		ret = __atomic_add_fetch(&item_templates[i]->refcnt, 1,
-					 __ATOMIC_RELAXED);
+		ret = __atomic_fetch_add(&item_templates[i]->refcnt, 1,
+					 __ATOMIC_RELAXED) + 1;
 		if (ret <= 1) {
 			rte_errno = EINVAL;
 			goto it_error;
@@ -3282,8 +3282,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
 	for (i = 0; i < nb_action_templates; i++) {
 		uint32_t ret;
 
-		ret = __atomic_add_fetch(&action_templates[i]->refcnt, 1,
-					 __ATOMIC_RELAXED);
+		ret = __atomic_fetch_add(&action_templates[i]->refcnt, 1,
+					 __ATOMIC_RELAXED) + 1;
 		if (ret <= 1) {
 			rte_errno = EINVAL;
 			goto at_error;
@@ -7726,8 +7726,8 @@ void flow_hw_clear_tags_set(struct rte_eth_dev *dev)
 {
 	uint32_t refcnt;
 
-	refcnt = __atomic_sub_fetch(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
-				    __ATOMIC_RELAXED);
+	refcnt = __atomic_fetch_sub(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
+				    __ATOMIC_RELAXED) - 1;
 	if (refcnt > 0)
 		return;
 	mlx5_flow_hw_flow_metadata_esw_en = 0;
diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c
index d6a017a..d98df68 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.c
+++ b/drivers/net/mlx5/mlx5_hws_cnt.c
@@ -192,8 +192,8 @@
 			}
 			param->accumulator_hits = 0;
 		}
-		if (__atomic_add_fetch(&param->sec_since_last_hit, time_delta,
-				       __ATOMIC_RELAXED) <=
+		if (__atomic_fetch_add(&param->sec_since_last_hit, time_delta,
+				       __ATOMIC_RELAXED) + time_delta <=
 		   __atomic_load_n(&param->timeout, __ATOMIC_RELAXED))
 			continue;
 		/* Prepare the relevant ring for this AGE parameter */
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 6e99c4d..ad8fd13 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2042,7 +2042,7 @@ struct mlx5_rxq_priv *
 
 	if (rxq == NULL)
 		return 0;
-	return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+	return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
 }
 
 /**
@@ -2141,7 +2141,7 @@ struct mlx5_external_rxq *
 {
 	struct mlx5_external_rxq *rxq = mlx5_ext_rxq_get(dev, idx);
 
-	return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+	return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
 }
 
 /**
@@ -2462,7 +2462,7 @@ struct mlx5_ind_table_obj *
 	unsigned int ret;
 
 	rte_rwlock_write_lock(&priv->ind_tbls_lock);
-	ret = __atomic_sub_fetch(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
+	ret = __atomic_fetch_sub(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED) - 1;
 	if (!ret)
 		LIST_REMOVE(ind_tbl, next);
 	rte_rwlock_write_unlock(&priv->ind_tbls_lock);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 1e0e61a..8cb52b0 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -1203,7 +1203,7 @@ struct mlx5_txq_ctrl *
 	if (priv->txqs == NULL || (*priv->txqs)[idx] == NULL)
 		return 0;
 	txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
-	if (__atomic_sub_fetch(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) > 1)
+	if (__atomic_fetch_sub(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) - 1 > 1)
 		return 1;
 	if (txq_ctrl->obj) {
 		priv->obj_ops.txq_obj_release(txq_ctrl->obj);
-- 
1.8.3.1


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

* [PATCH v3 10/16] net/octeontx: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (8 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 09/16] net/mlx5: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 11/16] raw/ifpga: " Tyler Retzlaff
                     ` (6 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/net/octeontx/octeontx_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index d52a3e7..a21ed80 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -559,7 +559,7 @@ enum octeontx_link_speed {
 		return 0;
 
 	/* Stopping/closing event device once all eth ports are closed. */
-	if (__atomic_sub_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) == 0) {
+	if (__atomic_fetch_sub(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0) {
 		rte_event_dev_stop(nic->evdev);
 		rte_event_dev_close(nic->evdev);
 	}
-- 
1.8.3.1


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

* [PATCH v3 11/16] raw/ifpga: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (9 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 10/16] net/octeontx: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 12/16] bbdev: " Tyler Retzlaff
                     ` (5 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 1020adc..ae3f79d 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -573,7 +573,7 @@ static int set_surprise_link_check_aer(
 
 	dev->poll_enabled = 0;
 
-	if (!__atomic_sub_fetch(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) &&
+	if (!(__atomic_fetch_sub(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) - 1) &&
 		ifpga_monitor_start_thread) {
 		ret = pthread_cancel(ifpga_monitor_start_thread);
 		if (ret)
-- 
1.8.3.1


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

* [PATCH v3 12/16] bbdev: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (10 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 11/16] raw/ifpga: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 13/16] eal: " Tyler Retzlaff
                     ` (4 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/bbdev/rte_bbdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c
index 1521cdb..9df0837 100644
--- a/lib/bbdev/rte_bbdev.c
+++ b/lib/bbdev/rte_bbdev.c
@@ -250,8 +250,8 @@ struct rte_bbdev *
 	}
 
 	/* clear shared BBDev Data if no process is using the device anymore */
-	if (__atomic_sub_fetch(&bbdev->data->process_cnt, 1,
-			      __ATOMIC_RELAXED) == 0)
+	if (__atomic_fetch_sub(&bbdev->data->process_cnt, 1,
+			      __ATOMIC_RELAXED) - 1 == 0)
 		memset(bbdev->data, 0, sizeof(*bbdev->data));
 
 	memset(bbdev, 0, sizeof(*bbdev));
-- 
1.8.3.1


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

* [PATCH v3 13/16] eal: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (11 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 12/16] bbdev: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 14/16] ipsec: " Tyler Retzlaff
                     ` (3 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/eal/include/generic/rte_rwlock.h |  8 ++++----
 lib/eal/ppc/include/rte_atomic.h     | 16 ++++++++--------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/eal/include/generic/rte_rwlock.h b/lib/eal/include/generic/rte_rwlock.h
index d45c22c..71e2d8d 100644
--- a/lib/eal/include/generic/rte_rwlock.h
+++ b/lib/eal/include/generic/rte_rwlock.h
@@ -97,8 +97,8 @@
 			rte_pause();
 
 		/* Try to get read lock */
-		x = __atomic_add_fetch(&rwl->cnt, RTE_RWLOCK_READ,
-				       __ATOMIC_ACQUIRE);
+		x = __atomic_fetch_add(&rwl->cnt, RTE_RWLOCK_READ,
+				       __ATOMIC_ACQUIRE) + RTE_RWLOCK_READ;
 
 		/* If no writer, then acquire was successful */
 		if (likely(!(x & RTE_RWLOCK_MASK)))
@@ -134,8 +134,8 @@
 		return -EBUSY;
 
 	/* Try to get read lock */
-	x = __atomic_add_fetch(&rwl->cnt, RTE_RWLOCK_READ,
-			       __ATOMIC_ACQUIRE);
+	x = __atomic_fetch_add(&rwl->cnt, RTE_RWLOCK_READ,
+			       __ATOMIC_ACQUIRE) + RTE_RWLOCK_READ;
 
 	/* Back out if writer raced in */
 	if (unlikely(x & RTE_RWLOCK_MASK)) {
diff --git a/lib/eal/ppc/include/rte_atomic.h b/lib/eal/ppc/include/rte_atomic.h
index 663b4d3..ffabd98 100644
--- a/lib/eal/ppc/include/rte_atomic.h
+++ b/lib/eal/ppc/include/rte_atomic.h
@@ -71,12 +71,12 @@ static inline int rte_atomic16_test_and_set(rte_atomic16_t *v)
 
 static inline int rte_atomic16_inc_and_test(rte_atomic16_t *v)
 {
-	return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0;
 }
 
 static inline int rte_atomic16_dec_and_test(rte_atomic16_t *v)
 {
-	return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0;
 }
 
 static inline uint16_t
@@ -113,12 +113,12 @@ static inline int rte_atomic32_test_and_set(rte_atomic32_t *v)
 
 static inline int rte_atomic32_inc_and_test(rte_atomic32_t *v)
 {
-	return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0;
 }
 
 static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)
 {
-	return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0;
 }
 
 static inline uint32_t
@@ -181,23 +181,23 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)
 static inline int64_t
 rte_atomic64_add_return(rte_atomic64_t *v, int64_t inc)
 {
-	return __atomic_add_fetch(&v->cnt, inc, __ATOMIC_ACQUIRE);
+	return __atomic_fetch_add(&v->cnt, inc, __ATOMIC_ACQUIRE) + inc;
 }
 
 static inline int64_t
 rte_atomic64_sub_return(rte_atomic64_t *v, int64_t dec)
 {
-	return __atomic_sub_fetch(&v->cnt, dec, __ATOMIC_ACQUIRE);
+	return __atomic_fetch_sub(&v->cnt, dec, __ATOMIC_ACQUIRE) - dec;
 }
 
 static inline int rte_atomic64_inc_and_test(rte_atomic64_t *v)
 {
-	return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0;
 }
 
 static inline int rte_atomic64_dec_and_test(rte_atomic64_t *v)
 {
-	return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+	return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0;
 }
 
 static inline int rte_atomic64_test_and_set(rte_atomic64_t *v)
-- 
1.8.3.1


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

* [PATCH v3 14/16] ipsec: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (12 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 13/16] eal: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 15/16] mbuf: " Tyler Retzlaff
                     ` (2 subsequent siblings)
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/ipsec/ipsec_sqn.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ipsec/ipsec_sqn.h b/lib/ipsec/ipsec_sqn.h
index 2636cb1..505950e 100644
--- a/lib/ipsec/ipsec_sqn.h
+++ b/lib/ipsec/ipsec_sqn.h
@@ -128,7 +128,7 @@
 
 	n = *num;
 	if (SQN_ATOMIC(sa))
-		sqn = __atomic_add_fetch(&sa->sqn.outb, n, __ATOMIC_RELAXED);
+		sqn = __atomic_fetch_add(&sa->sqn.outb, n, __ATOMIC_RELAXED) + n;
 	else {
 		sqn = sa->sqn.outb + n;
 		sa->sqn.outb = sqn;
-- 
1.8.3.1


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

* [PATCH v3 15/16] mbuf: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (13 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 14/16] ipsec: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-03-20 19:00   ` [PATCH v3 16/16] rcu: " Tyler Retzlaff
  2023-04-25  9:10   ` [PATCH v3 00/16] replace __atomic operations returning new value David Marchand
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/mbuf/rte_mbuf.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
index bc41eac..913c459 100644
--- a/lib/mbuf/rte_mbuf.h
+++ b/lib/mbuf/rte_mbuf.h
@@ -381,8 +381,8 @@ struct rte_pktmbuf_pool_private {
 static inline uint16_t
 __rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value)
 {
-	return __atomic_add_fetch(&m->refcnt, (uint16_t)value,
-				 __ATOMIC_ACQ_REL);
+	return __atomic_fetch_add(&m->refcnt, value,
+				 __ATOMIC_ACQ_REL) + value;
 }
 
 /**
@@ -502,8 +502,8 @@ struct rte_pktmbuf_pool_private {
 		return (uint16_t)value;
 	}
 
-	return __atomic_add_fetch(&shinfo->refcnt, (uint16_t)value,
-				 __ATOMIC_ACQ_REL);
+	return __atomic_fetch_add(&shinfo->refcnt, value,
+				 __ATOMIC_ACQ_REL) + value;
 }
 
 /** Mbuf prefetch */
@@ -1315,8 +1315,8 @@ static inline int __rte_pktmbuf_pinned_extbuf_decref(struct rte_mbuf *m)
 	 * Direct usage of add primitive to avoid
 	 * duplication of comparing with one.
 	 */
-	if (likely(__atomic_add_fetch(&shinfo->refcnt, (uint16_t)-1,
-				     __ATOMIC_ACQ_REL)))
+	if (likely(__atomic_fetch_add(&shinfo->refcnt, -1,
+				     __ATOMIC_ACQ_REL) - 1))
 		return 1;
 
 	/* Reinitialize counter before mbuf freeing. */
-- 
1.8.3.1


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

* [PATCH v3 16/16] rcu: use previous value atomic fetch operations
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (14 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 15/16] mbuf: " Tyler Retzlaff
@ 2023-03-20 19:00   ` Tyler Retzlaff
  2023-04-25  9:10   ` [PATCH v3 00/16] replace __atomic operations returning new value David Marchand
  16 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-03-20 19:00 UTC (permalink / raw)
  To: dev
  Cc: Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram, Tyler Retzlaff

Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/rcu/rte_rcu_qsbr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h
index ccae5d5..1aa078e 100644
--- a/lib/rcu/rte_rcu_qsbr.h
+++ b/lib/rcu/rte_rcu_qsbr.h
@@ -462,7 +462,7 @@ struct rte_rcu_qsbr_dq_parameters {
 	 * structure are visible to the workers before the token
 	 * update is visible.
 	 */
-	t = __atomic_add_fetch(&v->token, 1, __ATOMIC_RELEASE);
+	t = __atomic_fetch_add(&v->token, 1, __ATOMIC_RELEASE) + 1;
 
 	return t;
 }
-- 
1.8.3.1


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

* Re: [PATCH v2 00/16] replace __atomic operations returning new value
  2023-03-16 16:17       ` Tyler Retzlaff
@ 2023-04-18 18:11         ` Tyler Retzlaff
  0 siblings, 0 replies; 59+ messages in thread
From: Tyler Retzlaff @ 2023-04-18 18:11 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Bruce Richardson, dev, Honnappa.Nagarahalli, Ruifeng.Wang

On Thu, Mar 16, 2023 at 09:17:05AM -0700, Tyler Retzlaff wrote:
> On Thu, Mar 16, 2023 at 04:25:41PM +0100, Thomas Monjalon wrote:
> > 16/03/2023 11:03, Bruce Richardson:
> > > On Wed, Mar 15, 2023 at 02:15:29PM -0700, Tyler Retzlaff wrote:
> > > > This series replaces uses of __atomic_{add,and,or,sub,xor}_fetch with
> > > > __atomic_fetch_{add,and,or,sub,xor} intrinsics where the new value
> > > > is used.
> > [...]
> > > > Tyler Retzlaff (16):
> > > >   app/test: use previous value atomic fetch operations
> > > >   common/cnxk: use previous value atomic fetch operations
> > > >   common/mlx5: use previous value atomic fetch operations
> > > >   drivers/event: use previous value atomic fetch operations
> > > >   net/af_xdp: use previous value atomic fetch operations
> > > >   net/cnxk: use previous value atomic fetch operations
> > > >   net/cxgbe: use previous value atomic fetch operations
> > > >   net/iavf: use previous value atomic fetch operations
> > > >   net/mlx5: use previous value atomic fetch operations
> > > >   net/octeontx: use previous value atomic fetch operations
> > > >   raw/ifpga: use previous value atomic fetch operations
> > > >   bbdev: use previous value atomic fetch operations
> > > >   eal: use previous value atomic fetch operations
> > > >   ipsec: use previous value atomic fetch operations
> > > >   mbuf: use previous value atomic fetch operations
> > > >   rcu: use previous value atomic fetch operations
> > > > 
> > > I am wondering how we go about ensuring that we don't introduce any more of
> > > these atomic_X_fetch intrinsics. Is there some way we can add a compiler
> > > warning for them or have a checkpatch check, for example?
> > 
> > In devtools/checkpatches.sh, we are checking for these patterns:
> > 	rte_atomic[0-9][0-9]_.*\(
> > 	__atomic_thread_fence\(
> > 
> > Feel free to add more "forbidden patterns".
> > 
> > 
> 
> yes, i was going to do this before end of week but got interrupted by
> other work. i will introduce a patch for checkpatches.sh standalone
> asap that can be merged before these changes.

just fyi, there is a series up for this.

https://patchwork.dpdk.org/project/dpdk/list/?series=27613

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

* Re: [PATCH v3 00/16] replace __atomic operations returning new value
  2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
                     ` (15 preceding siblings ...)
  2023-03-20 19:00   ` [PATCH v3 16/16] rcu: " Tyler Retzlaff
@ 2023-04-25  9:10   ` David Marchand
  16 siblings, 0 replies; 59+ messages in thread
From: David Marchand @ 2023-04-25  9:10 UTC (permalink / raw)
  To: Tyler Retzlaff
  Cc: dev, Honnappa.Nagarahalli, Ruifeng.Wang, thomas, pbhagavatula,
	ndabilpuram

On Mon, Mar 20, 2023 at 8:01 PM Tyler Retzlaff
<roretzla@linux.microsoft.com> wrote:
>
> This series replaces uses of __atomic_{add,and,or,sub,xor}_fetch with
> __atomic_fetch_{add,and,or,sub,xor} intrinsics where the new value
> is used.
>
> This series is being separated from the other similar series in
> an effort to reduce the chance of mistakes being spotted in review
> since the usages in this case consume the returned / new value.
>
> v3:
>     * incorporate Reviewed-by and Acked-by received so far
>     * rebase series on -rc3 to get a fresh CI run
>
> v2:
>     * remove unnecessary casts of signed to unsigned arguments when
>       using generic __atomic builtins.
>     * remove inappropriate cast of signed negative value on addend.
>
> Tyler Retzlaff (16):
>   app/test: use previous value atomic fetch operations
>   common/cnxk: use previous value atomic fetch operations
>   common/mlx5: use previous value atomic fetch operations
>   drivers/event: use previous value atomic fetch operations
>   net/af_xdp: use previous value atomic fetch operations
>   net/cnxk: use previous value atomic fetch operations
>   net/cxgbe: use previous value atomic fetch operations
>   net/iavf: use previous value atomic fetch operations
>   net/mlx5: use previous value atomic fetch operations
>   net/octeontx: use previous value atomic fetch operations
>   raw/ifpga: use previous value atomic fetch operations
>   bbdev: use previous value atomic fetch operations
>   eal: use previous value atomic fetch operations
>   ipsec: use previous value atomic fetch operations
>   mbuf: use previous value atomic fetch operations
>   rcu: use previous value atomic fetch operations
>
>  app/test/test_ring_perf.c               |  2 +-
>  drivers/common/cnxk/roc_ae.c            |  2 +-
>  drivers/common/cnxk/roc_ae_fpm_tables.c |  2 +-
>  drivers/common/cnxk/roc_npa.c           |  2 +-
>  drivers/common/mlx5/linux/mlx5_nl.c     |  2 +-
>  drivers/common/mlx5/mlx5_common_mr.c    |  8 ++++----
>  drivers/common/mlx5/mlx5_common_utils.c |  8 ++++----
>  drivers/event/cnxk/cnxk_tim_worker.h    |  2 +-
>  drivers/event/dsw/dsw_event.c           |  4 ++--
>  drivers/event/octeontx/timvf_worker.h   |  2 +-
>  drivers/net/af_xdp/rte_eth_af_xdp.c     |  4 ++--
>  drivers/net/cnxk/cn10k_tx.h             |  4 ++--
>  drivers/net/cxgbe/clip_tbl.c            |  2 +-
>  drivers/net/cxgbe/mps_tcam.c            |  2 +-
>  drivers/net/iavf/iavf_vchnl.c           |  8 ++++----
>  drivers/net/mlx5/linux/mlx5_verbs.c     |  2 +-
>  drivers/net/mlx5/mlx5.c                 |  4 ++--
>  drivers/net/mlx5/mlx5_flow.c            |  8 ++++----
>  drivers/net/mlx5/mlx5_flow_dv.c         | 12 ++++++------
>  drivers/net/mlx5/mlx5_flow_hw.c         | 14 +++++++-------
>  drivers/net/mlx5/mlx5_hws_cnt.c         |  4 ++--
>  drivers/net/mlx5/mlx5_rxq.c             |  6 +++---
>  drivers/net/mlx5/mlx5_txq.c             |  2 +-
>  drivers/net/octeontx/octeontx_ethdev.c  |  2 +-
>  drivers/raw/ifpga/ifpga_rawdev.c        |  2 +-
>  lib/bbdev/rte_bbdev.c                   |  4 ++--
>  lib/eal/include/generic/rte_rwlock.h    |  8 ++++----
>  lib/eal/ppc/include/rte_atomic.h        | 16 ++++++++--------
>  lib/ipsec/ipsec_sqn.h                   |  2 +-
>  lib/mbuf/rte_mbuf.h                     | 12 ++++++------
>  lib/rcu/rte_rcu_qsbr.h                  |  2 +-
>  31 files changed, 77 insertions(+), 77 deletions(-)
>

LGTM.
Series applied, thanks.


-- 
David Marchand


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

end of thread, other threads:[~2023-04-25  9:10 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 02/16] common/cnxk: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 03/16] common/mlx5: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 04/16] drivers/event: " Tyler Retzlaff
2023-03-13  7:02   ` [EXT] " Pavan Nikhilesh Bhagavatula
2023-03-10 22:15 ` [PATCH 05/16] net/af_xdp: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 06/16] net/cnxk: " Tyler Retzlaff
2023-03-13  6:45   ` [EXT] " Nithin Kumar Dabilpuram
2023-03-10 22:15 ` [PATCH 07/16] net/cxgbe: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 08/16] net/iavf: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 09/16] net/mlx5: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 10/16] net/octeontx: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 11/16] raw/ifpga: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 12/16] bbdev: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 13/16] eal: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 14/16] ipsec: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 15/16] mbuf: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 16/16] rcu: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 02/16] common/cnxk: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 03/16] common/mlx5: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 04/16] drivers/event: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 05/16] net/af_xdp: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 06/16] net/cnxk: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 07/16] net/cxgbe: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 08/16] net/iavf: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 09/16] net/mlx5: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 10/16] net/octeontx: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 11/16] raw/ifpga: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 12/16] bbdev: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 13/16] eal: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 14/16] ipsec: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 15/16] mbuf: " Tyler Retzlaff
2023-03-15 21:15   ` [PATCH v2 16/16] rcu: " Tyler Retzlaff
2023-03-16 10:03   ` [PATCH v2 00/16] replace __atomic operations returning new value Bruce Richardson
2023-03-16 15:25     ` Thomas Monjalon
2023-03-16 16:17       ` Tyler Retzlaff
2023-04-18 18:11         ` Tyler Retzlaff
2023-03-20 10:24   ` Ruifeng Wang
2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 02/16] common/cnxk: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 03/16] common/mlx5: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 04/16] drivers/event: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 05/16] net/af_xdp: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 06/16] net/cnxk: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 07/16] net/cxgbe: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 08/16] net/iavf: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 09/16] net/mlx5: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 10/16] net/octeontx: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 11/16] raw/ifpga: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 12/16] bbdev: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 13/16] eal: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 14/16] ipsec: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 15/16] mbuf: " Tyler Retzlaff
2023-03-20 19:00   ` [PATCH v3 16/16] rcu: " Tyler Retzlaff
2023-04-25  9:10   ` [PATCH v3 00/16] replace __atomic operations returning new value David Marchand

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).