From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn71G-00089P-TY for qemu-devel@nongnu.org; Tue, 28 Apr 2015 11:02:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yn71C-0001xn-76 for qemu-devel@nongnu.org; Tue, 28 Apr 2015 11:01:54 -0400 From: Kevin Wolf Date: Tue, 28 Apr 2015 17:00:03 +0200 Message-Id: <1430233258-31807-22-git-send-email-kwolf@redhat.com> In-Reply-To: <1430233258-31807-1-git-send-email-kwolf@redhat.com> References: <1430233258-31807-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 21/76] thread-pool: clean up thread_pool_completion_bh() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Stefan Hajnoczi This patch simplifies thread_pool_completion_bh(). The function first checks elem->state: if (elem->state != THREAD_DONE) { continue; } It then goes on to check elem->state == THREAD_DONE although we already know this must be the case. The QLIST_REMOVE() is duplicated down both branches of an if-else statement so that can be lifted out as well. Signed-off-by: Stefan Hajnoczi Reviewed-by: Paolo Bonzini Message-id: 1427992762-10126-1-git-send-email-stefanha@redhat.com Signed-off-by: Kevin Wolf --- thread-pool.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/thread-pool.c b/thread-pool.c index e2cac8e..ac909f4 100644 --- a/thread-pool.c +++ b/thread-pool.c @@ -170,12 +170,12 @@ restart: if (elem->state != THREAD_DONE) { continue; } - if (elem->state == THREAD_DONE) { - trace_thread_pool_complete(pool, elem, elem->common.opaque, - elem->ret); - } - if (elem->state == THREAD_DONE && elem->common.cb) { - QLIST_REMOVE(elem, all); + + trace_thread_pool_complete(pool, elem, elem->common.opaque, + elem->ret); + QLIST_REMOVE(elem, all); + + if (elem->common.cb) { /* Read state before ret. */ smp_rmb(); @@ -188,8 +188,6 @@ restart: qemu_aio_unref(elem); goto restart; } else { - /* remove the request */ - QLIST_REMOVE(elem, all); qemu_aio_unref(elem); } } -- 1.8.3.1