Re: [Qemu-devel] [PATCH v2 3/3] tcg: allocate TB structs before the corresponding translated code

2017-06-06 Thread Emilio G. Cota
On Tue, Jun 06, 2017 at 10:02:17 -0700, Richard Henderson wrote: > On 06/06/2017 09:25 AM, Emilio G. Cota wrote: > >For this particular case we can get away without padding the structs if > >we're OK with having the end of a TB struct immediately followed > >by its translated code, instead of

Re: [Qemu-devel] [PATCH v2 3/3] tcg: allocate TB structs before the corresponding translated code

2017-06-06 Thread Emilio G. Cota
On Tue, Jun 06, 2017 at 01:36:50 -0400, Pranith Kumar wrote: > Reviewed-by: Pranith Kumar > > Thanks for doing this Emilio. Do you plan to continue working on rth's > suggestions in that email? If so, can we co-ordinate our work? My plan is to work on instrumentation.

Re: [Qemu-devel] [PATCH v2 3/3] tcg: allocate TB structs before the corresponding translated code

2017-06-06 Thread Richard Henderson
On 06/06/2017 09:25 AM, Emilio G. Cota wrote: For this particular case we can get away without padding the structs if we're OK with having the end of a TB struct immediately followed by its translated code, instead of having that code on the following cache line. Uh, no, if you can manually

Re: [Qemu-devel] [PATCH v2 3/3] tcg: allocate TB structs before the corresponding translated code

2017-06-06 Thread Emilio G. Cota
On Tue, Jun 06, 2017 at 01:24:11 -0700, Richard Henderson wrote: > On 06/05/2017 03:49 PM, Emilio G. Cota wrote: > >+TranslationBlock *tcg_tb_alloc(TCGContext *s) > >+{ > >+void *aligned; > >+ > >+aligned = (void *)ROUND_UP((uintptr_t)s->code_gen_ptr, > >QEMU_CACHELINE_SIZE); > >+if

Re: [Qemu-devel] [PATCH v2 3/3] tcg: allocate TB structs before the corresponding translated code

2017-06-06 Thread Richard Henderson
On 06/05/2017 03:49 PM, Emilio G. Cota wrote: +TranslationBlock *tcg_tb_alloc(TCGContext *s) +{ +void *aligned; + +aligned = (void *)ROUND_UP((uintptr_t)s->code_gen_ptr, QEMU_CACHELINE_SIZE); +if (unlikely(aligned + sizeof(TranslationBlock) > s->code_gen_highwater)) { +

Re: [Qemu-devel] [PATCH v2 3/3] tcg: allocate TB structs before the corresponding translated code

2017-06-05 Thread Pranith Kumar
On Mon, Jun 5, 2017 at 6:49 PM, Emilio G. Cota wrote: > Allocating an arbitrarily-sized array of tbs results in either > (a) a lot of memory wasted or (b) unnecessary flushes of the code > cache when we run out of TB structs in the array. > > An obvious solution would be to just

[Qemu-devel] [PATCH v2 3/3] tcg: allocate TB structs before the corresponding translated code

2017-06-05 Thread Emilio G. Cota
Allocating an arbitrarily-sized array of tbs results in either (a) a lot of memory wasted or (b) unnecessary flushes of the code cache when we run out of TB structs in the array. An obvious solution would be to just malloc a TB struct when needed, and keep the TB array as an array of pointers