From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ydi9T-0001w6-IH for qemu-devel@nongnu.org; Thu, 02 Apr 2015 12:39:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ydi9Q-0004XG-7j for qemu-devel@nongnu.org; Thu, 02 Apr 2015 12:39:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ydi9Q-0004UI-0W for qemu-devel@nongnu.org; Thu, 02 Apr 2015 12:39:28 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t32GdQmG003132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 2 Apr 2015 12:39:26 -0400 From: Stefan Hajnoczi Date: Thu, 2 Apr 2015 17:39:22 +0100 Message-Id: <1427992762-10126-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH] thread-pool: clean up thread_pool_completion_bh() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , John Snow , 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 --- 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); } } -- 2.1.0