From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com,
thomas@monjalon.net,
Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH v2 09/16] net/mlx5: use previous value atomic fetch operations
Date: Wed, 15 Mar 2023 14:15:38 -0700 [thread overview]
Message-ID: <1678914945-10638-10-git-send-email-roretzla@linux.microsoft.com> (raw)
In-Reply-To: <1678914945-10638-1-git-send-email-roretzla@linux.microsoft.com>
Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
drivers/net/mlx5/linux/mlx5_verbs.c | 2 +-
drivers/net/mlx5/mlx5.c | 4 ++--
drivers/net/mlx5/mlx5_flow.c | 8 ++++----
drivers/net/mlx5/mlx5_flow_dv.c | 12 ++++++------
drivers/net/mlx5/mlx5_flow_hw.c | 14 +++++++-------
drivers/net/mlx5/mlx5_hws_cnt.c | 4 ++--
drivers/net/mlx5/mlx5_rxq.c | 6 +++---
drivers/net/mlx5/mlx5_txq.c | 2 +-
8 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
index 67a7bec..ee5d072 100644
--- a/drivers/net/mlx5/linux/mlx5_verbs.c
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -1183,7 +1183,7 @@
if (!priv->lb_used)
return;
MLX5_ASSERT(__atomic_load_n(&sh->self_lb.refcnt, __ATOMIC_RELAXED));
- if (!(__atomic_sub_fetch(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED))) {
+ if (!(__atomic_fetch_sub(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED) - 1)) {
if (sh->self_lb.qp) {
claim_zero(mlx5_glue->destroy_qp(sh->self_lb.qp));
sh->self_lb.qp = NULL;
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 41b1b12..044012d 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1068,7 +1068,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
DRV_LOG(ERR, "Dynamic flex parser is not supported");
return -ENOTSUP;
}
- if (__atomic_add_fetch(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) > 1)
+ if (__atomic_fetch_add(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) + 1 > 1)
return 0;
node.header_length_mode = MLX5_GRAPH_NODE_LEN_FIELD;
@@ -1123,7 +1123,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_internal_flex_parser_profile *fp = &priv->sh->srh_flex_parser;
- if (__atomic_sub_fetch(&fp->refcnt, 1, __ATOMIC_RELAXED))
+ if (__atomic_fetch_sub(&fp->refcnt, 1, __ATOMIC_RELAXED) - 1)
return;
if (fp->fp)
mlx5_devx_cmd_destroy(fp->fp);
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 2514b33..332008e 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -7833,7 +7833,7 @@ struct rte_flow *
tunnel = mlx5_find_tunnel_id(dev, flow->tunnel_id);
RTE_VERIFY(tunnel);
- if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+ if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
mlx5_flow_tunnel_free(dev, tunnel);
}
flow_mreg_del_copy_action(dev, flow);
@@ -9742,9 +9742,9 @@ struct mlx5_flow_workspace*
__ATOMIC_RELAXED);
continue;
}
- if (__atomic_add_fetch(&age_param->sec_since_last_hit,
+ if (__atomic_fetch_add(&age_param->sec_since_last_hit,
time_delta,
- __ATOMIC_RELAXED) <= age_param->timeout)
+ __ATOMIC_RELAXED) + time_delta <= age_param->timeout)
continue;
/**
* Hold the lock first, or if between the
@@ -11387,7 +11387,7 @@ struct tunnel_db_element_release_ctx {
{
struct tunnel_db_element_release_ctx *ctx = x;
ctx->ret = 0;
- if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED))
+ if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1))
mlx5_flow_tunnel_free(dev, tunnel);
}
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ca26f39..f04160e 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -6723,8 +6723,8 @@ struct mlx5_list_entry *
* indirect action API, shared info is 1 before the reduction,
* so this condition is failed and function doesn't return here.
*/
- if (__atomic_sub_fetch(&cnt->shared_info.refcnt, 1,
- __ATOMIC_RELAXED))
+ if (__atomic_fetch_sub(&cnt->shared_info.refcnt, 1,
+ __ATOMIC_RELAXED) - 1)
return;
}
cnt->pool = pool;
@@ -12797,7 +12797,7 @@ struct mlx5_list_entry *
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_aso_age_mng *mng = priv->sh->aso_age_mng;
struct mlx5_aso_age_action *age = flow_aso_age_get_by_idx(dev, age_idx);
- uint32_t ret = __atomic_sub_fetch(&age->refcnt, 1, __ATOMIC_RELAXED);
+ uint32_t ret = __atomic_fetch_sub(&age->refcnt, 1, __ATOMIC_RELAXED) - 1;
if (!ret) {
flow_dv_aso_age_remove_from_age(dev, age);
@@ -13193,7 +13193,7 @@ struct mlx5_list_entry *
/* Cannot release when CT is in the ASO SQ. */
if (state == ASO_CONNTRACK_WAIT || state == ASO_CONNTRACK_QUERY)
return -1;
- ret = __atomic_sub_fetch(&ct->refcnt, 1, __ATOMIC_RELAXED);
+ ret = __atomic_fetch_sub(&ct->refcnt, 1, __ATOMIC_RELAXED) - 1;
if (!ret) {
if (ct->dr_action_orig) {
#ifdef HAVE_MLX5_DR_ACTION_ASO_CT
@@ -15582,8 +15582,8 @@ struct mlx5_list_entry *
sh->geneve_tlv_option_resource;
rte_spinlock_lock(&sh->geneve_tlv_opt_sl);
if (geneve_opt_resource) {
- if (!(__atomic_sub_fetch(&geneve_opt_resource->refcnt, 1,
- __ATOMIC_RELAXED))) {
+ if (!(__atomic_fetch_sub(&geneve_opt_resource->refcnt, 1,
+ __ATOMIC_RELAXED) - 1)) {
claim_zero(mlx5_devx_cmd_destroy
(geneve_opt_resource->obj));
mlx5_free(sh->geneve_tlv_option_resource);
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 9392727..109aab1 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -458,7 +458,7 @@ static int flow_hw_translate_group(struct rte_eth_dev *dev,
}
if (acts->mark)
- if (!__atomic_sub_fetch(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED))
+ if (!(__atomic_fetch_sub(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED) - 1))
flow_hw_rxq_flag_set(dev, false);
if (acts->jump) {
@@ -3268,8 +3268,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
rte_errno = EINVAL;
goto it_error;
}
- ret = __atomic_add_fetch(&item_templates[i]->refcnt, 1,
- __ATOMIC_RELAXED);
+ ret = __atomic_fetch_add(&item_templates[i]->refcnt, 1,
+ __ATOMIC_RELAXED) + 1;
if (ret <= 1) {
rte_errno = EINVAL;
goto it_error;
@@ -3282,8 +3282,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions)
for (i = 0; i < nb_action_templates; i++) {
uint32_t ret;
- ret = __atomic_add_fetch(&action_templates[i]->refcnt, 1,
- __ATOMIC_RELAXED);
+ ret = __atomic_fetch_add(&action_templates[i]->refcnt, 1,
+ __ATOMIC_RELAXED) + 1;
if (ret <= 1) {
rte_errno = EINVAL;
goto at_error;
@@ -7624,8 +7624,8 @@ void flow_hw_clear_tags_set(struct rte_eth_dev *dev)
{
uint32_t refcnt;
- refcnt = __atomic_sub_fetch(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
- __ATOMIC_RELAXED);
+ refcnt = __atomic_fetch_sub(&mlx5_flow_hw_flow_metadata_config_refcnt, 1,
+ __ATOMIC_RELAXED) - 1;
if (refcnt > 0)
return;
mlx5_flow_hw_flow_metadata_esw_en = 0;
diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c
index d6a017a..d98df68 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.c
+++ b/drivers/net/mlx5/mlx5_hws_cnt.c
@@ -192,8 +192,8 @@
}
param->accumulator_hits = 0;
}
- if (__atomic_add_fetch(¶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 */
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 6e99c4d..ad8fd13 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2042,7 +2042,7 @@ struct mlx5_rxq_priv *
if (rxq == NULL)
return 0;
- return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+ return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
}
/**
@@ -2141,7 +2141,7 @@ struct mlx5_external_rxq *
{
struct mlx5_external_rxq *rxq = mlx5_ext_rxq_get(dev, idx);
- return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED);
+ return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1;
}
/**
@@ -2462,7 +2462,7 @@ struct mlx5_ind_table_obj *
unsigned int ret;
rte_rwlock_write_lock(&priv->ind_tbls_lock);
- ret = __atomic_sub_fetch(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED);
+ ret = __atomic_fetch_sub(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED) - 1;
if (!ret)
LIST_REMOVE(ind_tbl, next);
rte_rwlock_write_unlock(&priv->ind_tbls_lock);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 1e0e61a..8cb52b0 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -1203,7 +1203,7 @@ struct mlx5_txq_ctrl *
if (priv->txqs == NULL || (*priv->txqs)[idx] == NULL)
return 0;
txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
- if (__atomic_sub_fetch(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) > 1)
+ if (__atomic_fetch_sub(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) - 1 > 1)
return 1;
if (txq_ctrl->obj) {
priv->obj_ops.txq_obj_release(txq_ctrl->obj);
--
1.8.3.1
next prev parent reply other threads:[~2023-03-15 21:16 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 22:15 [PATCH 00/16] use __atomic operations returning new value Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 02/16] common/cnxk: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 03/16] common/mlx5: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 04/16] drivers/event: " Tyler Retzlaff
2023-03-13 7:02 ` [EXT] " Pavan Nikhilesh Bhagavatula
2023-03-10 22:15 ` [PATCH 05/16] net/af_xdp: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 06/16] net/cnxk: " Tyler Retzlaff
2023-03-13 6:45 ` [EXT] " Nithin Kumar Dabilpuram
2023-03-10 22:15 ` [PATCH 07/16] net/cxgbe: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 08/16] net/iavf: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 09/16] net/mlx5: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 10/16] net/octeontx: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 11/16] raw/ifpga: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 12/16] bbdev: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 13/16] eal: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 14/16] ipsec: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 15/16] mbuf: " Tyler Retzlaff
2023-03-10 22:15 ` [PATCH 16/16] rcu: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 00/16] replace __atomic operations returning new value Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 02/16] common/cnxk: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 03/16] common/mlx5: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 04/16] drivers/event: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 05/16] net/af_xdp: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 06/16] net/cnxk: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 07/16] net/cxgbe: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 08/16] net/iavf: " Tyler Retzlaff
2023-03-15 21:15 ` Tyler Retzlaff [this message]
2023-03-15 21:15 ` [PATCH v2 10/16] net/octeontx: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 11/16] raw/ifpga: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 12/16] bbdev: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 13/16] eal: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 14/16] ipsec: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 15/16] mbuf: " Tyler Retzlaff
2023-03-15 21:15 ` [PATCH v2 16/16] rcu: " Tyler Retzlaff
2023-03-16 10:03 ` [PATCH v2 00/16] replace __atomic operations returning new value Bruce Richardson
2023-03-16 15:25 ` Thomas Monjalon
2023-03-16 16:17 ` Tyler Retzlaff
2023-04-18 18:11 ` Tyler Retzlaff
2023-03-20 10:24 ` Ruifeng Wang
2023-03-20 19:00 ` [PATCH v3 " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 01/16] app/test: use previous value atomic fetch operations Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 02/16] common/cnxk: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 03/16] common/mlx5: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 04/16] drivers/event: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 05/16] net/af_xdp: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 06/16] net/cnxk: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 07/16] net/cxgbe: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 08/16] net/iavf: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 09/16] net/mlx5: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 10/16] net/octeontx: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 11/16] raw/ifpga: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 12/16] bbdev: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 13/16] eal: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 14/16] ipsec: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 15/16] mbuf: " Tyler Retzlaff
2023-03-20 19:00 ` [PATCH v3 16/16] rcu: " Tyler Retzlaff
2023-04-25 9:10 ` [PATCH v3 00/16] replace __atomic operations returning new value David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1678914945-10638-10-git-send-email-roretzla@linux.microsoft.com \
--to=roretzla@linux.microsoft.com \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Ruifeng.Wang@arm.com \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).