From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1av580-0007h7-Ox for qemu-devel@nongnu.org; Tue, 26 Apr 2016 11:42:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1av57u-0003Cr-Ou for qemu-devel@nongnu.org; Tue, 26 Apr 2016 11:42:20 -0400 Received: from mail-qk0-x22d.google.com ([2607:f8b0:400d:c09::22d]:33712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1av57u-0003Cl-Jl for qemu-devel@nongnu.org; Tue, 26 Apr 2016 11:42:14 -0400 Received: by mail-qk0-x22d.google.com with SMTP id n63so7045028qkf.0 for ; Tue, 26 Apr 2016 08:42:14 -0700 (PDT) Sender: Richard Henderson References: <20160425152528.GA16402@flamenco> <1461627983-32563-1-git-send-email-cota@braap.org> <8b49fdbb-fe67-ce03-c288-f31b4f34af8b@twiddle.net> <87r3dsev2s.fsf@linaro.org> From: Richard Henderson Message-ID: <571F8C52.4090807@twiddle.net> Date: Tue, 26 Apr 2016 08:42:10 -0700 MIME-Version: 1.0 In-Reply-To: <87r3dsev2s.fsf@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v3] translate-all: protect code_gen_buffer with RCU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Alex_Benn=c3=a9e?= Cc: "Emilio G. Cota" , QEMU Developers , MTTCG Devel , Paolo Bonzini , Peter Crosthwaite , Sergey Fedorov On 04/25/2016 11:35 PM, Alex Bennée wrote: > > Richard Henderson writes: > >> On 04/25/2016 04:46 PM, Emilio G. Cota wrote: >>> + /* >>> + * write the prologue into buf2. This is safe because we'll later call >>> + * tcg_prologue_init on buf1, from which we'll start execution. >>> + */ >>> + tcg_ctx.code_gen_buffer = code_gen_buf2; >>> + tcg_prologue_init(&tcg_ctx); >>> + >> >> Ah, no. Write only one prologue, not one per buffer. >> >> If they're sufficiently close (i.e. one allocation under the max size), >> then the same one can be used for both halves. >> >> The global variables that you didn't see in this revision are: >> >> aarch64/tcg-target.inc.c:static tcg_insn_unit *tb_ret_addr; >> arm/tcg-target.inc.c:static tcg_insn_unit *tb_ret_addr; >> i386/tcg-target.inc.c:static tcg_insn_unit *tb_ret_addr; >> ia64/tcg-target.inc.c:static tcg_insn_unit *tb_ret_addr; >> ia64/tcg-target.inc.c: tcg_insn_unit *thunks[8] = { }; >> mips/tcg-target.inc.c:static tcg_insn_unit *tb_ret_addr; >> ppc/tcg-target.inc.c:static tcg_insn_unit *tb_ret_addr; >> s390/tcg-target.inc.c:static tcg_insn_unit *tb_ret_addr; >> sparc/tcg-target.inc.c:static tcg_insn_unit *qemu_ld_trampoline[16]; >> sparc/tcg-target.inc.c:static tcg_insn_unit *qemu_st_trampoline[16]; > > Aside from the existing code structure is there any reason to have only > one prologue? Well, there's also the gdb jit unwind info. But aside from those, no. > It doesn't seem to be a large amount of code and in the > case of having smaller translation regions I would posit having a > "local" prologue/epilogue would make the jumps cheaper. Not really. The jumps are generally in range already, based on the restriction in max buffer size. Really only arm32 (and ppc32, post direct jump atomicity patchset) are the only ones that require a tiny (less than 64MB) buffer. Anything bigger than 64MB, I don't see any reason to create two independent buffers. The other consideration not yet mentioned is that you'd like to put on the entire buffer, in the case of x86_64 and some others, within 2GB of the main executable, so that helper calls can use a direct call insn. r~