From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baNXu-0002zQ-G9 for qemu-devel@nongnu.org; Thu, 18 Aug 2016 09:39:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1baNXt-0001KI-J8 for qemu-devel@nongnu.org; Thu, 18 Aug 2016 09:39:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baNXt-0001K5-DT for qemu-devel@nongnu.org; Thu, 18 Aug 2016 09:39:45 -0400 From: Stefan Hajnoczi Date: Thu, 18 Aug 2016 14:39:38 +0100 Message-Id: <1471527578-9435-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1471527578-9435-1-git-send-email-stefanha@redhat.com> References: <1471527578-9435-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL for-2.7 2/2] block: fix possible reorder of flush operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , "Denis V. Lunev" , Evgeny Yakovlev , Stefan Hajnoczi , Fam Zheng , Kevin Wolf , Max Reitz From: "Denis V. Lunev" This patch reduce CPU usage of flush operations a bit. When we have one flush completed we should kick only next operation. We should not start all pending operations in the hope that they will go back to wait on wait_queue. Also there is a technical possibility that requests will get reordered with the previous approach. After wakeup all requests are removed from the wait queue. They become active and they are processed one-by-one adding to the wait queue in the same order. Though new flush can arrive while all requests are not put into the queue. Signed-off-by: Denis V. Lunev Tested-by: Evgeny Yakovlev Signed-off-by: Evgeny Yakovlev Message-id: 1471457214-3994-3-git-send-email-den@openvz.org CC: Stefan Hajnoczi CC: Fam Zheng CC: Kevin Wolf CC: Max Reitz Signed-off-by: Stefan Hajnoczi --- block/io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 9c04086..420944d 100644 --- a/block/io.c +++ b/block/io.c @@ -2358,7 +2358,8 @@ out: /* Notify any pending flushes that we have completed */ bs->flushed_gen = current_gen; bs->active_flush_req = NULL; - qemu_co_queue_restart_all(&bs->flush_queue); + /* Return value is ignored - it's ok if wait queue is empty */ + qemu_co_queue_next(&bs->flush_queue); tracked_request_end(&req); return ret; -- 2.7.4