From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ydif8-0003g5-Hr for qemu-devel@nongnu.org; Thu, 02 Apr 2015 13:12:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ydif4-0000pa-BV for qemu-devel@nongnu.org; Thu, 02 Apr 2015 13:12:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ydif4-0000oV-2Y for qemu-devel@nongnu.org; Thu, 02 Apr 2015 13:12:10 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t32HC8pw031088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 2 Apr 2015 13:12:09 -0400 Message-ID: <551D7863.3070007@redhat.com> Date: Thu, 02 Apr 2015 19:12:03 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1427992762-10126-1-git-send-email-stefanha@redhat.com> In-Reply-To: <1427992762-10126-1-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] thread-pool: clean up thread_pool_completion_bh() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Kevin Wolf , John Snow On 02/04/2015 18:39, Stefan Hajnoczi wrote: > 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. And not once, twice. :) This was the outcome of removing THREAD_CANCELED. > 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); > } > } > Reviewed-by: Paolo Bonzini