From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b04Jz-0007Vv-2D for qemu-devel@nongnu.org; Tue, 10 May 2016 05:51:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b04Jt-0005kO-RV for qemu-devel@nongnu.org; Tue, 10 May 2016 05:51:17 -0400 Received: from [59.151.112.132] (port=3178 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b04Jt-0005iq-97 for qemu-devel@nongnu.org; Tue, 10 May 2016 05:51:13 -0400 Message-ID: <5731AFD7.4030504@cn.fujitsu.com> Date: Tue, 10 May 2016 17:54:31 +0800 From: Changlong Xie MIME-Version: 1.0 References: <1462871793-31561-1-git-send-email-xiecl.fnst@cn.fujitsu.com> <5731AC04.8010709@virtuozzo.com> In-Reply-To: <5731AC04.8010709@virtuozzo.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] rfifolock: no need to get thread identifier when nesting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" , qemu devel , Stefan Hajnoczi On 05/10/2016 05:38 PM, Denis V. Lunev wrote: > On 05/10/2016 12:16 PM, Changlong Xie wrote: >> Signed-off-by: Changlong Xie >> --- >> util/rfifolock.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/util/rfifolock.c b/util/rfifolock.c >> index c22f5fe..f406cc1 100644 >> --- a/util/rfifolock.c >> +++ b/util/rfifolock.c >> @@ -50,6 +50,7 @@ void rfifolock_lock(RFifoLock *r) >> if (r->nesting > 0 && qemu_thread_is_self(&r->owner_thread)) { >> r->tail--; /* put ticket back, we're nesting */ >> + goto out; >> } else { >> while (ticket != r->head) { >> /* Invoke optional contention callback */ >> @@ -61,6 +62,7 @@ void rfifolock_lock(RFifoLock *r) >> } >> qemu_thread_get_self(&r->owner_thread); >> +out: >> r->nesting++; >> qemu_mutex_unlock(&r->lock); >> } > it would be better to put > qemu_thread_get_self(&r->owner_thread); > 2 lines up and avoid unnecessary goto Yes, it's a better choice, will send out v2 Thanks -Xie > > >