From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUM2h-0006zF-SI for qemu-devel@nongnu.org; Tue, 25 Aug 2015 17:46:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUM2d-0004Ch-Ps for qemu-devel@nongnu.org; Tue, 25 Aug 2015 17:46:07 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:39904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUM2d-0004CZ-Hz for qemu-devel@nongnu.org; Tue, 25 Aug 2015 17:46:03 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 0A207213E8 for ; Tue, 25 Aug 2015 17:46:03 -0400 (EDT) Date: Tue, 25 Aug 2015 17:46:26 -0400 From: "Emilio G. Cota" Message-ID: <20150825214626.GD29063@flamenco> References: <1440375847-17603-1-git-send-email-cota@braap.org> <1440375847-17603-27-git-send-email-cota@braap.org> <55DA7012.40801@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55DA7012.40801@redhat.com> Subject: Re: [Qemu-devel] [RFC 26/38] cpu: protect tb_jmp_cache with seqlock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: mttcg@greensocs.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, guillaume.delbergue@greensocs.com, alex.bennee@linaro.org, Frederic Konrad On Sun, Aug 23, 2015 at 18:14:58 -0700, Paolo Bonzini wrote: > On 23/08/2015 17:23, Emilio G. Cota wrote: > > This paves the way for a lockless tb_find_fast. > > > > Signed-off-by: Emilio G. Cota > > --- (snip) > > @@ -1707,12 +1735,14 @@ void tb_flush_jmp_cache(CPUState *cpu, target_ulong addr) > > /* Discard jump cache entries for any tb which might potentially > > overlap the flushed page. */ > > i = tb_jmp_cache_hash_page(addr - TARGET_PAGE_SIZE); > > + seqlock_write_lock(&cpu->tb_jmp_cache_sequence); > > memset(&cpu->tb_jmp_cache[i], 0, > > TB_JMP_PAGE_SIZE * sizeof(TranslationBlock *)); > > > > i = tb_jmp_cache_hash_page(addr); > > memset(&cpu->tb_jmp_cache[i], 0, > > TB_JMP_PAGE_SIZE * sizeof(TranslationBlock *)); > > + seqlock_write_unlock(&cpu->tb_jmp_cache_sequence); > > } > > > > void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) > > > > I'm not sure how the last three patches compare with the existing "tcg: > move tb_find_fast outside the tb_lock critical section"? The seqlock for tb_jmp_cache is necessary the moment that the array can be wiped out with a memset(), as shown above. That function (tb_flush_jmp_cache) is called by tlb_flush_page, which has many callers. One could argue that we could enforce calling tlb_flush_page to be a) always done by the owner thread or b) done while all others CPUs are paused. I argue that worrying about that is not worth it; let's protect the array with a seqlock, which on TSO is essentially free, and worry about more important things. Wrt the next two patches: Patch 27 is an improvement in that each TB has its own valid flag, which makes sense because this should only affect TB's that are trying to chain to/from it, not all TBs. Patch 28 uses the RCU QLIST which to me seems cleaner and less error-prone than open-coding an RCU LIST. Thanks, Emilio