qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Thread local TCGContext.
@ 2015-01-28 15:04 Frederic Konrad
  2015-01-28 15:17 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Frederic Konrad @ 2015-01-28 15:04 UTC (permalink / raw)
  To: qemu-devel, mttcg; +Cc: Paolo Bonzini, Mark Burton, Peter Maydell

Hi,

I wondering how we can have one TCGContext per thread cleanly.

We should be able to do this:

diff --git a/tcg/tcg.h b/tcg/tcg.h
index baf053a..8d488dc 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -533,7 +533,7 @@ struct TCGContext {
      struct TCGBackendData *be;
  };

-extern TCGContext tcg_ctx;
+extern __thread TCGContext tcg_ctx;
  extern TBContext tb_ctx;

  /* pool based memory allocation */
diff --git a/translate-all.c b/translate-all.c
index a986d61..69c6b83 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -125,11 +125,30 @@ uintptr_t qemu_host_page_mask;
  static void *l1_map[V_L1_SIZE];

  /* code generation context */
-TCGContext tcg_ctx;
+__thread TCGContext tcg_ctx;

But the big problem is the initialisation, it's done only onetime in the 
iothread with
the accelerator..

(gdb) bt
#0  tcg_context_init (s=0x7ffff7fb7a50) at qemu/tcg/tcg.c:333
#1  0x000055555560d90e in cpu_gen_init () at qemu/translate-all.c:158
#2  tcg_exec_init (tb_size=0) at qemu/translate-all.c:719
#3  0x000055555571a5c5 in tcg_init (ms=<optimized out>) at accel.c:42
#4  0x000055555571a6fb in accel_init_machine (ms=0x55555626b670, 
acc=0x555556251f20) at accel.c:70
#5  configure_accelerator (ms=0x55555626b670) at accel.c:109
#6  0x00005555555fee66 in main (argc=<optimized out>, argv=<optimized 
out>, envp=<optimized out>) at vl.c:4030

Any idea how to deal with this cleanly?

Thanks,
Fred

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] Thread local TCGContext.
  2015-01-28 15:04 [Qemu-devel] Thread local TCGContext Frederic Konrad
@ 2015-01-28 15:17 ` Paolo Bonzini
  2015-01-28 15:27   ` Frederic Konrad
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2015-01-28 15:17 UTC (permalink / raw)
  To: Frederic Konrad, qemu-devel, mttcg; +Cc: Peter Maydell, Mark Burton



On 28/01/2015 16:04, Frederic Konrad wrote:
> 
> 
>  /* code generation context */
> -TCGContext tcg_ctx;
> +__thread TCGContext tcg_ctx;
> 
> But the big problem is the initialisation, it's done only onetime in the
> iothread with
> the accelerator..

You need to move it to qemu_tcg_cpu_thread_fn.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] Thread local TCGContext.
  2015-01-28 15:17 ` Paolo Bonzini
@ 2015-01-28 15:27   ` Frederic Konrad
  2015-01-28 15:30     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Frederic Konrad @ 2015-01-28 15:27 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel, mttcg; +Cc: Peter Maydell, Mark Burton

On 28/01/2015 16:17, Paolo Bonzini wrote:
>
> On 28/01/2015 16:04, Frederic Konrad wrote:
>>
>>   /* code generation context */
>> -TCGContext tcg_ctx;
>> +__thread TCGContext tcg_ctx;
>>
>> But the big problem is the initialisation, it's done only onetime in the
>> iothread with
>> the accelerator..
> You need to move it to qemu_tcg_cpu_thread_fn.
>
> Paolo
>
Ok that makes sense.

I thought it won't be possible because it seems to be initialized by a 
class but
probably qemu_tcg_cpu_thread_fn exists only when the accelerator is tcg.

Thanks,
Fred

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] Thread local TCGContext.
  2015-01-28 15:27   ` Frederic Konrad
@ 2015-01-28 15:30     ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2015-01-28 15:30 UTC (permalink / raw)
  To: Frederic Konrad, qemu-devel, mttcg; +Cc: Peter Maydell, Mark Burton



On 28/01/2015 16:27, Frederic Konrad wrote:
>>
> Ok that makes sense.
> 
> I thought it won't be possible because it seems to be initialized by a class but
> probably qemu_tcg_cpu_thread_fn exists only when the accelerator is tcg.

Yes, it needs a bit of refactoring.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-28 15:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-28 15:04 [Qemu-devel] Thread local TCGContext Frederic Konrad
2015-01-28 15:17 ` Paolo Bonzini
2015-01-28 15:27   ` Frederic Konrad
2015-01-28 15:30     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).