[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/20] migration: hold the lock only if it is really
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 20/20] migration: hold the lock only if it is really needed |
Date: |
Wed, 22 Aug 2018 14:00:50 +0200 |
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>
Reviewed-by: Juan Quintela <address@hidden>
Signed-off-by: Juan Quintela <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 40013e68a1..79c89425a3 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2033,6 +2033,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.17.1
- [Qemu-devel] [PULL 14/20] migration: poll the cm event for destination qemu, (continued)
- [Qemu-devel] [PULL 14/20] migration: poll the cm event for destination qemu, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 05/20] migration: disable RDMA WRITE after postcopy started, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 09/20] migration: implement io_set_aio_fd_handler function for RDMA QIOChannel, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 07/20] migration: implement bi-directional RDMA QIOChannel, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 16/20] migration: fix counting normal page for compression, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 13/20] tests/migration-test: Silence the kvm_hv message by default, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 15/20] migration: do not wait for free thread, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 17/20] migration: introduce save_zero_page_to_file, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 18/20] migration: drop the return value of do_compress_ram_page, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 19/20] migration: move handle of zero page to the thread, Juan Quintela, 2018/08/22
- [Qemu-devel] [PULL 20/20] migration: hold the lock only if it is really needed,
Juan Quintela <=
- Re: [Qemu-devel] [PULL 00/20] Migration pull requset, Peter Maydell, 2018/08/24