[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 7/8] migration: hold the lock only if it is reall
From: |
guangrong . xiao |
Subject: |
[Qemu-devel] [PATCH v2 7/8] migration: hold the lock only if it is really needed |
Date: |
Thu, 19 Jul 2018 20:15:19 +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>
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 e1909502da..89305c7af5 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2062,6 +2062,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
- Re: [Qemu-devel] [PATCH v2 6/8] migration: move handle of zero page to the thread, (continued)
[Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, guangrong . xiao, 2018/07/19
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Xiao Guangrong, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Peter Xu, 2018/07/23
- Re: [Qemu-devel] [PATCH v2 8/8] migration: do not flush_compressed_data at the end of each iteration, Xiao Guangrong, 2018/07/24
[Qemu-devel] [PATCH v2 7/8] migration: hold the lock only if it is really needed,
guangrong . xiao <=