test/distributor: fix burst flush on worker quit
RFC PATCH 1/1 test/distributor: fix burst flush on worker quit
While working on RISC-V port I have encountered a situation where worker threads get stuck in the rte_distributor_return_pkt() function in the burst test.
After investigation some of the threads enter this function with flag RTE_DISTRIB_GET_BUF set in the d->retptr64[0]. At the same time main thread has already passed rte_distributor_process() so nobody will clear this flag and hence workers can't return.
What I've noticed is that adding a flush just after the last _process(), similarly to how quit_workers() function is written in the test_distributor.c fixes the issue.
Additionally the issue disappears when I remove the rdtsc delay code inside the rte_distributor_request_pkt().
However I can't get this to reproduce on x86 (even with SIMD forced off) and with artificial delays, which is why I wonder whether I'm not actually hiding some other issue.
Looking at the implementation of the distributor, it is based on __atomic_* builtins and the only platform related bit in the fast-path is the rte_rdtsc() and rte_pause(). There may be some issues in the toolchain (I've tried so far with the Ubuntu one - 10.2.0-8ubuntu1). I should add that all unit tests for distributor are passing so either there's some coverage corner case or the implementation works on RISC-V. As for RDTSC I'm using a sleep-stable time counter with 1MHz frequency and switching to high resolution cycle counter also removes the issue but that's the same as removing the rdtsc delay as mentioned above.
I'd love to hear from You if this fix makes any sense.
While modifying this test, I've also pulled in a fix from test_distributor.c which ensures that each thread gets his own wakeup packet as it's possible that when sending a burst of packets, they won't be spread over all the workers.
--- app/test/test_distributor_perf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
app/test/test_distributor_perf.c +4 -2
@@ -188,13 +188,15 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p)rte_mempool_get_bulk (p, (void *)bufs, num_workers); quit =1 ; -for (i =0 ; i < num_workers; i++) +for (i =0 ; i < num_workers; i++) { bufs[i]->hash.usr = i <<1 ; -rte_distributor_process (d, bufs, num_workers); +rte_distributor_process (d, &bufs[i],1 ); + }rte_mempool_put_bulk (p, (void *)bufs, num_workers);rte_distributor_process (d,NULL ,0 ); +rte_distributor_flush (d);rte_eal_mp_wait_lcore (); quit =0 ; worker_idx =0 ;
Signature · 1 line
2.27.0
Hi Stanislaw,
W dniu 26.04.2021 o 18:33, Stanislaw Kardach pisze:
Quoted 8 lines
While working on RISC-V port I have encountered a situation where worker threads get stuck in the
rte_distributor_return_pkt()function in the burst test.
After investigation some of the threads enter this function with flagRTE_DISTRIB_GET_BUFset in the d->retptr64[0]. At the same time main thread has already passedrte_distributor_process()so nobody will clear this flag and hence workers can't return.
Quoted 8 lines
What I've noticed is that adding a flush just after the last
_process(), similarly to howquit_workers()function is written in thetest_distributor.cfixes the issue.
Additionally the issue disappears when I remove the rdtsc delay code inside therte_distributor_request_pkt().
However I can't get this to reproduce on x86 (even with SIMD forced off) and with artificial delays, which is why I wonder whether I'm not actually hiding some other issue.
I was able to reproduce the issue on x86 arch using VM with 32 emulated CPU cores.
I guess it would be enough to just have more than 8 worker threads, so not all of them would be awaken.
Quoted 11 lines
Looking at the implementation of the distributor, it is based on __atomic_* builtins and the only platform related bit in the fast-path is the
rte_rdtsc()andrte_pause(). There may be some issues in the toolchain (I've tried so far with the Ubuntu one - 10.2.0-8ubuntu1). I should add that all unit tests for distributor are passing so either there's some coverage corner case or the implementation works on RISC-V. As for RDTSC I'm using a sleep-stable time counter with 1MHz frequency and switching to high resolution cycle counter also removes the issue but that's the same as removing the rdtsc delay as mentioned above.
Quoted 1 line
I'd love to hear from You if this fix makes any sense.
Yes your patch fixes the issue and is perfectly fine.
Quoted 27 lines
While modifying this test, I've also pulled in a fix from
test_distributor.cwhich ensures that each thread gets his own wakeup packet as it's possible that when sending a burst of packets, they won't be spread over all the workers.Signed-off-by Stanislaw Kardach <[email protected]>Fixes 7c3287a10535 ("test/distributor: add performance test for burst mode")Cc David Marchand <[email protected]>--- app/test/test_distributor_perf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)app/test/test_distributor_perf.c +1
-2@@ -188,13 +188,15 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p)rte_mempool_get_bulk (p, (void *)bufs, num_workers); quit =1 ; -for (i =0 ; i < num_workers; i++) +for (i =0 ; i < num_workers; i++) { bufs[i]->hash.usr = i <<1 ; -rte_distributor_process (d, bufs, num_workers);
app/test/test_distributor_perf.c quit_workers(struct rte_distributor *d, struct rte_mempool *p) · line 202
Quoted 10 lines
app/test/test_distributor_perf.c +3
-0+rte_distributor_process (d, &bufs[i],1 ); + }rte_mempool_put_bulk (p, (void *)bufs, num_workers);rte_distributor_process (d,NULL ,0 ); +rte_distributor_flush (d);rte_eal_mp_wait_lcore (); quit =0 ; worker_idx =0 ;
Signature · 7 lines
Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Office +48 22 377 88 25 [email protected]
David Hunt
Acked-byQuoted 66 lines · Lukasz Wojciechowski
Hi Stanislaw,
W dniu 26.04.2021 o 18:33, Stanislaw Kardach pisze:
Quoted 8 lines
While working on RISC-V port I have encountered a situation where worker threads get stuck in the
rte_distributor_return_pkt()function in the burst test.
After investigation some of the threads enter this function with flagRTE_DISTRIB_GET_BUFset in the d->retptr64[0]. At the same time main thread has already passedrte_distributor_process()so nobody will clear this flag and hence workers can't return.Quoted 8 lines
What I've noticed is that adding a flush just after the last
_process(), similarly to howquit_workers()function is written in thetest_distributor.cfixes the issue.
Additionally the issue disappears when I remove the rdtsc delay code inside therte_distributor_request_pkt().
However I can't get this to reproduce on x86 (even with SIMD forced off) and with artificial delays, which is why I wonder whether I'm not actually hiding some other issue.I was able to reproduce the issue on x86 arch using VM with 32 emulated CPU cores.
I guess it would be enough to just have more than 8 worker threads, so not all of them would be awaken.Quoted 11 lines
Looking at the implementation of the distributor, it is based on __atomic_* builtins and the only platform related bit in the fast-path is the
rte_rdtsc()andrte_pause(). There may be some issues in the toolchain (I've tried so far with the Ubuntu one - 10.2.0-8ubuntu1). I should add that all unit tests for distributor are passing so either there's some coverage corner case or the implementation works on RISC-V. As for RDTSC I'm using a sleep-stable time counter with 1MHz frequency and switching to high resolution cycle counter also removes the issue but that's the same as removing the rdtsc delay as mentioned above.I'd love to hear from You if this fix makes any sense.
Yes your patch fixes the issue and is perfectly fine.
Quoted 31 lines
While modifying this test, I've also pulled in a fix from
test_distributor.cwhich ensures that each thread gets his own wakeup packet as it's possible that when sending a burst of packets, they won't be spread over all the workers.Signed-off-by Stanislaw Kardach <[email protected]>Fixes 7c3287a10535 ("test/distributor: add performance test for burst mode")Cc David Marchand <[email protected]>--- app/test/test_distributor_perf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)app/test/test_distributor_perf.c +3
-2@@ -188,13 +188,15 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p)rte_mempool_get_bulk (p, (void *)bufs, num_workers); quit =1 ; -for (i =0 ; i < num_workers; i++) +for (i =0 ; i < num_workers; i++) { bufs[i]->hash.usr = i <<1 ; -rte_distributor_process (d, bufs, num_workers); +rte_distributor_process (d, &bufs[i],1 ); + }rte_mempool_put_bulk (p, (void *)bufs, num_workers);
Quoted 7 lines
app/test/test_distributor_perf.c quit_workers(struct rte_distributor *d, struct rte_mempool *p) · line 202
Quoted 5 lines
app/test/test_distributor_perf.c +1
-0rte_distributor_process (d,NULL ,0 ); +rte_distributor_flush (d);rte_eal_mp_wait_lcore (); quit =0 ; worker_idx =0 ;Tested-by Lukasz Wojciechowski <[email protected]>Reviewed-by Lukasz Wojciechowski <[email protected]>
Thanks, Stanislaw, Lukasz.
On Wed, Apr 28, 2021 at 2:51 PM David Hunt <[email protected]> wrote:
<snip>
Quoted 5 lines
Thanks, Stanislaw, Lukasz.
Acked-by David Hunt <[email protected]>Just to be sure, may I send the non-RFC patch without the question part of
the description or would you prefer the current version to be merged?
Quoted 9 lines · Stanisław Kardach
On Wed, Apr 28, 2021 at 2:51 PM David Hunt <[email protected] <mailto:[email protected]>> wrote:
<snip>Thanks, Stanislaw, Lukasz.
Acked-by David Hunt <[email protected]<mailto:[email protected]>>
Just to be sure, may I send the non-RFC patch without the question part of the description or would you prefer the current version to be merged?
Hi Stanislaw,
It would be better to send a v2, as the concept looks good, was reviewd and tested by Lukasz, so remove the questions and send as a patch that could be merged.
Thanks,
Dave.
Quoted 28 lines · Stanislaw Kardach
While working on RISC-V port I have encountered a situation where worker threads get stuck in the
rte_distributor_return_pkt()function in the burst test.
After investigation some of the threads enter this function with flagRTE_DISTRIB_GET_BUFset in the d->retptr64[0]. At the same time main thread has already passedrte_distributor_process()so nobody will clear this flag and hence workers can't return.What I've noticed is that adding a flush just after the last
_process(), similarly to howquit_workers()function is written in thetest_distributor.cfixes the issue.
Additionally the issue disappears when I remove the rdtsc delay code inside therte_distributor_request_pkt().
However I can't get this to reproduce on x86 (even with SIMD forced off) and with artificial delays, which is why I wonder whether I'm not actually hiding some other issue.Looking at the implementation of the distributor, it is based on __atomic_* builtins and the only platform related bit in the fast-path is the
rte_rdtsc()andrte_pause(). There may be some issues in the toolchain (I've tried so far with the Ubuntu one - 10.2.0-8ubuntu1). I should add that all unit tests for distributor are passing so either there's some coverage corner case or the implementation works on RISC-V. As for RDTSC I'm using a sleep-stable time counter with 1MHz frequency and switching to high resolution cycle counter also removes the issue but that's the same as removing the rdtsc delay as mentioned above.
Quoted 6 lines
I'd love to hear from You if this fix makes any sense.
While modifying this test, I've also pulled in a fix from
test_distributor.cwhich ensures that each thread gets his own wakeup packet as it's possible that when sending a burst of packets, they won't be spread over all the workers.
Do we have two fixes in a single patch?
This is ok if both point at the same originating commit, but else, we need two patches with proper Fixes: line.
I see we have reviews, can you submit non-rfc patches?
Thanks.
Signature · 1 line
David Marchand
On Wed, Apr 28, 2021 at 3:11 PM David Marchand <[email protected]> wrote:
<snip>
Quoted 5 lines
Do we have two fixes in a single patch?
This is ok if both point at the same originating commit, but else, we need two patches with proper Fixes: line.
Those touch different commits, I'll split them and send together.
Quoted 3 lines
I see we have reviews, can you submit non-rfc patches?
Will do.
Quoted 6 lines
Thanks.
--
David Marchand
v2 cover test/distributor: perf burst mode quit fixes
In reply to Stanislaw KardachThis series addresses two issues:
1. Worker threads hang when finishing the burst-mode distributor perf test. This was observed on a RISC-V platform as well as reproduced on x86.
2. Potential lack of fairness in final wakeup notification distribution in burst mode. Though this issue was not observed, the change is in line with the functional tests.
---
RFC -> V2
- Split 2 fixes into separate patches.
- Added review/test/ack tags from the RFC discussion.
---
Stanislaw Kardach (2):
test/distributor: fix worker notification in burst test/distributor: fix burst flush on worker quit
app/test/test_distributor_perf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.27.0
PATCH v2 1/2 test/distributor: fix worker notification in burst
Because a single worker can process more than one packet from the distributor, the final set of notifications in burst mode should be sent one-by-one to ensure that each worker has a chance to wake up.
This fix mirrors the change done in the functional test by commit f72bff0ec272 ("test/distributor: fix quitting workers in burst mode").
--- app/test/test_distributor_perf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
app/test/test_distributor_perf.c +3 -2
@@ -188,9 +188,10 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p)rte_mempool_get_bulk (p, (void *)bufs, num_workers); quit =1 ; -for (i =0 ; i < num_workers; i++) +for (i =0 ; i < num_workers; i++) { bufs[i]->hash.usr = i <<1 ; -rte_distributor_process (d, bufs, num_workers); +rte_distributor_process (d, &bufs[i],1 ); + }rte_mempool_put_bulk (p, (void *)bufs, num_workers);
Signature · 1 line
2.27.0
PATCH v2 2/2 test/distributor: fix burst flush on worker quit
In reply to Stanislaw KardachWhile working on RISC-V port I have encountered a situation where worker threads get stuck in the rte_distributor_return_pkt() function in the burst test.
Investigation showed some of the threads enter this function with flag RTE_DISTRIB_GET_BUF set in the d->retptr64[0]. At the same time the main thread has already passed rte_distributor_process() so nobody will clear this flag and hence workers can't return.
What I've noticed is that adding a flush just after the last _process(), similarly to how quit_workers() function is written in the test_distributor.c fixes the issue.
Lukasz Wojciechowski reproduced the same issue on x86 using a VM with 32 emulated CPU cores to force some lcores not to be woken up.
--- app/test/test_distributor_perf.c | 1 + 1 file changed, 1 insertion(+)
app/test/test_distributor_perf.c +1 -0
@@ -196,6 +196,7 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p)rte_mempool_put_bulk (p, (void *)bufs, num_workers);rte_distributor_process (d,NULL ,0 ); +rte_distributor_flush (d);rte_eal_mp_wait_lcore (); quit =0 ; worker_idx =0 ;
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH v2 0/2] test/distributor: perf burst mode quit fixes
In reply to Stanislaw KardachQuoted 9 lines · Stanislaw Kardach
This series addresses two issues:
1. Worker threads hang when finishing the burst-mode distributor perf test. This was observed on a RISC-V platform as well as reproduced on x86.
2. Potential lack of fairness in final wakeup notification distribution in burst mode. Though this issue was not observed, the change is in line with the functional tests.
Series applied, thanks.
Signature · 1 line
David Marchand