Received: from eggs.gnu.org ([2001:4830:134:3::10]:33322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmmAG-0004zc-Mp for qemu-devel@nongnu.org; Wed, 21 Sep 2016 14:22:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmmAA-0003wc-Lu for qemu-devel@nongnu.org; Wed, 21 Sep 2016 14:22:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmmAA-0003wP-FQ for qemu-devel@nongnu.org; Wed, 21 Sep 2016 14:22:30 -0400 References: <1474289459-15242-1-git-send-email-pbonzini@redhat.com> <1474289459-15242-16-git-send-email-pbonzini@redhat.com> <20160921160559.GA13385@flamenco> <30d082bc-663c-d267-a844-e03c961da043@redhat.com> <20160921173726.GA27412@flamenco> From: Paolo Bonzini Message-ID: <5d662563-6770-8ecb-8732-00e2f51ac484@redhat.com> Date: Wed, 21 Sep 2016 20:22:26 +0200 MIME-Version: 1.0 In-Reply-To: <20160921173726.GA27412@flamenco> Content-Type: text/plain; charset=windows-1252 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: "Emilio G. Cota" Cc: qemu-devel@nongnu.org, serge.fdrv@gmail.com, alex.bennee@linaro.org, sergey.fedorov@linaro.org On 21/09/2016 19:37, Emilio G. Cota wrote: > On Wed, Sep 21, 2016 at 18:19:26 +0200, Paolo Bonzini wrote: >> >> >> On 21/09/2016 18:05, Emilio G. Cota wrote: >>>>> + tb_lock(); >>>>> + >>>>> + /* If it's already been done on request of another CPU, >>>>> + * just retry. >>>>> + */ >>>>> + if (atomic_read(&tcg_ctx.tb_ctx.tb_flush_count) != tb_flush_req) { >>>>> + goto done; >>> tb_flush_count is always accessed with tb_lock held, right? If so, I don't >>> see a reason to access it with atomic_read/set. >> >> tb_flush accesses it outside tb_lock. Technically this one you're >> quoting need not use atomic_read, but others need to. > > Sorry for being thick, but when does tb_flush not own tb_lock? > (I'm assuming we're talking only user-mode, since full-system has > for now empty tb_lock/unlock helpers.) When called from gdbstub I think it doesn't (and for system-mode in other cases too, so better be ready anyway). Paolo