Requesting review about a bugfix in touch_all_pages
From faf903f7b8892179e64bd1a37fe3585a6441bc51 Mon Sep 17 00:00:00 2001
From: Bauerchen <[email protected]>
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;
---
util/oslib-posix.c | 3 +++
1 file changed, 3 insertions(+)
util/oslib-posix.c +0 -0
@@ -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
Paolo Bonzini
AppliedQuoted 28 lines · bauerchen(陈蒙蒙)
From
faf903f7b8892179e64bd1a37fe3585a6441bc51Mon Sep 17 00:00:00 2001
From: Bauerchen <[email protected]>
Date: Mon, 6 Apr 2020 10:36:54 +0800
Subject: [PATCH] Fix: Intouch_all_pages, maybe we need a lock to protectqemu_cond_boardcast, orqemu_cond_boardcastmay be called before all touch page threads enterqemu_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 <[email protected]>---
util/oslib-posix.c | 3 +++1 file changed, 3 insertions(+)util/oslib-posix.c +3
-0@@ -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);
Quoted 6 lines
for (i = 0; i <memset_num_threads; i++) {qemu_thread_join(&memset_thread[i].pgthread); --
1.8.3.1
Queued, thanks.
Paolo