Re: [Qemu-devel] [PATCH 1/2] tcg: Ensure safe tb_jmp_cache lookup out of 'tb_lock'

2016-07-05 Thread Paolo Bonzini
On 05/07/2016 00:31, Emilio G. Cota wrote: > My mistake. An atomic_read here isn't needed: as the commit message > points out, we only need atomic_read when tb_lock isn't held. In this > case tb_lock is held, so we only use atomic accesses for writing > to the array. It's harmless though. In C1

Re: [Qemu-devel] [PATCH 1/2] tcg: Ensure safe tb_jmp_cache lookup out of 'tb_lock'

2016-07-04 Thread Emilio G. Cota
On Sat, Jul 02, 2016 at 08:09:35 +0100, Alex Bennée wrote: > > Emilio G. Cota writes: > > > On Fri, Jul 01, 2016 at 17:16:09 +0100, Alex Bennée wrote: > >> From: Sergey Fedorov > > (snip) > >> @@ -333,7 +338,7 @@ static inline TranslationBlock *tb_find_fast(CPUState > >> *cpu, > >> is

Re: [Qemu-devel] [PATCH 1/2] tcg: Ensure safe tb_jmp_cache lookup out of 'tb_lock'

2016-07-04 Thread Emilio G. Cota
On Fri, Jul 01, 2016 at 17:32:01 -0700, Richard Henderson wrote: > On 07/01/2016 05:17 PM, Emilio G. Cota wrote: > >On Fri, Jul 01, 2016 at 17:16:09 +0100, Alex Bennée wrote: > >>From: Sergey Fedorov > >(snip) > >>@@ -333,7 +338,7 @@ static inline TranslationBlock *tb_find_fast(CPUState > >>*cpu,

Re: [Qemu-devel] [PATCH 1/2] tcg: Ensure safe tb_jmp_cache lookup out of 'tb_lock'

2016-07-02 Thread Alex Bennée
Emilio G. Cota writes: > On Fri, Jul 01, 2016 at 17:16:09 +0100, Alex Bennée wrote: >> From: Sergey Fedorov > (snip) >> @@ -333,7 +338,7 @@ static inline TranslationBlock *tb_find_fast(CPUState >> *cpu, >> is executed. */ >> cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); >>

Re: [Qemu-devel] [PATCH 1/2] tcg: Ensure safe tb_jmp_cache lookup out of 'tb_lock'

2016-07-01 Thread Richard Henderson
On 07/01/2016 05:17 PM, Emilio G. Cota wrote: On Fri, Jul 01, 2016 at 17:16:09 +0100, Alex Bennée wrote: From: Sergey Fedorov (snip) @@ -333,7 +338,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu, is executed. */ cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);

Re: [Qemu-devel] [PATCH 1/2] tcg: Ensure safe tb_jmp_cache lookup out of 'tb_lock'

2016-07-01 Thread Emilio G. Cota
On Fri, Jul 01, 2016 at 17:16:09 +0100, Alex Bennée wrote: > From: Sergey Fedorov (snip) > @@ -333,7 +338,7 @@ static inline TranslationBlock *tb_find_fast(CPUState > *cpu, > is executed. */ > cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); > tb_lock(); > -tb = cpu->tb_jmp

Re: [Qemu-devel] [PATCH 1/2] tcg: Ensure safe tb_jmp_cache lookup out of 'tb_lock'

2016-07-01 Thread Richard Henderson
On 07/01/2016 09:16 AM, Alex Bennée wrote: From: Sergey Fedorov First, ensure atomicity of CPU's 'tb_jmp_cache' access by: * using atomic_read() to look up a TB when not holding 'tb_lock'; * using atomic_write() to remove a TB from each CPU's local cache on TB invalidation. Second, add so

[Qemu-devel] [PATCH 1/2] tcg: Ensure safe tb_jmp_cache lookup out of 'tb_lock'

2016-07-01 Thread Alex Bennée
From: Sergey Fedorov First, ensure atomicity of CPU's 'tb_jmp_cache' access by: * using atomic_read() to look up a TB when not holding 'tb_lock'; * using atomic_write() to remove a TB from each CPU's local cache on TB invalidation. Second, add some memory barriers to ensure we don't put the