use __atomic operations returning new value
PATCH 2/16 common/cnxk: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- 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(-)
drivers/common/cnxk/roc_ae.c +1 -1
@@ -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); }
drivers/common/cnxk/roc_ae_fpm_tables.c +1 -1
@@ -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); }
drivers/common/cnxk/roc_npa.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
PATCH 1/16 app/test: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- app/test/test_ring_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_ring_perf.c +1 -1
@@ -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
Signature · 1 line
1.8.3.1
cover use __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 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(-)
Signature · 1 line
1.8.3.1
PATCH 4/16 drivers/event: use previous value atomic fetch operations
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.
--- 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(-)
drivers/event/cnxk/cnxk_tim_worker.h +1 -1
@@ -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
drivers/event/dsw/dsw_event.c +2 -2
@@ -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 */
drivers/event/octeontx/timvf_worker.h +1 -1
@@ -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 *
Signature · 1 line
1.8.3.1
PATCH 3/16 common/mlx5: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- 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(-)
drivers/common/mlx5/linux/mlx5_nl.c +1 -1
@@ -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.
drivers/common/mlx5/mlx5_common_mr.c +4 -4
@@ -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; }
drivers/common/mlx5/mlx5_common_utils.c +4 -4
@@ -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 )) {
Signature · 1 line
1.8.3.1
PATCH 6/16 net/cnxk: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/cnxk/cn10k_tx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/cnxk/cn10k_tx.h +2 -2
@@ -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 ;
Signature · 1 line
1.8.3.1
PATCH 8/16 net/iavf: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/iavf/iavf_vchnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/iavf/iavf_vchnl.c +4 -4
@@ -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 {
Signature · 1 line
1.8.3.1
PATCH 11/16 raw/ifpga: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
@@ -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)
Signature · 1 line
1.8.3.1
PATCH 10/16 net/octeontx: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/octeontx/octeontx_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/octeontx/octeontx_ethdev.c +1 -1
@@ -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); }
Signature · 1 line
1.8.3.1
PATCH 7/16 net/cxgbe: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/cxgbe/clip_tbl.c | 2 +- drivers/net/cxgbe/mps_tcam.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/cxgbe/clip_tbl.c +1 -1
@@ -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);
drivers/net/cxgbe/mps_tcam.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
PATCH 5/16 net/af_xdp: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/af_xdp/rte_eth_af_xdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +2 -2
@@ -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;
Signature · 1 line
1.8.3.1
PATCH 12/16 bbdev: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/bbdev/rte_bbdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bbdev/rte_bbdev.c +2 -2
@@ -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));
Signature · 1 line
1.8.3.1
PATCH 9/16 net/mlx5: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- 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(-)
drivers/net/mlx5/linux/mlx5_verbs.c +1 -1
@@ -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 ;
drivers/net/mlx5/mlx5.c +2 -2
@@ -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);
drivers/net/mlx5/mlx5_flow.c +4 -4
@@ -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); }
drivers/net/mlx5/mlx5_flow_dv.c +6 -6
@@ -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);
drivers/net/mlx5/mlx5_flow_hw.c +7 -7
@@ -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 ;
drivers/net/mlx5/mlx5_hws_cnt.c +2 -2
@@ -192,8 +192,8 @@ } param->accumulator_hits =0 ; } -if (__atomic_add_fetch (¶m->sec_since_last_hit, time_delta, - __ATOMIC_RELAXED) <= +if (__atomic_fetch_add (¶m->sec_since_last_hit, time_delta, + __ATOMIC_RELAXED) + time_delta <=__atomic_load_n (¶m->timeout, __ATOMIC_RELAXED))continue ;/* Prepare the relevant ring for this AGE parameter */
drivers/net/mlx5/mlx5_rxq.c +3 -3
@@ -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);
drivers/net/mlx5/mlx5_txq.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
PATCH 14/16 ipsec: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/ipsec/ipsec_sqn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ipsec/ipsec_sqn.h +1 -1
@@ -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;
Signature · 1 line
1.8.3.1
PATCH 15/16 mbuf: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/mbuf/rte_mbuf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/mbuf/rte_mbuf.h +6 -6
@@ -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. */
Signature · 1 line
1.8.3.1
PATCH 13/16 eal: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/eal/include/generic/rte_rwlock.h | 8 ++++---- lib/eal/ppc/include/rte_atomic.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-)
lib/eal/include/generic/rte_rwlock.h +4 -4
@@ -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 )) {
lib/eal/ppc/include/rte_atomic.h +8 -8
@@ -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)
Signature · 1 line
1.8.3.1
PATCH 16/16 rcu: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/rcu/rte_rcu_qsbr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rcu/rte_rcu_qsbr.h +1 -1
@@ -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; }
Signature · 1 line
1.8.3.1
RE: [EXT] [PATCH 06/16] net/cnxk: use previous value atomic fetch operations
In reply to Tyler RetzlaffQuoted 45 lines
-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Saturday, March 11, 2023 3:45 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Tyler Retzlaff <[email protected]>
Subject: [EXT] [PATCH 06/16] net/cnxk: use previous value atomic fetch operationsExternal 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 <[email protected]>--- drivers/net/cnxk/cn10k_tx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/cnxk/cn10k_tx.h +1
-1@@ -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 ) {drivers/net/cnxk/cn10k_tx.h +1
-2/* 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
RE: [EXT] [PATCH 04/16] drivers/event: use previous value atomic fetch operations
In reply to Tyler RetzlaffQuoted 11 lines
-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Saturday, March 11, 2023 3:45 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Tyler Retzlaff <[email protected]>
Subject: [EXT] [PATCH 04/16]drivers/event: use previous value atomic fetch operations
Quoted 8 lines
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 <[email protected]>
Quoted 55 lines
--- 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(-)drivers/event/cnxk/cnxk_tim_worker.h +1
-1@@ -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_tdrivers/event/dsw/dsw_event.c +2
-2@@ -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 */ drivers/event/octeontx/timvf_worker.h +1
-1@@ -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
PATCH v2 1/16 app/test: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- app/test/test_ring_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_ring_perf.c +1 -1
@@ -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
Signature · 1 line
1.8.3.1
PATCH v2 2/16 common/cnxk: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- 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(-)
drivers/common/cnxk/roc_ae.c +1 -1
@@ -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); }
drivers/common/cnxk/roc_ae_fpm_tables.c +1 -1
@@ -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); }
drivers/common/cnxk/roc_npa.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
PATCH v2 4/16 drivers/event: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- 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(-)
drivers/event/cnxk/cnxk_tim_worker.h +1 -1
@@ -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
drivers/event/dsw/dsw_event.c +2 -2
@@ -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 */
drivers/event/octeontx/timvf_worker.h +1 -1
@@ -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 *
Signature · 1 line
1.8.3.1
v2 cover replace __atomic operations returning new value
In reply to Tyler RetzlaffThis 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(-)
Signature · 1 line
1.8.3.1
PATCH v2 3/16 common/mlx5: use previous value atomic fetch operations
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.
--- 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(-)
drivers/common/mlx5/linux/mlx5_nl.c +1 -1
@@ -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.
drivers/common/mlx5/mlx5_common_mr.c +4 -4
@@ -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; }
drivers/common/mlx5/mlx5_common_utils.c +4 -4
@@ -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 )) {
Signature · 1 line
1.8.3.1
PATCH v2 5/16 net/af_xdp: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/af_xdp/rte_eth_af_xdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +2 -2
@@ -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;
Signature · 1 line
1.8.3.1
PATCH v2 6/16 net/cnxk: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/cnxk/cn10k_tx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/cnxk/cn10k_tx.h +2 -2
@@ -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 ;
Signature · 1 line
1.8.3.1
PATCH v2 7/16 net/cxgbe: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/cxgbe/clip_tbl.c | 2 +- drivers/net/cxgbe/mps_tcam.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/cxgbe/clip_tbl.c +1 -1
@@ -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);
drivers/net/cxgbe/mps_tcam.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
PATCH v2 8/16 net/iavf: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/iavf/iavf_vchnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/iavf/iavf_vchnl.c +4 -4
@@ -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 {
Signature · 1 line
1.8.3.1
PATCH v2 11/16 raw/ifpga: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
@@ -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)
Signature · 1 line
1.8.3.1
PATCH v2 9/16 net/mlx5: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- 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(-)
drivers/net/mlx5/linux/mlx5_verbs.c +1 -1
@@ -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 ;
drivers/net/mlx5/mlx5.c +2 -2
@@ -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);
drivers/net/mlx5/mlx5_flow.c +4 -4
@@ -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); }
drivers/net/mlx5/mlx5_flow_dv.c +6 -6
@@ -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);
drivers/net/mlx5/mlx5_flow_hw.c +7 -7
@@ -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 ;
drivers/net/mlx5/mlx5_hws_cnt.c +2 -2
@@ -192,8 +192,8 @@ } param->accumulator_hits =0 ; } -if (__atomic_add_fetch (¶m->sec_since_last_hit, time_delta, - __ATOMIC_RELAXED) <= +if (__atomic_fetch_add (¶m->sec_since_last_hit, time_delta, + __ATOMIC_RELAXED) + time_delta <=__atomic_load_n (¶m->timeout, __ATOMIC_RELAXED))continue ;/* Prepare the relevant ring for this AGE parameter */
drivers/net/mlx5/mlx5_rxq.c +3 -3
@@ -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);
drivers/net/mlx5/mlx5_txq.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
PATCH v2 14/16 ipsec: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/ipsec/ipsec_sqn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ipsec/ipsec_sqn.h +1 -1
@@ -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;
Signature · 1 line
1.8.3.1
PATCH v2 10/16 net/octeontx: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/octeontx/octeontx_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/octeontx/octeontx_ethdev.c +1 -1
@@ -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); }
Signature · 1 line
1.8.3.1
PATCH v2 12/16 bbdev: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/bbdev/rte_bbdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bbdev/rte_bbdev.c +2 -2
@@ -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));
Signature · 1 line
1.8.3.1
PATCH v2 13/16 eal: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/eal/include/generic/rte_rwlock.h | 8 ++++---- lib/eal/ppc/include/rte_atomic.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-)
lib/eal/include/generic/rte_rwlock.h +4 -4
@@ -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 )) {
lib/eal/ppc/include/rte_atomic.h +8 -8
@@ -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)
Signature · 1 line
1.8.3.1
PATCH v2 15/16 mbuf: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/mbuf/rte_mbuf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/mbuf/rte_mbuf.h +6 -6
@@ -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. */
Signature · 1 line
1.8.3.1
PATCH v2 16/16 rcu: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/rcu/rte_rcu_qsbr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rcu/rte_rcu_qsbr.h +1 -1
@@ -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; }
Signature · 1 line
1.8.3.1
Re: [PATCH v2 00/16] replace __atomic operations returning new value
In reply to Tyler RetzlaffQuoted 22 lines · 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__atomicbuiltins.
* 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 operationsdrivers/event: use previous value atomic fetch operationsnet/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
Quoted 9 lines
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?
Re: [PATCH v2 00/16] replace __atomic operations returning new value
16/03/2023 11:03, Bruce Richardson:
Quoted 4 lines · Tyler Retzlaff
Quoted 3 lines
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.
[...]
Quoted 18 lines
Quoted 9 lines
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 operationsdrivers/event: use previous value atomic fetch operationsnet/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 operationsQuoted 9 lines
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
Quoted 3 lines
I am wondering how we go about ensuring that we don't introduce any more of these
atomic_X_fetchintrinsics. 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".
Re: [PATCH v2 00/16] replace __atomic operations returning new value
Quoted 28 lines · Thomas Monjalon
16/03/2023 11:03, Bruce Richardson:
Quoted 4 lines · Tyler Retzlaff
Quoted 3 lines
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.
[...]
Quoted 18 lines
Quoted 9 lines
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 operationsdrivers/event: use previous value atomic fetch operationsnet/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 operationsQuoted 9 lines
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 operationsQuoted 3 lines
I am wondering how we go about ensuring that we don't introduce any more of these
atomic_X_fetchintrinsics. Is there some way we can add a compiler warning for them or have a checkpatch check, for example?
Quoted 7 lines
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.
RE: [PATCH v2 00/16] replace __atomic operations returning new value
In reply to Tyler RetzlaffQuoted 71 lines
-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Thursday, March 16, 2023 5:15 AM
To: [email protected]
Cc: Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; [email protected]; Tyler Retzlaff <[email protected]>
Subject: [PATCH v2 00/16] replace__atomicoperations returning new valueThis 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__atomicbuiltins.
* 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 operationsdrivers/event: use previous value atomic fetch operationsnet/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 operationsapp/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(-)
Quoted 2 lines
--
1.8.3.1
PATCH v3 1/16 app/test: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- app/test/test_ring_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_ring_perf.c +1 -1
@@ -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
Signature · 1 line
1.8.3.1
PATCH v3 2/16 common/cnxk: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- 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(-)
drivers/common/cnxk/roc_ae.c +1 -1
@@ -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); }
drivers/common/cnxk/roc_ae_fpm_tables.c +1 -1
@@ -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); }
drivers/common/cnxk/roc_npa.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
v3 cover replace __atomic operations returning new value
In reply to Tyler RetzlaffThis 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(-)
Signature · 1 line
1.8.3.1
PATCH v3 4/16 drivers/event: use previous value atomic fetch operations
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.
--- 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(-)
drivers/event/cnxk/cnxk_tim_worker.h +1 -1
@@ -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
drivers/event/dsw/dsw_event.c +2 -2
@@ -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 */
drivers/event/octeontx/timvf_worker.h +1 -1
@@ -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 *
Signature · 1 line
1.8.3.1
PATCH v3 3/16 common/mlx5: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- 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(-)
drivers/common/mlx5/linux/mlx5_nl.c +1 -1
@@ -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.
drivers/common/mlx5/mlx5_common_mr.c +4 -4
@@ -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; }
drivers/common/mlx5/mlx5_common_utils.c +4 -4
@@ -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 )) {
Signature · 1 line
1.8.3.1
PATCH v3 8/16 net/iavf: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/iavf/iavf_vchnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/iavf/iavf_vchnl.c +4 -4
@@ -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 {
Signature · 1 line
1.8.3.1
PATCH v3 5/16 net/af_xdp: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/af_xdp/rte_eth_af_xdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +2 -2
@@ -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;
Signature · 1 line
1.8.3.1
PATCH v3 6/16 net/cnxk: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/cnxk/cn10k_tx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/cnxk/cn10k_tx.h +2 -2
@@ -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 ;
Signature · 1 line
1.8.3.1
PATCH v3 7/16 net/cxgbe: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/cxgbe/clip_tbl.c | 2 +- drivers/net/cxgbe/mps_tcam.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/cxgbe/clip_tbl.c +1 -1
@@ -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);
drivers/net/cxgbe/mps_tcam.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
PATCH v3 11/16 raw/ifpga: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
@@ -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)
Signature · 1 line
1.8.3.1
PATCH v3 12/16 bbdev: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/bbdev/rte_bbdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bbdev/rte_bbdev.c +2 -2
@@ -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));
Signature · 1 line
1.8.3.1
PATCH v3 10/16 net/octeontx: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- drivers/net/octeontx/octeontx_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/octeontx/octeontx_ethdev.c +1 -1
@@ -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); }
Signature · 1 line
1.8.3.1
PATCH v3 14/16 ipsec: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/ipsec/ipsec_sqn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ipsec/ipsec_sqn.h +1 -1
@@ -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;
Signature · 1 line
1.8.3.1
PATCH v3 9/16 net/mlx5: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- 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(-)
drivers/net/mlx5/linux/mlx5_verbs.c +1 -1
@@ -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 ;
drivers/net/mlx5/mlx5.c +2 -2
@@ -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);
drivers/net/mlx5/mlx5_flow.c +4 -4
@@ -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); }
drivers/net/mlx5/mlx5_flow_dv.c +6 -6
@@ -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);
drivers/net/mlx5/mlx5_flow_hw.c +7 -7
@@ -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 ;
drivers/net/mlx5/mlx5_hws_cnt.c +2 -2
@@ -192,8 +192,8 @@ } param->accumulator_hits =0 ; } -if (__atomic_add_fetch (¶m->sec_since_last_hit, time_delta, - __ATOMIC_RELAXED) <= +if (__atomic_fetch_add (¶m->sec_since_last_hit, time_delta, + __ATOMIC_RELAXED) + time_delta <=__atomic_load_n (¶m->timeout, __ATOMIC_RELAXED))continue ;/* Prepare the relevant ring for this AGE parameter */
drivers/net/mlx5/mlx5_rxq.c +3 -3
@@ -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);
drivers/net/mlx5/mlx5_txq.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
PATCH v3 13/16 eal: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/eal/include/generic/rte_rwlock.h | 8 ++++---- lib/eal/ppc/include/rte_atomic.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-)
lib/eal/include/generic/rte_rwlock.h +4 -4
@@ -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 )) {
lib/eal/ppc/include/rte_atomic.h +8 -8
@@ -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)
Signature · 1 line
1.8.3.1
PATCH v3 16/16 rcu: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/rcu/rte_rcu_qsbr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rcu/rte_rcu_qsbr.h +1 -1
@@ -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; }
Signature · 1 line
1.8.3.1
PATCH v3 15/16 mbuf: use previous value atomic fetch operations
In reply to Tyler RetzlaffUse __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.
--- lib/mbuf/rte_mbuf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/mbuf/rte_mbuf.h +6 -6
@@ -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. */
Signature · 1 line
1.8.3.1
Re: [PATCH v2 00/16] replace __atomic operations returning new value
In reply to Tyler RetzlaffQuoted 33 lines · Tyler Retzlaff
Quoted 32 lines · Thomas Monjalon
16/03/2023 11:03, Bruce Richardson:
Quoted 4 lines · Tyler Retzlaff
Quoted 3 lines
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.
[...]
Quoted 18 lines
Quoted 9 lines
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 operationsdrivers/event: use previous value atomic fetch operationsnet/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 operationsQuoted 9 lines
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 operationsQuoted 3 lines
I am wondering how we go about ensuring that we don't introduce any more of these
atomic_X_fetchintrinsics. 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\(
Quoted 7 lines
Quoted 3 lines
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.shstandalone asap that can be merged before these changes.
just fyi, there is a series up for this.
Re: [PATCH v3 00/16] replace __atomic operations returning new value
In reply to Tyler RetzlaffQuoted 60 lines · 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 runv2:
* remove unnecessary casts of signed to unsigned arguments when using generic__atomicbuiltins.
* 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 operationsdrivers/event: use previous value atomic fetch operationsnet/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 operationsapp/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 +-
Quoted 9 lines
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.
Signature · 1 line
David Marchand