Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch when we have no interest in the
result of the operation.

Reduces unnecessary codegen that provided the result of the atomic
operation that was not used.

Change brings closer alignment with atomics available in C11 standard
and will reduce review effort when they are integrated.

Signed-off-by: Tyler Retzlaff <roret...@linux.microsoft.com>
---
 drivers/common/cnxk/roc_nix_inl_dev.c   |  2 +-
 drivers/common/mlx5/mlx5_common_mr.c    |  2 +-
 drivers/common/mlx5/mlx5_common_utils.c | 10 +++++-----
 drivers/common/mlx5/mlx5_malloc.c       | 16 ++++++++--------
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/common/cnxk/roc_nix_inl_dev.c 
b/drivers/common/cnxk/roc_nix_inl_dev.c
index 6f60961..45d6f62 100644
--- a/drivers/common/cnxk/roc_nix_inl_dev.c
+++ b/drivers/common/cnxk/roc_nix_inl_dev.c
@@ -741,7 +741,7 @@
                        inl_dev->work_cb(&tmp, sa, (port_id << 8) | 0x1);
                        __atomic_store_n(ring_base + tail_l + 1, 0ULL,
                                         __ATOMIC_RELAXED);
-                       __atomic_add_fetch((uint32_t *)ring_base, 1,
+                       __atomic_fetch_add((uint32_t *)ring_base, 1,
                                           __ATOMIC_ACQ_REL);
                } else
                        plt_err("Invalid SA");
diff --git a/drivers/common/mlx5/mlx5_common_mr.c 
b/drivers/common/mlx5/mlx5_common_mr.c
index 0e1d243..9ebe398 100644
--- a/drivers/common/mlx5/mlx5_common_mr.c
+++ b/drivers/common/mlx5/mlx5_common_mr.c
@@ -1650,7 +1650,7 @@ struct mlx5_mempool_get_extmem_data {
        unsigned int i;
 
        for (i = 0; i < mpr->mrs_n; i++)
-               __atomic_add_fetch(&mpr->mrs[i].refcnt, 1, __ATOMIC_RELAXED);
+               __atomic_fetch_add(&mpr->mrs[i].refcnt, 1, __ATOMIC_RELAXED);
 }
 
 /**
diff --git a/drivers/common/mlx5/mlx5_common_utils.c 
b/drivers/common/mlx5/mlx5_common_utils.c
index 58d744b..915a317 100644
--- a/drivers/common/mlx5/mlx5_common_utils.c
+++ b/drivers/common/mlx5/mlx5_common_utils.c
@@ -217,7 +217,7 @@ struct mlx5_list_entry *
                entry->lcore_idx = (uint32_t)lcore_index;
                LIST_INSERT_HEAD(&l_inconst->cache[lcore_index]->h,
                                 entry, next);
-               __atomic_add_fetch(&l_inconst->count, 1, __ATOMIC_RELAXED);
+               __atomic_fetch_add(&l_inconst->count, 1, __ATOMIC_RELAXED);
                DRV_LOG(DEBUG, "MLX5 list %s c%d entry %p new: %u.",
                        l_const->name, lcore_index,
                        (void *)entry, entry->ref_cnt);
@@ -254,7 +254,7 @@ struct mlx5_list_entry *
        l_inconst->gen_cnt++;
        rte_rwlock_write_unlock(&l_inconst->lock);
        LIST_INSERT_HEAD(&l_inconst->cache[lcore_index]->h, local_entry, next);
-       __atomic_add_fetch(&l_inconst->count, 1, __ATOMIC_RELAXED);
+       __atomic_fetch_add(&l_inconst->count, 1, __ATOMIC_RELAXED);
        DRV_LOG(DEBUG, "mlx5 list %s entry %p new: %u.", l_const->name,
                (void *)entry, entry->ref_cnt);
        return local_entry;
@@ -294,11 +294,11 @@ struct mlx5_list_entry *
                else
                        l_const->cb_remove(l_const->ctx, entry);
        } else {
-               __atomic_add_fetch(&l_inconst->cache[entry->lcore_idx]->inv_cnt,
+               __atomic_fetch_add(&l_inconst->cache[entry->lcore_idx]->inv_cnt,
                                   1, __ATOMIC_RELAXED);
        }
        if (!l_const->lcores_share) {
-               __atomic_sub_fetch(&l_inconst->count, 1, __ATOMIC_RELAXED);
+               __atomic_fetch_sub(&l_inconst->count, 1, __ATOMIC_RELAXED);
                DRV_LOG(DEBUG, "mlx5 list %s entry %p removed.",
                        l_const->name, (void *)entry);
                return 0;
@@ -310,7 +310,7 @@ struct mlx5_list_entry *
                LIST_REMOVE(gentry, next);
                rte_rwlock_write_unlock(&l_inconst->lock);
                l_const->cb_remove(l_const->ctx, gentry);
-               __atomic_sub_fetch(&l_inconst->count, 1, __ATOMIC_RELAXED);
+               __atomic_fetch_sub(&l_inconst->count, 1, __ATOMIC_RELAXED);
                DRV_LOG(DEBUG, "mlx5 list %s entry %p removed.",
                        l_const->name, (void *)gentry);
                return 0;
diff --git a/drivers/common/mlx5/mlx5_malloc.c 
b/drivers/common/mlx5/mlx5_malloc.c
index cef3b88..c58c41d 100644
--- a/drivers/common/mlx5/mlx5_malloc.c
+++ b/drivers/common/mlx5/mlx5_malloc.c
@@ -99,7 +99,7 @@ struct mlx5_sys_mem {
                        rte_mem_virt2memseg_list(addr),
                        __ATOMIC_RELAXED);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-               __atomic_add_fetch(&mlx5_sys_mem.msl_update, 1,
+               __atomic_fetch_add(&mlx5_sys_mem.msl_update, 1,
                                   __ATOMIC_RELAXED);
 #endif
        }
@@ -126,7 +126,7 @@ struct mlx5_sys_mem {
                if (!rte_mem_virt2memseg_list(addr))
                        return false;
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-               __atomic_add_fetch(&mlx5_sys_mem.msl_miss, 1, __ATOMIC_RELAXED);
+               __atomic_fetch_add(&mlx5_sys_mem.msl_miss, 1, __ATOMIC_RELAXED);
 #endif
        }
        return true;
@@ -185,7 +185,7 @@ struct mlx5_sys_mem {
                mlx5_mem_update_msl(addr);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
                if (addr)
-                       __atomic_add_fetch(&mlx5_sys_mem.malloc_rte, 1,
+                       __atomic_fetch_add(&mlx5_sys_mem.malloc_rte, 1,
                                           __ATOMIC_RELAXED);
 #endif
                return addr;
@@ -199,7 +199,7 @@ struct mlx5_sys_mem {
                addr = malloc(size);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
        if (addr)
-               __atomic_add_fetch(&mlx5_sys_mem.malloc_sys, 1,
+               __atomic_fetch_add(&mlx5_sys_mem.malloc_sys, 1,
                                   __ATOMIC_RELAXED);
 #endif
        return addr;
@@ -233,7 +233,7 @@ struct mlx5_sys_mem {
                mlx5_mem_update_msl(new_addr);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
                if (new_addr)
-                       __atomic_add_fetch(&mlx5_sys_mem.realloc_rte, 1,
+                       __atomic_fetch_add(&mlx5_sys_mem.realloc_rte, 1,
                                           __ATOMIC_RELAXED);
 #endif
                return new_addr;
@@ -246,7 +246,7 @@ struct mlx5_sys_mem {
        new_addr = realloc(addr, size);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
        if (new_addr)
-               __atomic_add_fetch(&mlx5_sys_mem.realloc_sys, 1,
+               __atomic_fetch_add(&mlx5_sys_mem.realloc_sys, 1,
                                   __ATOMIC_RELAXED);
 #endif
        return new_addr;
@@ -259,13 +259,13 @@ struct mlx5_sys_mem {
                return;
        if (!mlx5_mem_is_rte(addr)) {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-               __atomic_add_fetch(&mlx5_sys_mem.free_sys, 1,
+               __atomic_fetch_add(&mlx5_sys_mem.free_sys, 1,
                                   __ATOMIC_RELAXED);
 #endif
                mlx5_os_free(addr);
        } else {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-               __atomic_add_fetch(&mlx5_sys_mem.free_rte, 1,
+               __atomic_fetch_add(&mlx5_sys_mem.free_rte, 1,
                                   __ATOMIC_RELAXED);
 #endif
                rte_free(addr);
-- 
1.8.3.1

Reply via email to