All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] Fix occasional test fail on multithread
@ 2022-05-17  8:29 Hiroki Narukawa
  2022-05-17  8:29 ` [PATCH 1/1] test-thread-pool: Fix occasional test fail Hiroki Narukawa
  2022-06-06  6:59 ` [PATCH 0/1] Fix occasional test fail on multithread 成川 弘樹
  0 siblings, 2 replies; 3+ messages in thread
From: Hiroki Narukawa @ 2022-05-17  8:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, aoiwa, Hiroki Narukawa

In some of our environment, sometimes test did not pass due to multithreading behavior.

I think this fix will check correct behavior. Could you review this patch?

Hiroki Narukawa (1):
  test-thread-pool: Fix occasional test fail

 tests/unit/test-thread-pool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

-- 
2.17.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] test-thread-pool: Fix occasional test fail
  2022-05-17  8:29 [PATCH 0/1] Fix occasional test fail on multithread Hiroki Narukawa
@ 2022-05-17  8:29 ` Hiroki Narukawa
  2022-06-06  6:59 ` [PATCH 0/1] Fix occasional test fail on multithread 成川 弘樹
  1 sibling, 0 replies; 3+ messages in thread
From: Hiroki Narukawa @ 2022-05-17  8:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, aoiwa, Hiroki Narukawa

I encountered occasional test fail in some of build environment.

Then I found that adding g_usleep(20000); soon after
> if (qatomic_cmpxchg(&data[i].n, 0, 4) == 0) {
in do_test_cancel() in tests/unit/test-thread-pool.c reproduces.

In this test, cancel operation is not done atomically.

If data.n is set to 4, long_cb() finishes immediately, bdrv_aio_cancel()
is called after that, the job is done and
> g_assert_cmpint(data[i].ret, ==, -ECANCELED);
at the case data[i].n == 4 fails.

This patch makes this rare situation to pass correctly.

Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
---
 tests/unit/test-thread-pool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/unit/test-thread-pool.c b/tests/unit/test-thread-pool.c
index 6020e65d69..c29afe2bef 100644
--- a/tests/unit/test-thread-pool.c
+++ b/tests/unit/test-thread-pool.c
@@ -29,8 +29,12 @@ static int long_cb(void *opaque)
     if (qatomic_cmpxchg(&data->n, 0, 1) == 0) {
         g_usleep(2000000);
         qatomic_or(&data->n, 2);
+        return 0;
     }
-    return 0;
+    /* In rare cases that reach here, this job will be done,
+     * but should be treated as canceled.
+     */
+    return -ECANCELED;
 }
 
 static void done_cb(void *opaque, int ret)
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 0/1] Fix occasional test fail on multithread
  2022-05-17  8:29 [PATCH 0/1] Fix occasional test fail on multithread Hiroki Narukawa
  2022-05-17  8:29 ` [PATCH 1/1] test-thread-pool: Fix occasional test fail Hiroki Narukawa
@ 2022-06-06  6:59 ` 成川 弘樹
  1 sibling, 0 replies; 3+ messages in thread
From: 成川 弘樹 @ 2022-06-06  6:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, aoiwa

ping, how is the status of this patch?

On 2022/05/17 17:29, Hiroki Narukawa wrote:
> In some of our environment, sometimes test did not pass due to multithreading behavior.
> 
> I think this fix will check correct behavior. Could you review this patch?
> 
> Hiroki Narukawa (1):
>    test-thread-pool: Fix occasional test fail
> 
>   tests/unit/test-thread-pool.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-06  7:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17  8:29 [PATCH 0/1] Fix occasional test fail on multithread Hiroki Narukawa
2022-05-17  8:29 ` [PATCH 1/1] test-thread-pool: Fix occasional test fail Hiroki Narukawa
2022-06-06  6:59 ` [PATCH 0/1] Fix occasional test fail on multithread 成川 弘樹

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.