From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmlSp-0001Md-0J for qemu-devel@nongnu.org; Wed, 21 Sep 2016 13:37:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmlSk-0007Ix-La for qemu-devel@nongnu.org; Wed, 21 Sep 2016 13:37:41 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:48110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmlSi-0007Fw-C2 for qemu-devel@nongnu.org; Wed, 21 Sep 2016 13:37:38 -0400 Date: Wed, 21 Sep 2016 13:37:26 -0400 From: "Emilio G. Cota" Message-ID: <20160921173726.GA27412@flamenco> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <30d082bc-663c-d267-a844-e03c961da043@redhat.com> 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@gmail.com, alex.bennee@linaro.org, sergey.fedorov@linaro.org 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.) E.