qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Requesting review about a bugfix in touch_all_pages


From: 陈蒙蒙
Subject: Requesting review about a bugfix in touch_all_pages
Date: Mon, 6 Apr 2020 03:13:34 +0000


From faf903f7b8892179e64bd1a37fe3585a6441bc51 Mon Sep 17 00:00:00 2001
From: Bauerchen <address@hidden>
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 <address@hidden>
---
 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]