use rte atomic thread fence
cover use rte atomic thread fence
Replace use of __atomic_thread_fence with __rte_atomic_thread_fence.
It may be appropriate to use rte_atomic_thread_fence instead but it will be up to maintainers to evaluate and make the change if appropriate.
Tyler Retzlaff (5):
distributor: use rte atomic thread fence
eal: use rte atomic thread fence
hash: use rte atomic thread fence
ring: use rte atomic thread fence
stack: use rte atomic thread fence
lib/distributor/rte_distributor.c | 2 +- lib/eal/common/eal_common_trace.c | 2 +- lib/hash/rte_cuckoo_hash.c | 10 +++++----- lib/ring/rte_ring_c11_pvt.h | 4 ++-- lib/stack/rte_stack_lf_c11.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/5 distributor: use rte atomic thread fence
Use __rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/distributor/rte_distributor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/distributor/rte_distributor.c +1 -1
@@ -187,7 +187,7 @@ }/* Sync with distributor to acquire retptrs */ -__atomic_thread_fence (rte_memory_order_acquire); +__rte_atomic_thread_fence (rte_memory_order_acquire);for (i =0 ; i <RTE_DIST_BURST_SIZE ; i++)/* Switch off the return bit first */ buf->retptr64[i] =0 ;
Signature · 1 line
1.8.3.1
PATCH 2/5 eal: use rte atomic thread fence
In reply to Tyler RetzlaffUse __rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/eal/common/eal_common_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/eal/common/eal_common_trace.c +1 -1
@@ -526,7 +526,7 @@ rte_trace_mode rte_trace_mode_get(void)/* Add the trace point at tail */ STAILQ_INSERT_TAIL (&tp_list, tp, next); -__atomic_thread_fence (rte_memory_order_release); +__rte_atomic_thread_fence (rte_memory_order_release);/* All Good !!! */ return 0 ;
Signature · 1 line
1.8.3.1
PATCH 3/5 hash: use rte atomic thread fence
In reply to Tyler RetzlaffUse __rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/hash/rte_cuckoo_hash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
lib/hash/rte_cuckoo_hash.c +5 -5
@@ -871,7 +871,7 @@ struct rte_hash */* The store to sig_current should not * move above the store to tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_release); +__rte_atomic_thread_fence (rte_memory_order_release); }/* Need to swap current/alt sig to allow later
@@ -903,7 +903,7 @@ struct rte_hash */* The store to sig_current should not * move above the store to tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_release); +__rte_atomic_thread_fence (rte_memory_order_release); } curr_bkt->sig_current[curr_slot] = sig;
@@ -1396,7 +1396,7 @@ struct rte_hash */* The loads of sig_current in search_one_bucket * should not move below the load from tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_acquire); +__rte_atomic_thread_fence (rte_memory_order_acquire);/* Re-read the table change counter to check if the * table has changed during search. If yes, re-do * the search.
@@ -1625,7 +1625,7 @@ struct rte_hash */* The store to sig_current should * not move above the store to tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_release); +__rte_atomic_thread_fence (rte_memory_order_release); } last_bkt->sig_current[i] =NULL_SIGNATURE ; rte_atomic_store_explicit(&last_bkt->key_idx[i],
@@ -2216,7 +2216,7 @@ struct rte_hash */* The loads of sig_current in compare_signatures * should not move below the load from tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_acquire); +__rte_atomic_thread_fence (rte_memory_order_acquire);/* Re-read the table change counter to check if the * table has changed during search. If yes, re-do * the search.
Signature · 1 line
1.8.3.1
PATCH 4/5 ring: use rte atomic thread fence
In reply to Tyler RetzlaffUse __rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/ring/rte_ring_c11_pvt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/ring/rte_ring_c11_pvt.h +2 -2
@@ -68,7 +68,7 @@ n = max;/* Ensure the head is read before tail */ -__atomic_thread_fence (rte_memory_order_acquire); +__rte_atomic_thread_fence (rte_memory_order_acquire);/* load-acquire synchronize with store-release of ht->tail * in update_tail.
@@ -145,7 +145,7 @@ n = max;/* Ensure the head is read before tail */ -__atomic_thread_fence (rte_memory_order_acquire); +__rte_atomic_thread_fence (rte_memory_order_acquire);/* this load-acquire synchronize with store-release of ht->tail * in update_tail.
Signature · 1 line
1.8.3.1
PATCH 5/5 stack: use rte atomic thread fence
In reply to Tyler RetzlaffUse __rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/stack/rte_stack_lf_c11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/stack/rte_stack_lf_c11.h +1 -1
@@ -110,7 +110,7 @@* elements are properly ordered with respect to the head * pointer read. */ -__atomic_thread_fence (rte_memory_order_acquire); +__rte_atomic_thread_fence (rte_memory_order_acquire);rte_prefetch0 (old_head.top);
Signature · 1 line
1.8.3.1
Quoted 23 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 2 November 2023 04.04Replace use of
__atomic_thread_fencewith__rte_atomic_thread_fence.It may be appropriate to use
rte_atomic_thread_fenceinstead but it will be up to maintainers to evaluate and make the change if appropriate.Tyler Retzlaff (5):
distributor: use rte atomic thread fence
eal: use rte atomic thread fence
hash: use rte atomic thread fence
ring: use rte atomic thread fence
stack: use rte atomic thread fencelib/distributor/rte_distributor.c | 2 +- lib/eal/common/eal_common_trace.c | 2 +- lib/hash/rte_cuckoo_hash.c | 10 +++++----- lib/ring/rte_ring_c11_pvt.h | 4 ++-- lib/stack/rte_stack_lf_c11.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-)
Quoted 2 lines
--
1.8.3.1
02/11/2023 04:04, Tyler Retzlaff:
Quoted 4 lines
Replace use of
__atomic_thread_fencewith__rte_atomic_thread_fence.It may be appropriate to use
rte_atomic_thread_fenceinstead but it will be up to maintainers to evaluate and make the change if appropriate.
I don't understand the use of __rte_atomic_thread_fence which is supposed to be EAL-internal only, isn't it?
On x86, we have this:
static __rte_always_inline void rte_atomic_thread_fence(rte_memory_order memorder)
{
if (memorder == rte_memory_order_seq_cst)
rte_smp_mb();
else
__rte_atomic_thread_fence(memorder);
}This is skipped if you use __rte_atomic_thread_fence() directly.
Quoted 12 lines · Thomas Monjalon
02/11/2023 04:04, Tyler Retzlaff:
Quoted 4 lines
Replace use of
__atomic_thread_fencewith__rte_atomic_thread_fence.It may be appropriate to use
rte_atomic_thread_fenceinstead but it will be up to maintainers to evaluate and make the change if appropriate.I don't understand the use of
__rte_atomic_thread_fencewhich is supposed to be EAL-internal only, isn't it?On x86, we have this:
static__rte_always_inlinevoidrte_atomic_thread_fence(rte_memory_order memorder)
Quoted 8 lines
{ if (memorder == rte_memory_order_seq_cst) rte_smp_mb(); else __rte_atomic_thread_fence(memorder); }This is skipped if you use
__rte_atomic_thread_fence()directly.
correct. that is on purpose because the original code was skipping condition by using __atomic_thread_fence directly.
this series intends no functional change which is why the replacements are __rte_atomic_thread_fence instead of to rte_atomic_thread_fence.
i would encourage the maintainers to evaluate whether the code can use rte_atomic_thread_fence directly without functional regression.
ty
08/11/2023 19:49, Tyler Retzlaff:
Quoted 20 lines · Thomas Monjalon
Quoted 19 lines
02/11/2023 04:04, Tyler Retzlaff:
Quoted 4 lines
Replace use of
__atomic_thread_fencewith__rte_atomic_thread_fence.It may be appropriate to use
rte_atomic_thread_fenceinstead but it will be up to maintainers to evaluate and make the change if appropriate.I don't understand the use of
__rte_atomic_thread_fencewhich is supposed to be EAL-internal only, isn't it?On x86, we have this:
static__rte_always_inlinevoidrte_atomic_thread_fence(rte_memory_order memorder){ if (memorder == rte_memory_order_seq_cst) rte_smp_mb(); else __rte_atomic_thread_fence(memorder); }
Quoted 4 lines
Quoted 1 line
This is skipped if you use
__rte_atomic_thread_fence()directly.correct. that is on purpose because the original code was skipping condition by using
__atomic_thread_fencedirectly.
There is chance that it was not skipping on purpose.
Quoted 2 lines
this series intends no functional change which is why the replacements are
__rte_atomic_thread_fenceinstead of torte_atomic_thread_fence.
We should take this opportunity to simplify the code, I mean we should avoid having 3 functions for the same thing.
Quoted 2 lines
i would encourage the maintainers to evaluate whether the code can use
rte_atomic_thread_fencedirectly without functional regression.
Let's do the change so the maintainers can review what is changed. Note it should have no impact if not using rte_memory_order_seq_cst. If we discover later that something is broken, we have time to fix it.
Note: lib/eal/include/rte_mcslock.h should not use __rte_atomic_thread_fence() and lib/lpm/rte_lpm.c should not use __atomic_thread_fence().
Can we replace and discourage all occurrences of __atomic_thread_fence() and __rte_atomic_thread_fence()? It would be simpler to recommend only rte_atomic_thread_fence().
Also in another patch, it would be nice to replace __ATOMIC_* with rte_memory_order_*, at least when used in rte_atomic_thread_fence().
v2 cover use rte atomic thread fence
In reply to Tyler RetzlaffReplace use of __atomic_thread_fence with rte_atomic_thread_fence.
Notes:
The rest of lib/lpm will be converted to rte_atomic in a separate series (to be submitted soon).
There are existing checkpatches checks that catch use of both __atomic_thread_fence and __rte_atomic_thread_fence in new submissions.
v2:
* change series to use rte_atomic_thread_fence instead of __rte_atomic_thread_fence (internal)
* also change __atomic_thread_fence in lib/lpm
Tyler Retzlaff (6):
distributor: use rte atomic thread fence
eal: use rte atomic thread fence
hash: use rte atomic thread fence
ring: use rte atomic thread fence
stack: use rte atomic thread fence
lpm: use rte atomic thread fence
lib/distributor/rte_distributor.c | 2 +- lib/eal/common/eal_common_trace.c | 2 +- lib/eal/include/rte_mcslock.h | 4 ++-- lib/hash/rte_cuckoo_hash.c | 10 +++++----- lib/lpm/rte_lpm.c | 4 ++-- lib/ring/rte_ring_c11_pvt.h | 4 ++-- lib/stack/rte_stack_lf_c11.h | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/6 distributor: use rte atomic thread fence
Use rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/distributor/rte_distributor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/distributor/rte_distributor.c +1 -1
@@ -187,7 +187,7 @@ }/* Sync with distributor to acquire retptrs */ -__atomic_thread_fence (rte_memory_order_acquire); +rte_atomic_thread_fence (rte_memory_order_acquire);for (i =0 ; i <RTE_DIST_BURST_SIZE ; i++)/* Switch off the return bit first */ buf->retptr64[i] =0 ;
Signature · 1 line
1.8.3.1
PATCH v2 2/6 eal: use rte atomic thread fence
In reply to Tyler RetzlaffUse rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
Update rte_mcslock.h to use rte_atomic_thread_fence instead of directly using internal __rte_atomic_thread_fence
--- lib/eal/common/eal_common_trace.c | 2 +- lib/eal/include/rte_mcslock.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/eal/common/eal_common_trace.c +1 -1
@@ -526,7 +526,7 @@ rte_trace_mode rte_trace_mode_get(void)/* Add the trace point at tail */ STAILQ_INSERT_TAIL (&tp_list, tp, next); -__atomic_thread_fence (rte_memory_order_release); +rte_atomic_thread_fence (rte_memory_order_release);/* All Good !!! */ return 0 ;
lib/eal/include/rte_mcslock.h +2 -2
@@ -83,7 +83,7 @@* store to prev->next. Otherwise it will cause a deadlock. Need a * store-load barrier. */ -__rte_atomic_thread_fence (rte_memory_order_acq_rel); +rte_atomic_thread_fence (rte_memory_order_acq_rel);/* If the lock has already been acquired, it first atomically * places the node at the end of the queue and then proceeds * to spin on me->locked until the previous lock holder resets
@@ -117,7 +117,7 @@* while-loop first. This has the potential to cause a * deadlock. Need a load barrier. */ -__rte_atomic_thread_fence (rte_memory_order_acquire); +rte_atomic_thread_fence (rte_memory_order_acquire);/* More nodes added to the queue by other CPUs. * Wait until the next pointer is set. */
Signature · 1 line
1.8.3.1
PATCH v2 3/6 hash: use rte atomic thread fence
In reply to Tyler RetzlaffUse rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/hash/rte_cuckoo_hash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
lib/hash/rte_cuckoo_hash.c +5 -5
@@ -878,7 +878,7 @@ struct rte_hash */* The store to sig_current should not * move above the store to tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_release); +rte_atomic_thread_fence (rte_memory_order_release); }/* Need to swap current/alt sig to allow later
@@ -910,7 +910,7 @@ struct rte_hash */* The store to sig_current should not * move above the store to tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_release); +rte_atomic_thread_fence (rte_memory_order_release); } curr_bkt->sig_current[curr_slot] = sig;
@@ -1403,7 +1403,7 @@ struct rte_hash */* The loads of sig_current in search_one_bucket * should not move below the load from tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_acquire); +rte_atomic_thread_fence (rte_memory_order_acquire);/* Re-read the table change counter to check if the * table has changed during search. If yes, re-do * the search.
@@ -1632,7 +1632,7 @@ struct rte_hash */* The store to sig_current should * not move above the store to tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_release); +rte_atomic_thread_fence (rte_memory_order_release); } last_bkt->sig_current[i] =NULL_SIGNATURE ; rte_atomic_store_explicit(&last_bkt->key_idx[i],
@@ -2223,7 +2223,7 @@ struct rte_hash */* The loads of sig_current in compare_signatures * should not move below the load from tbl_chng_cnt. */ -__atomic_thread_fence (rte_memory_order_acquire); +rte_atomic_thread_fence (rte_memory_order_acquire);/* Re-read the table change counter to check if the * table has changed during search. If yes, re-do * the search.
Signature · 1 line
1.8.3.1
PATCH v2 4/6 ring: use rte atomic thread fence
In reply to Tyler RetzlaffUse rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/ring/rte_ring_c11_pvt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/ring/rte_ring_c11_pvt.h +2 -2
@@ -68,7 +68,7 @@ n = max;/* Ensure the head is read before tail */ -__atomic_thread_fence (rte_memory_order_acquire); +rte_atomic_thread_fence (rte_memory_order_acquire);/* load-acquire synchronize with store-release of ht->tail * in update_tail.
@@ -145,7 +145,7 @@ n = max;/* Ensure the head is read before tail */ -__atomic_thread_fence (rte_memory_order_acquire); +rte_atomic_thread_fence (rte_memory_order_acquire);/* this load-acquire synchronize with store-release of ht->tail * in update_tail.
Signature · 1 line
1.8.3.1
PATCH v2 5/6 stack: use rte atomic thread fence
In reply to Tyler RetzlaffUse rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/stack/rte_stack_lf_c11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/stack/rte_stack_lf_c11.h +1 -1
@@ -110,7 +110,7 @@* elements are properly ordered with respect to the head * pointer read. */ -__atomic_thread_fence (rte_memory_order_acquire); +rte_atomic_thread_fence (rte_memory_order_acquire);rte_prefetch0 (old_head.top);
Signature · 1 line
1.8.3.1
PATCH v2 6/6 lpm: use rte atomic thread fence
In reply to Tyler RetzlaffUse rte_atomic_thread_fence instead of directly using __atomic_thread_fence builtin gcc intrinsic
--- lib/lpm/rte_lpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/lpm/rte_lpm.c +2 -2
@@ -1116,7 +1116,7 @@ struct rte_lpm ** Prevent the free of the tbl8 group from hoisting. */ i_lpm->lpm.tbl24[tbl24_index].valid =0 ; -__atomic_thread_fence (__ATOMIC_RELEASE); +rte_atomic_thread_fence (rte_memory_order_release); status =tbl8_free (i_lpm, tbl8_group_start); }else if (tbl8_recycle_index >-1 ) {/* Update tbl24 entry. */
@@ -1132,7 +1132,7 @@ struct rte_lpm **/ __atomic_store (&i_lpm->lpm.tbl24[tbl24_index], &new_tbl24_entry, __ATOMIC_RELAXED); -__atomic_thread_fence (__ATOMIC_RELEASE); +rte_atomic_thread_fence (rte_memory_order_release); status =tbl8_free (i_lpm, tbl8_group_start); }#undef group_idx
Signature · 1 line
1.8.3.1
Quoted 33 lines · Tyler Retzlaff
Replace use of
__atomic_thread_fencewithrte_atomic_thread_fence.Notes:
The rest of lib/lpm will be converted to
rte_atomicin a separate series (to be submitted soon).There are existing checkpatches checks that catch use of both
__atomic_thread_fenceand__rte_atomic_thread_fencein new submissions.v2:
* change series to userte_atomic_thread_fenceinstead of__rte_atomic_thread_fence(internal)
* also change__atomic_thread_fencein lib/lpmTyler Retzlaff (6):
distributor: use rte atomic thread fence
eal: use rte atomic thread fence
hash: use rte atomic thread fence
ring: use rte atomic thread fence
stack: use rte atomic thread fence
lpm: use rte atomic thread fencelib/distributor/rte_distributor.c | 2 +- lib/eal/common/eal_common_trace.c | 2 +- lib/eal/include/rte_mcslock.h | 4 ++-- lib/hash/rte_cuckoo_hash.c | 10 +++++----- lib/lpm/rte_lpm.c | 4 ++-- lib/ring/rte_ring_c11_pvt.h | 4 ++-- lib/stack/rte_stack_lf_c11.h | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-)
Thomas Monjalon
Acked-byQuoted 24 lines
Quoted 16 lines
Replace use of
__atomic_thread_fencewithrte_atomic_thread_fence.Notes:
The rest of lib/lpm will be converted to
rte_atomicin a separate series (to be submitted soon).There are existing checkpatches checks that catch use of both
__atomic_thread_fenceand__rte_atomic_thread_fencein new submissions.v2:
* change series to userte_atomic_thread_fenceinstead of__rte_atomic_thread_fence(internal)
* also change__atomic_thread_fencein lib/lpmQuoted 7 lines
Tyler Retzlaff (6):
distributor: use rte atomic thread fence
eal: use rte atomic thread fence
hash: use rte atomic thread fence
ring: use rte atomic thread fence
stack: use rte atomic thread fence
lpm: use rte atomic thread fence
Quoted 1 line
Series-acked-by Chengwen Feng <[email protected]>
Squashed and applied, thanks.