[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 06/10] migration: hold the lock only if it is rea
From: |
guangrong . xiao |
Subject: |
[Qemu-devel] [PATCH v3 06/10] migration: hold the lock only if it is really needed |
Date: |
Tue, 7 Aug 2018 17:12:05 +0800 |
From: Xiao Guangrong <address@hidden>
Try to hold src_page_req_mutex only if the queue is not
empty
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Peter Xu <address@hidden>
Signed-off-by: Xiao Guangrong <address@hidden>
---
include/qemu/queue.h | 1 +
migration/ram.c | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index 59fd1203a1..ac418efc43 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -341,6 +341,7 @@ struct {
\
/*
* Simple queue access methods.
*/
+#define QSIMPLEQ_EMPTY_ATOMIC(head) (atomic_read(&((head)->sqh_first)) == NULL)
#define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
#define QSIMPLEQ_FIRST(head) ((head)->sqh_first)
#define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
diff --git a/migration/ram.c b/migration/ram.c
index d804d01aae..99ecf9b315 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2026,6 +2026,10 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t
*offset)
{
RAMBlock *block = NULL;
+ if (QSIMPLEQ_EMPTY_ATOMIC(&rs->src_page_requests)) {
+ return NULL;
+ }
+
qemu_mutex_lock(&rs->src_page_req_mutex);
if (!QSIMPLEQ_EMPTY(&rs->src_page_requests)) {
struct RAMSrcPageRequest *entry =
--
2.14.4
- [Qemu-devel] [PATCH v3 00/10] migration: compression optimization, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 02/10] migration: fix counting normal page for compression, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 03/10] migration: introduce save_zero_page_to_file, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 04/10] migration: drop the return value of do_compress_ram_page, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 05/10] migration: move handle of zero page to the thread, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 06/10] migration: hold the lock only if it is really needed,
guangrong . xiao <=
- [Qemu-devel] [PATCH v3 07/10] migration: do not flush_compressed_data at the end of each iteration, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 08/10] migration: handle the error condition properly, guangrong . xiao, 2018/08/07
- Re: [Qemu-devel] [PATCH v3 08/10] migration: handle the error condition properly, Dr. David Alan Gilbert, 2018/08/08