Received: from eggs.gnu.org ([2001:4830:134:3::10]:50716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bntp8-00013a-C1 for qemu-devel@nongnu.org; Sat, 24 Sep 2016 16:45:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bntp6-0006ee-VQ for qemu-devel@nongnu.org; Sat, 24 Sep 2016 16:45:25 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36170) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bntp6-0006eM-P8 for qemu-devel@nongnu.org; Sat, 24 Sep 2016 16:45:24 -0400 Received: by mail-pf0-f194.google.com with SMTP id n24so6912287pfb.3 for ; Sat, 24 Sep 2016 13:45:24 -0700 (PDT) Sender: Richard Henderson References: <1474615909-17069-1-git-send-email-pbonzini@redhat.com> <1474615909-17069-16-git-send-email-pbonzini@redhat.com> <1562781019.2636285.1474717908026.JavaMail.zimbra@redhat.com> From: Richard Henderson Message-ID: <1237a144-5a83-8fe9-fddd-6891c3055005@twiddle.net> Date: Sat, 24 Sep 2016 13:44:22 -0700 MIME-Version: 1.0 In-Reply-To: <1562781019.2636285.1474717908026.JavaMail.zimbra@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed 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: Paolo Bonzini Cc: qemu-devel@nongnu.org, serge fdrv , cota@braap.org, alex bennee , sergey fedorov On 09/24/2016 04:51 AM, Paolo Bonzini wrote: > > > ----- 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. Don't we need the flush to be complete before the new count is seen? That's why I was suggesting the mb_set. r~