* Requesting review about a bugfix in touch_all_pages
@ 2020-04-06 3:13 bauerchen(陈蒙蒙)
2020-04-06 9:48 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: bauerchen(陈蒙蒙) @ 2020-04-06 3:13 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini
From faf903f7b8892179e64bd1a37fe3585a6441bc51 Mon Sep 17 00:00:00 2001
From: Bauerchen <bauerchen@tencent.com>
Date: Mon, 6 Apr 2020 10:36:54 +0800
Subject: [PATCH] Fix: In touch_all_pages, maybe we need a lock to protect
qemu_cond_boardcast, or qemu_cond_boardcast may be called before all touch
page threads enter qemu_cond_wait. In this case, main thread waits touch
page threads return, touch page threads wait main thread waking up, that is a
dead lock ,vm will be in pause state forever;
Signed-off-by: Bauerchen <bauerchen@tencent.com>
---
util/oslib-posix.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 4dd6d7d..062236a 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -492,8 +492,11 @@ static bool touch_all_pages(char *area, size_t hpagesize, size_t numpages,
QEMU_THREAD_JOINABLE);
addr += memset_thread[i].numpages * hpagesize;
}
+
+ qemu_mutex_lock(&page_mutex);
threads_created_flag = true;
qemu_cond_broadcast(&page_cond);
+ qemu_mutex_unlock(&page_mutex);
for (i = 0; i < memset_num_threads; i++) {
qemu_thread_join(&memset_thread[i].pgthread);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: Requesting review about a bugfix in touch_all_pages
2020-04-06 3:13 Requesting review about a bugfix in touch_all_pages bauerchen(陈蒙蒙)
@ 2020-04-06 9:48 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2020-04-06 9:48 UTC (permalink / raw)
To: bauerchen(陈蒙蒙), qemu-devel
On 06/04/20 05:13, bauerchen(陈蒙蒙) wrote:
>
> From faf903f7b8892179e64bd1a37fe3585a6441bc51 Mon Sep 17 00:00:00 2001
> From: Bauerchen <bauerchen@tencent.com>
> Date: Mon, 6 Apr 2020 10:36:54 +0800
> Subject: [PATCH] Fix: In touch_all_pages, maybe we need a lock to protect
> qemu_cond_boardcast, or qemu_cond_boardcast may be called before all touch
> page threads enter qemu_cond_wait. In this case, main thread waits touch
> page threads return, touch page threads wait main thread waking up, that is a
> dead lock ,vm will be in pause state forever;
>
> Signed-off-by: Bauerchen <bauerchen@tencent.com>
> ---
> util/oslib-posix.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index 4dd6d7d..062236a 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -492,8 +492,11 @@ static bool touch_all_pages(char *area, size_t hpagesize, size_t numpages,
> QEMU_THREAD_JOINABLE);
> addr += memset_thread[i].numpages * hpagesize;
> }
> +
> + qemu_mutex_lock(&page_mutex);
> threads_created_flag = true;
> qemu_cond_broadcast(&page_cond);
> + qemu_mutex_unlock(&page_mutex);
>
> for (i = 0; i < memset_num_threads; i++) {
> qemu_thread_join(&memset_thread[i].pgthread);
> --
> 1.8.3.1
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-06 10:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-06 3:13 Requesting review about a bugfix in touch_all_pages bauerchen(陈蒙蒙)
2020-04-06 9:48 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).