replace tight loop with wait until equal api
cover replace tight loop with wait until equal api
For dpdk/lib, directly use wait_until_equal API to replace tight loop.
Feifei Wang (2):
eal/common: use wait until equal API for tight loop
mcslock: use wait until equal API for tight loop
lib/eal/common/eal_common_mcfg.c | 3 +-- lib/eal/include/generic/rte_mcslock.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 eal/common: use wait until equal API for tight loop
Instead of polling for mcfg->magic to be updated, use wait_until_equal API.
--- lib/eal/common/eal_common_mcfg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
lib/eal/common/eal_common_mcfg.c +1 -2
@@ -30,8 +30,7 @@ eal_mcfg_wait_complete(void)struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config;/* wait until shared mem_config finish initialising */ -while (mcfg->magic !=RTE_MAGIC ) -rte_pause (); +rte_wait_until_equal_32 (&mcfg->magic,RTE_MAGIC , __ATOMIC_RELAXED); }int
Signature · 1 line
2.25.1
PATCH 2/2 mcslock: use wait until equal API for tight loop
In reply to Feifei WangInstead of polling for previous lock holder unlocking, use wait_until_equal API.
--- lib/eal/include/generic/rte_mcslock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/eal/include/generic/rte_mcslock.h +2 -2
@@ -84,8 +84,8 @@ rte_mcslock_lock(rte_mcslock_t **msl, rte_mcslock_t *me)* to spin on me->locked until the previous lock holder resets * the me->locked using mcslock_unlock(). */ -while (__atomic_load_n (&me->locked, __ATOMIC_ACQUIRE)) -rte_pause (); +rte_wait_until_equal_32 ((volatile uint32_t *)&me->locked, +0 , __ATOMIC_ACQUIRE); }/**
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v1 2/2] mcslock: use wait until equal API for tight loop
Quoted 15 lines · Feifei Wang
Instead of polling for previous lock holder unlocking, use
wait_until_equalAPI.Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- lib/eal/include/generic/rte_mcslock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/eal/include/generic/rte_mcslock.h +0
-0
lib/eal/include/generic/rte_mcslock.h rte_mcslock_lock(rte_mcslock_t **msl, rte_mcslock_t *me) · line 88
Quoted 7 lines
lib/eal/include/generic/rte_mcslock.h +2
-2@@ -84,8 +84,8 @@ rte_mcslock_lock(rte_mcslock_t **msl, rte_mcslock_t *me)* to spin on me->locked until the previous lock holder resets * the me->locked using mcslock_unlock(). */ -while (__atomic_load_n (&me->locked, __ATOMIC_ACQUIRE)) -rte_pause (); +rte_wait_until_equal_32 ((volatile uint32_t *)&me->locked, +0 , __ATOMIC_ACQUIRE);
Why do you need to cast as volatile?
Signature · 1 line
David Marchand
[dpdk-dev] 回复: [PATCH v1 2/2] mcslock: use wait until equal API for tight loop
Quoted 37 lines
-----邮件原件-----
发件人: dev <[email protected]> 代表 David Marchand
发送时间: Tuesday, October 19, 2021 7:10 PM
收件人: Feifei Wang <[email protected]>
抄送: Honnappa Nagarahalli <[email protected]>; dev <[email protected]>; nd <[email protected]>; Ruifeng Wang <[email protected]>
主题: Re: [dpdk-dev] [PATCH v1 2/2] mcslock: use wait until equal API for tight looplib/eal/include/generic/rte_mcslock.h rte_mcslock_lock(rte_mcslock_t **msl,
Quoted 16 lines · Feifei Wang
Instead of polling for previous lock holder unlocking, use
wait_until_equalAPI.Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- lib/eal/include/generic/rte_mcslock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/eal/include/generic/rte_mcslock.h +0
-0@@ -84,8 +84,8 @@ rte_mcslock_lock(rte_mcslock_t **msl,
rte_mcslock_t*me)lib/eal/include/generic/rte_mcslock.h rte_mcslock_lock(rte_mcslock_t **msl, rte_mcslock_t *me) · line 88
Quoted 7 lines
lib/eal/include/generic/rte_mcslock.h +2
-2* to spin on me->locked until the previous lock holder resets * the me->locked using mcslock_unlock(). */ -while (__atomic_load_n (&me->locked, __ATOMIC_ACQUIRE)) -rte_pause (); +rte_wait_until_equal_32 ((volatile uint32_t *)&me->locked, +0 , __ATOMIC_ACQUIRE);
Quoted 1 line
Why do you need to cast as volatile?
Thanks for the comments.
This is firstly because rte_wait_until_equal API defines the variable as volatile. However, with your comment, I find 'me->lock' is not volatile. And by the test, I think you are right, it is necessary to add volatile here.
Quoted 4 lines
--
David Marchand
[dpdk-dev] 回复: [PATCH v1 2/2] mcslock: use wait until equal API for tight loop
Quoted 49 lines
-----邮件原件-----
发件人: Feifei Wang
发送时间: Wednesday, October 20, 2021 10:46 AM
收件人: David Marchand <[email protected]>
抄送: Honnappa Nagarahalli <[email protected]>; dev <[email protected]>; nd <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>
主题: 回复: [dpdk-dev] [PATCH v1 2/2] mcslock: use wait until equal API for tight loopQuoted 6 lines
-----邮件原件-----
发件人: dev <[email protected]> 代表 David Marchand 发送时间: Tuesday, October 19, 2021 7:10 PM
收件人: Feifei Wang <[email protected]>
抄送: Honnappa Nagarahalli <[email protected]>; dev <[email protected]>; nd <[email protected]>; Ruifeng WangQuoted 30 lines
主题: Re: [dpdk-dev] [PATCH v1 2/2] mcslock: use wait until equal API for tight loop
lib/eal/include/generic/rte_mcslock.h rte_mcslock_lock(rte_mcslock_t **msl,
Quoted 16 lines · Feifei Wang
Instead of polling for previous lock holder unlocking, use
wait_until_equalAPI.Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- lib/eal/include/generic/rte_mcslock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/eal/include/generic/rte_mcslock.h +0
-0@@ -84,8 +84,8 @@ rte_mcslock_lock(rte_mcslock_t **msl,
rte_mcslock_t*me)Quoted 7 lines
lib/eal/include/generic/rte_mcslock.h +2
-2* to spin on me->locked until the previous lock holder resets * the me->locked using mcslock_unlock(). */ -while (__atomic_load_n (&me->locked, __ATOMIC_ACQUIRE)) -rte_pause (); +rte_wait_until_equal_32 ((volatile uint32_t *)&me->locked, +0 , __ATOMIC_ACQUIRE);
Quoted 5 lines
Quoted 1 line
Why do you need to cast as volatile?
Thanks for the comments.
This is firstly becauserte_wait_until_equalAPI defines the variable as volatile. However, with your comment, I find 'me->lock' is not volatile. And by the test, I think you are right, it is necessary to add volatile here.
Sorry, correct the writing mistakes:
'It is unnecessary to add volatile here.'
Quoted 4 lines
Quoted 4 lines
--
David Marchand
Hi,
Would you please help review this patch series?
Thanks very much.
Best Regards
Feifei
Quoted 19 lines
-----邮件原件-----
发件人: Feifei Wang <[email protected]>
发送时间: Wednesday, August 25, 2021 4:01 PM
抄送: [email protected]; nd <[email protected]>; Feifei Wang <[email protected]>
主题: [PATCH v1 0/2] replace tight loop with wait until equal apiFor dpdk/lib, directly use
wait_until_equalAPI to replace tight loop.Feifei Wang (2):
eal/common: use wait until equal API for tight loop
mcslock: use wait until equal API for tight looplib/eal/common/eal_common_mcfg.c | 3 +-- lib/eal/include/generic/rte_mcslock.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)--
2.25.1
v2 cover replace tight loop with wait until equal api
In reply to Feifei WangFor dpdk/lib, directly use wait_until_equal API to replace tight loop.
v2:
1. delete wrong 'volatile' in mcslock (David)
Feifei Wang (2):
eal/common: use wait until equal API for tight loop
mcslock: use wait until equal API for tight loop
lib/eal/common/eal_common_mcfg.c | 3 +-- lib/eal/include/generic/rte_mcslock.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/2 eal/common: use wait until equal API for tight loop
Instead of polling for mcfg->magic to be updated, use wait_until_equal API.
--- lib/eal/common/eal_common_mcfg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
lib/eal/common/eal_common_mcfg.c +1 -2
@@ -30,8 +30,7 @@ eal_mcfg_wait_complete(void)struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config;/* wait until shared mem_config finish initialising */ -while (mcfg->magic !=RTE_MAGIC ) -rte_pause (); +rte_wait_until_equal_32 (&mcfg->magic,RTE_MAGIC , __ATOMIC_RELAXED); }int
Signature · 1 line
2.25.1
PATCH v2 2/2 mcslock: use wait until equal API for tight loop
In reply to Feifei WangInstead of polling for previous lock holder unlocking, use wait_until_equal API.
--- lib/eal/include/generic/rte_mcslock.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
lib/eal/include/generic/rte_mcslock.h +1 -2
@@ -84,8 +84,7 @@ rte_mcslock_lock(rte_mcslock_t **msl, rte_mcslock_t *me)* to spin on me->locked until the previous lock holder resets * the me->locked using mcslock_unlock(). */ -while (__atomic_load_n (&me->locked, __ATOMIC_ACQUIRE)) -rte_pause (); +rte_wait_until_equal_32 ((uint32_t *)&me->locked,0 , __ATOMIC_ACQUIRE); }/**
Signature · 1 line
2.25.1
Quoted 6 lines · Feifei Wang
For dpdk/lib, directly use
wait_until_equalAPI to replace tight loop.v2:
1. delete wrong 'volatile' in mcslock (David)
Quoted 8 lines
Feifei Wang (2):
eal/common: use wait until equal API for tight loop
mcslock: use wait until equal API for tight looplib/eal/common/eal_common_mcfg.c | 3 +-- lib/eal/include/generic/rte_mcslock.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
Series applied, thanks.
Signature · 1 line
David Marchand