From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnlUy-0002X6-4a for qemu-devel@nongnu.org; Sat, 24 Sep 2016 07:52:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnlUt-0002SG-TW for qemu-devel@nongnu.org; Sat, 24 Sep 2016 07:52:03 -0400 Received: from mx6-phx2.redhat.com ([209.132.183.39]:39806) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnlUt-0002RA-KA for qemu-devel@nongnu.org; Sat, 24 Sep 2016 07:51:59 -0400 Date: Sat, 24 Sep 2016 07:51:48 -0400 (EDT) From: Paolo Bonzini Message-ID: <1562781019.2636285.1474717908026.JavaMail.zimbra@redhat.com> In-Reply-To: References: <1474615909-17069-1-git-send-email-pbonzini@redhat.com> <1474615909-17069-16-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 15/16] tcg: Make tb_flush() thread safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org, serge fdrv , cota@braap.org, alex bennee , sergey fedorov ----- Original Message ----- > From: "Richard Henderson" > To: "Paolo Bonzini" , qemu-devel@nongnu.org > Cc: "serge fdrv" , cota@braap.org, "alex bennee" , "sergey fedorov" > > Sent: Friday, September 23, 2016 8:06:09 PM > Subject: Re: [Qemu-devel] [PATCH 15/16] tcg: Make tb_flush() thread safe > > On 09/23/2016 12:31 AM, Paolo Bonzini wrote: > > + unsigned tb_flush_req = (unsigned) (uintptr_t) data; > > Extra cast? > > > - tcg_ctx.tb_ctx.tb_flush_count++; > > + atomic_inc(&tcg_ctx.tb_ctx.tb_flush_count); > > Since this is the only place this value is incremented, and we're under a > lock, > it should be cheaper to use > > atomic_mb_set(&tcg_ctx.tb_ctx.tb_flush_count, tb_flush_req + 1); atomic_set will do even. Though it's not really a fast path, which is why I went for atomic_inc. > > + uintptr_t tb_flush_req = (uintptr_t) > > + atomic_read(&tcg_ctx.tb_ctx.tb_flush_count); > > Extra cast? Yeah. Paolo > That said, it's correct as-is so, > > Reviewed-by: Richard Henderson > > > r~ >