From ae526e32bd36cfb84045c8d2fd34e0b9e39a52f8 Mon Sep 17 00:00:00 2001 From: Xiao Guangrong Date: Tue, 21 Aug 2018 16:10:25 +0800 Subject: migration: hold the lock only if it is really needed Try to hold src_page_req_mutex only if the queue is not empty Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Signed-off-by: Xiao Guangrong Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'migration') 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 = -- cgit v1.2.3-55-g7522