From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auOWG-0003vu-Lg for qemu-devel@nongnu.org; Sun, 24 Apr 2016 14:12:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1auOWB-0008PE-MV for qemu-devel@nongnu.org; Sun, 24 Apr 2016 14:12:32 -0400 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]:36351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auOWB-0008Ol-Gb for qemu-devel@nongnu.org; Sun, 24 Apr 2016 14:12:27 -0400 Received: by mail-pa0-x22a.google.com with SMTP id bt5so2879363pac.3 for ; Sun, 24 Apr 2016 11:12:27 -0700 (PDT) Sender: Richard Henderson References: <571A6C85.5020707@twiddle.net> <1461468462-31118-1-git-send-email-cota@braap.org> From: Richard Henderson Message-ID: <571D0C87.4020408@twiddle.net> Date: Sun, 24 Apr 2016 11:12:23 -0700 MIME-Version: 1.0 In-Reply-To: <1461468462-31118-1-git-send-email-cota@braap.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v2] translate-all: protect code_gen_buffer with RCU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" , QEMU Developers , MTTCG Devel Cc: =?UTF-8?Q?Alex_Benn=c3=a9e?= , Paolo Bonzini , Peter Crosthwaite , Sergey Fedorov On 04/23/2016 08:27 PM, Emilio G. Cota wrote: > [ Applies on top of bennee/mttcg/enable-mttcg-for-armv7-v1 after > reverting "translate-all: introduces tb_flush_safe". A trivial > conflict must be solved after applying. ] > > This is a first attempt at making tb_flush not have to stop all CPUs. > There are issues as pointed out below, but this could be a good start. > > Context: > https://lists.gnu.org/archive/html/qemu-devel/2016-03/msg04658.html > https://lists.gnu.org/archive/html/qemu-devel/2016-03/msg06942.html I will again say that I don't believe that wasting all of this memory is as good as using locks -- tb_flush doesn't happen *that* often. > +static void map_static_code_gen_buffer(void *buf, size_t size) > +{ > + map_exec(buf, size); > + map_none(buf + size, qemu_real_host_page_size); > + qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); > +} Nit: I know it's only startup, but there's no reason to make multiple map_exec or madvise calls. You can cover the entire buffer in one go, and then call map_none on the guard pages. > +#ifdef USE_STATIC_CODE_GEN_BUFFER ... > +#elif defined(_WIN32) ... > +#else /* UNIX, dynamically-allocated code buffer */ ... > +#endif /* USE_STATIC_CODE_GEN_BUFFER */ I'm not keen on your dynamic allocation implementations. Why not split the one dynamic buffer the same way as the static buffer? We are talking about >= 256MB here, after all. > + tcg_prologue_init(&tcg_ctx); We have some global variables in the tcg backends that are initialized by tcg_prologue_init. I don't think we should be calling it again without locks being involved. Of course, you don't have to call it again if you split one buffer. Then you also get to share the same rcu implementation. r~