tcg-cpus: split into 3 tcg variants
cover tcg-cpus: split into 3 tcg variants
The purpose of this series is to split the tcg-cpus into 3 variants:
tcg_cpus_mttcg (multithreaded tcg vcpus) tcg_cpus_rr (single threaded round robin vcpus) tcg_cpus_icount (same as RR, but using icount)
Alex, I read the comment in tcg_start_vcpu_thread saying:
/*
* Initialize TCG regions--once. Now is a good time, because:
* (1) TCG's init context, prologue and target globals have been set up.
* (2) qemu_tcg_mttcg_enabled() works now (TCG init code runs before the
* -accel flag is processed, so the check doesn't work then).
*/
Is this actually current?
I tried to refactor this (see patch 2), and it seems to work to do the init of regions in tcg_init, and it seems that mttcg_enabled is known already at that point..
Ciao,
Claudio
Claudio Fontana (2):
accel/tcg: split CpusAccel into three TCG variants accel/tcg: split tcg_start_vcpu_thread
accel/tcg/meson.build | 9 +- accel/tcg/tcg-all.c | 13 +- accel/tcg/tcg-cpus-icount.c | 145 +++++++++++ accel/tcg/tcg-cpus-icount.h | 20 ++ accel/tcg/tcg-cpus-mttcg.c | 142 ++++++++++ accel/tcg/tcg-cpus-mttcg.h | 25 ++ accel/tcg/tcg-cpus-rr.c | 305 ++++++++++++++++++++++ accel/tcg/tcg-cpus-rr.h | 26 ++ accel/tcg/tcg-cpus.c | 500 +----------------------------------- accel/tcg/tcg-cpus.h | 9 +- softmmu/icount.c | 2 +- 11 files changed, 697 insertions(+), 499 deletions(-) create mode 100644 accel/tcg/tcg-cpus-icount.c create mode 100644 accel/tcg/tcg-cpus-icount.h create mode 100644 accel/tcg/tcg-cpus-mttcg.c create mode 100644 accel/tcg/tcg-cpus-mttcg.h create mode 100644 accel/tcg/tcg-cpus-rr.c create mode 100644 accel/tcg/tcg-cpus-rr.h
Signature · 1 line
2.26.2
RFC 1/2 accel/tcg: split CpusAccel into three TCG variants
split up the CpusAccel tcg_cpus into three TCG variants:
tcg_cpus_rr (single threaded, round robin cpus) tcg_cpus_icount (same as rr, but with instruction counting enabled) tcg_cpus_mttcg (multi-threaded cpus)
--- accel/tcg/meson.build | 9 +- accel/tcg/tcg-all.c | 8 +- accel/tcg/tcg-cpus-icount.c | 145 +++++++++++ accel/tcg/tcg-cpus-icount.h | 20 ++ accel/tcg/tcg-cpus-mttcg.c | 118 +++++++++ accel/tcg/tcg-cpus-mttcg.h | 25 ++ accel/tcg/tcg-cpus-rr.c | 270 ++++++++++++++++++++ accel/tcg/tcg-cpus-rr.h | 23 ++ accel/tcg/tcg-cpus.c | 478 ++---------------------------------- accel/tcg/tcg-cpus.h | 9 +- softmmu/icount.c | 2 +- 11 files changed, 647 insertions(+), 460 deletions(-) create mode 100644 accel/tcg/tcg-cpus-icount.c create mode 100644 accel/tcg/tcg-cpus-icount.h create mode 100644 accel/tcg/tcg-cpus-mttcg.c create mode 100644 accel/tcg/tcg-cpus-mttcg.h create mode 100644 accel/tcg/tcg-cpus-rr.c create mode 100644 accel/tcg/tcg-cpus-rr.h
accel/tcg/meson.build +8 -1
@@ -12,4 +12,11 @@ tcg_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('user-exec-stub.c')) tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin-gen.c'), libdl]) specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) -specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files('tcg-all.c', 'cputlb.c', 'tcg-cpus.c')) +specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files( + 'tcg-all.c', + 'cputlb.c', + 'tcg-cpus.c', + 'tcg-cpus-mttcg.c', + 'tcg-cpus-icount.c', + 'tcg-cpus-rr.c' +))
accel/tcg/tcg-all.c +7 -1
@@ -104,8 +104,14 @@ static int tcg_init(MachineState *ms)tcg_exec_init (s->tb_size *1024 *1024 ); mttcg_enabled = s->mttcg_enabled; -cpus_register_accel (&tcg_cpus); +if (mttcg_enabled) { +cpus_register_accel (&tcg_cpus_mttcg); + }else if (icount_enabled ()) { +cpus_register_accel (&tcg_cpus_icount); + }else { +cpus_register_accel (&tcg_cpus_rr); + }return 0 ; }
accel/tcg/tcg-cpus-icount.c new file +145 -0
145 lines not on this page · raw message
accel/tcg/tcg-cpus-icount.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Accelerator CPUS Interface +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_ICOUNT_H +#define TCG_CPUS_ICOUNT_H + +extern const CpusAccel tcg_cpus_icount; + +int64_t tcg_get_icount_limit (void ); +void handle_icount_deadline (void ); +void prepare_icount_for_run (CPUState *cpu); +void process_icount_data (CPUState *cpu); + +#endif /* TCG_CPUS_ICOUNT_H */
accel/tcg/tcg-cpus-mttcg.c new file +118 -0
118 lines not on this page · raw message
accel/tcg/tcg-cpus-mttcg.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Accelerator CPUS Interface +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_MTTCG_H +#define TCG_CPUS_MTTCG_H + +extern const CpusAccel tcg_cpus_mttcg; + +/* +* Multi-threaded TCG +* +* In the multi-threaded case each vCPU has its own thread. The TLS +* variable current_cpu can be used deep in the code to find the +* current CPUState for a given thread. +*/ + +void *tcg_cpu_thread_fn (void *arg); + +#endif /* TCG_CPUS_MTTCG_H */
accel/tcg/tcg-cpus-rr.c new file +270 -0
270 lines not on this page · raw message
accel/tcg/tcg-cpus-rr.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Accelerator CPUS Interface +* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_RR_H +#define TCG_CPUS_RR_H + +extern const CpusAccel tcg_cpus_rr; + +#define TCG_KICK_PERIOD (NANOSECONDS_PER_SECOND / 10) + +/* Kick all RR vCPUs. */ +void qemu_cpu_kick_rr_cpus (CPUState *unused); + +/* Single-threaded TCG */ +void *tcg_rr_cpu_thread_fn (void *arg); + +#endif /* TCG_CPUS_RR_H */
accel/tcg/tcg-cpus.c +22 -456
506 lines not on this page · raw message
accel/tcg/tcg-cpus.h +8 -1
@@ -12,6 +12,13 @@#include "sysemu/cpus.h" -extern const CpusAccel tcg_cpus; +#include "tcg-cpus-rr.h" +#include "tcg-cpus-icount.h" +#include "tcg-cpus-mttcg.h" + +void tcg_start_vcpu_thread (CPUState *cpu); +void qemu_tcg_destroy_vcpu (CPUState *cpu); +int tcg_cpu_exec (CPUState *cpu); +void tcg_handle_interrupt (CPUState *cpu,int mask);#endif /* TCG_CPUS_H */
softmmu/icount.c +1 -1
@@ -396,7 +396,7 @@ void icount_start_warp_timer(void)void icount_account_warp_timer (void ) { -if (!icount_enabled () || !icount_sleep) { +if (!icount_sleep) {return ; }
Signature · 1 line
2.26.2
Re: [RFC v1 1/2] accel/tcg: split CpusAccel into three TCG variants
Quoted 26 lines · Claudio Fontana
split up the CpusAccel
tcg_cpusinto three TCG variants:
tcg_cpus_rr(single threaded, round robin cpus)tcg_cpus_icount(same as rr, but with instruction counting enabled)tcg_cpus_mttcg(multi-threaded cpus)Signed-off-by Claudio Fontana <[email protected]>--- accel/tcg/meson.build | 9 +- accel/tcg/tcg-all.c | 8 +- accel/tcg/tcg-cpus-icount.c | 145 +++++++++++ accel/tcg/tcg-cpus-icount.h | 20 ++ accel/tcg/tcg-cpus-mttcg.c | 118 +++++++++ accel/tcg/tcg-cpus-mttcg.h | 25 ++ accel/tcg/tcg-cpus-rr.c | 270 ++++++++++++++++++++ accel/tcg/tcg-cpus-rr.h | 23 ++ accel/tcg/tcg-cpus.c | 478 ++---------------------------------- accel/tcg/tcg-cpus.h | 9 +- softmmu/icount.c | 2 +- 11 files changed, 647 insertions(+), 460 deletions(-)create mode 100644
accel/tcg/tcg-cpus-icount.c
create mode 100644accel/tcg/tcg-cpus-icount.h
create mode 100644accel/tcg/tcg-cpus-mttcg.c
create mode 100644accel/tcg/tcg-cpus-mttcg.h
create mode 100644accel/tcg/tcg-cpus-rr.c
create mode 100644accel/tcg/tcg-cpus-rr.h
...
accel/tcg/tcg-cpus-icount.c line 2
Quoted 8 lines
accel/tcg/tcg-cpus-icount.c new file +2
-0@@ -0,0 +1,145 @@ +/* +* QEMU System Emulator
"QEMU single threaded vCPUs implementation using instruction counting"?
Quoted 22 lines
accel/tcg/tcg-cpus-icount.c new file +22
-0+* +* Copyright (c) 2003-2008 Fabrice Bellard +* Copyright (c) 2014 Red Hat Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/
...
accel/tcg/tcg-cpus-icount.h line 2
Quoted 8 lines
accel/tcg/tcg-cpus-icount.h new file +2
-0@@ -0,0 +1,20 @@ +/* +* Accelerator CPUS Interface
Ditto.
Quoted 24 lines
accel/tcg/tcg-cpus-icount.h new file +18
-0+* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_ICOUNT_H +#define TCG_CPUS_ICOUNT_H + +extern const CpusAccel tcg_cpus_icount; + +int64_t tcg_get_icount_limit (void ); +void handle_icount_deadline (void ); +void prepare_icount_for_run (CPUState *cpu); +void process_icount_data (CPUState *cpu); + +#endif /* TCG_CPUS_ICOUNT_H */ accel/tcg/tcg-cpus-mttcg.c new file +0
-0
accel/tcg/tcg-cpus-mttcg.c line 2
Quoted 2 lines
accel/tcg/tcg-cpus-mttcg.c new file +2
-0@@ -0,0 +1,118 @@ +/* +* QEMU System Emulator
"QEMU multi-threaded vCPUs implementation"?
Quoted 22 lines
accel/tcg/tcg-cpus-mttcg.c new file +22
-0+* +* Copyright (c) 2003-2008 Fabrice Bellard +* Copyright (c) 2014 Red Hat Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/
...
accel/tcg/tcg-cpus-mttcg.h line 2
Quoted 8 lines
accel/tcg/tcg-cpus-mttcg.h new file +2
-0@@ -0,0 +1,25 @@ +/* +* Accelerator CPUS Interface
Ditto.
Quoted 29 lines
accel/tcg/tcg-cpus-mttcg.h new file +23
-0+* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_MTTCG_H +#define TCG_CPUS_MTTCG_H + +extern const CpusAccel tcg_cpus_mttcg; + +/* +* Multi-threaded TCG +* +* In the multi-threaded case each vCPU has its own thread. The TLS +* variable current_cpu can be used deep in the code to find the +* current CPUState for a given thread. +*/ + +void *tcg_cpu_thread_fn (void *arg); + +#endif /* TCG_CPUS_MTTCG_H */ accel/tcg/tcg-cpus-rr.c new file +0
-0
accel/tcg/tcg-cpus-rr.c line 2
Quoted 2 lines
accel/tcg/tcg-cpus-rr.c new file +2
-0@@ -0,0 +1,270 @@ +/* +* QEMU System Emulator
"QEMU single threaded (using round robin) vCPUs implementation"?
Quoted 22 lines
accel/tcg/tcg-cpus-rr.c new file +22
-0+* +* Copyright (c) 2003-2008 Fabrice Bellard +* Copyright (c) 2014 Red Hat Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/
...
accel/tcg/tcg-cpus-rr.h line 2
Quoted 8 lines
accel/tcg/tcg-cpus-rr.h new file +2
-0@@ -0,0 +1,23 @@ +/* +* Accelerator CPUS Interface
Ditto.
Quoted 21 lines
accel/tcg/tcg-cpus-rr.h new file +21
-0+* +* Copyright 2020 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef TCG_CPUS_RR_H +#define TCG_CPUS_RR_H + +extern const CpusAccel tcg_cpus_rr; + +#define TCG_KICK_PERIOD (NANOSECONDS_PER_SECOND / 10) + +/* Kick all RR vCPUs. */ +void qemu_cpu_kick_rr_cpus (CPUState *unused); + +/* Single-threaded TCG */ +void *tcg_rr_cpu_thread_fn (void *arg); + +#endif /* TCG_CPUS_RR_H */
...
accel/tcg/tcg-cpus.h line 17
Quoted 12 lines
accel/tcg/tcg-cpus.h +3
-1@@ -12,6 +12,13 @@#include "sysemu/cpus.h" -extern const CpusAccel tcg_cpus; +#include "tcg-cpus-rr.h" +#include "tcg-cpus-icount.h" +#include "tcg-cpus-mttcg.h"
Why do we need to include the implementation declarations?
Quoted 21 lines
accel/tcg/tcg-cpus.h +5
-0+ +void tcg_start_vcpu_thread (CPUState *cpu); +void qemu_tcg_destroy_vcpu (CPUState *cpu); +int tcg_cpu_exec (CPUState *cpu); +void tcg_handle_interrupt (CPUState *cpu,int mask);#endif /* TCG_CPUS_H */ softmmu/icount.c +1
-1@@ -396,7 +396,7 @@ void icount_start_warp_timer(void)void icount_account_warp_timer (void ) { -if (!icount_enabled () || !icount_sleep) { +if (!icount_sleep) {return ; }
RFC 2/2 accel/tcg: split tcg_start_vcpu_thread
In reply to Claudio Fontanaafter the initial split into 3 tcg variants, we proceed to also split tcg_start_vcpu_thread.
We actually split it in 2 this time, since the icount variant just uses the round robin function.
--- accel/tcg/tcg-all.c | 5 ++++ accel/tcg/tcg-cpus-icount.c | 2 +- accel/tcg/tcg-cpus-mttcg.c | 26 ++++++++++++++++- accel/tcg/tcg-cpus-rr.c | 37 +++++++++++++++++++++++- accel/tcg/tcg-cpus-rr.h | 3 ++ accel/tcg/tcg-cpus.c | 56 ------------------------------------- 6 files changed, 70 insertions(+), 59 deletions(-)
accel/tcg/tcg-all.c +5 -0
@@ -105,6 +105,11 @@ static int tcg_init(MachineState *ms)tcg_exec_init (s->tb_size *1024 *1024 ); mttcg_enabled = s->mttcg_enabled; +/* +* Initialize TCG regions +*/ +tcg_region_init (); +if (mttcg_enabled) {cpus_register_accel (&tcg_cpus_mttcg); }else if (icount_enabled ()) {
accel/tcg/tcg-cpus-icount.c +1 -1
@@ -136,7 +136,7 @@ static void icount_handle_interrupt(CPUState *cpu, int mask) }const CpusAccel tcg_cpus_icount = { - .create_vcpu_thread = tcg_start_vcpu_thread, + .create_vcpu_thread = rr_start_vcpu_thread, .kick_vcpu_thread = qemu_cpu_kick_rr_cpus, .handle_interrupt = icount_handle_interrupt,
accel/tcg/tcg-cpus-mttcg.c +25 -1
@@ -110,8 +110,32 @@ static void mttcg_kick_vcpu_thread(CPUState *cpu)cpu_exit (cpu); } +static void mttcg_start_vcpu_thread (CPUState *cpu) +{ +char thread_name[VCPU_THREAD_NAME_SIZE ]; + +g_assert (tcg_enabled ()); + + parallel_cpus = (current_machine->smp.max_cpus >1 ); + + cpu->thread =g_malloc0 (sizeof (QemuThread)); + cpu->halt_cond =g_malloc0 (sizeof (QemuCond)); +qemu_cond_init (cpu->halt_cond); + +/* create a thread per vCPU with TCG (MTTCG) */ +snprintf (thread_name,VCPU_THREAD_NAME_SIZE ,"CPU %d/TCG" , + cpu->cpu_index); + +qemu_thread_create (cpu->thread, thread_name, tcg_cpu_thread_fn, + cpu,QEMU_THREAD_JOINABLE ); + +#ifdef _WIN32 + cpu->hThread =qemu_thread_get_handle (cpu->thread); +#endif +} +const CpusAccel tcg_cpus_mttcg = { - .create_vcpu_thread = tcg_start_vcpu_thread, + .create_vcpu_thread = mttcg_start_vcpu_thread, .kick_vcpu_thread = mttcg_kick_vcpu_thread, .handle_interrupt = tcg_handle_interrupt,
accel/tcg/tcg-cpus-rr.c +36 -1
@@ -262,8 +262,43 @@ void *tcg_rr_cpu_thread_fn(void *arg)return NULL ; } +void rr_start_vcpu_thread (CPUState *cpu) +{ +char thread_name[VCPU_THREAD_NAME_SIZE ]; +static QemuCond *single_tcg_halt_cond; +static QemuThread *single_tcg_cpu_thread; + +g_assert (tcg_enabled ()); + parallel_cpus = false; + +if (!single_tcg_cpu_thread) { + cpu->thread =g_malloc0 (sizeof (QemuThread)); + cpu->halt_cond =g_malloc0 (sizeof (QemuCond)); +qemu_cond_init (cpu->halt_cond); + +/* share a single thread for all cpus with TCG */ +snprintf (thread_name,VCPU_THREAD_NAME_SIZE ,"ALL CPUs/TCG" ); +qemu_thread_create (cpu->thread, thread_name, + tcg_rr_cpu_thread_fn, + cpu,QEMU_THREAD_JOINABLE ); + + single_tcg_halt_cond = cpu->halt_cond; + single_tcg_cpu_thread = cpu->thread; +#ifdef _WIN32 + cpu->hThread =qemu_thread_get_handle (cpu->thread); +#endif + }else { +/* we share the thread */ + cpu->thread = single_tcg_cpu_thread; + cpu->halt_cond = single_tcg_halt_cond; + cpu->thread_id = first_cpu->thread_id; + cpu->can_do_io =1 ; + cpu->created = true; + } +} +const CpusAccel tcg_cpus_rr = { - .create_vcpu_thread = tcg_start_vcpu_thread, + .create_vcpu_thread = rr_start_vcpu_thread, .kick_vcpu_thread = qemu_cpu_kick_rr_cpus, .handle_interrupt = tcg_handle_interrupt,
accel/tcg/tcg-cpus-rr.h +3 -0
@@ -17,6 +17,9 @@ extern const CpusAccel tcg_cpus_rr;/* Kick all RR vCPUs. */ void qemu_cpu_kick_rr_cpus (CPUState *unused); +/* start the round robin vcpu thread */ +void rr_start_vcpu_thread (CPUState *cpu); +/* Single-threaded TCG */ void *tcg_rr_cpu_thread_fn (void *arg);
accel/tcg/tcg-cpus.c +0 -56
62 lines not on this page · raw message
Signature · 1 line
2.26.2
Quoted 6 lines · Claudio Fontana
The purpose of this series is to split the tcg-cpus into 3 variants:
tcg_cpus_mttcg (multithreaded tcg vcpus) tcg_cpus_rr (single threaded round robin vcpus) tcg_cpus_icount (same as RR, but using icount)
Good idea!
Quoted 6 lines · Claudio Fontana
The purpose of this series is to split the tcg-cpus into 3 variants:
tcg_cpus_mttcg (multithreaded tcg vcpus) tcg_cpus_rr (single threaded round robin vcpus) tcg_cpus_icount (same as RR, but using icount)
I've no objection to the cosmetic clean-up but I assume the 3 modes will still be available in TCG enabled binaries.
Quoted 11 lines
Alex, I read the comment in
tcg_start_vcpu_threadsaying:/*
* Initialize TCG regions--once. Now is a good time, because:
* (1) TCG's init context, prologue and target globals have been set up.
* (2)qemu_tcg_mttcg_enabled()works now (TCG init code runs before the
* -accel flag is processed, so the check doesn't work then).
*/Is this actually current?
Hmm probably not. Now everything is tied to the order of class initialisation and realisation. AIUI all properties set by the command line should be complete by the time an object realizes and parent classes should be processed before their children.
Quoted 31 lines
I tried to refactor this (see patch 2), and it seems to work to do the init of regions in
tcg_init, and it seems thatmttcg_enabledis known already at that point..Ciao,
Claudio
Claudio Fontana (2):
accel/tcg: split CpusAccel into three TCG variants accel/tcg: splittcg_start_vcpu_threadaccel/tcg/meson.build | 9 +- accel/tcg/tcg-all.c | 13 +- accel/tcg/tcg-cpus-icount.c | 145 +++++++++++ accel/tcg/tcg-cpus-icount.h | 20 ++ accel/tcg/tcg-cpus-mttcg.c | 142 ++++++++++ accel/tcg/tcg-cpus-mttcg.h | 25 ++ accel/tcg/tcg-cpus-rr.c | 305 ++++++++++++++++++++++ accel/tcg/tcg-cpus-rr.h | 26 ++ accel/tcg/tcg-cpus.c | 500 +----------------------------------- accel/tcg/tcg-cpus.h | 9 +- softmmu/icount.c | 2 +- 11 files changed, 697 insertions(+), 499 deletions(-) create mode 100644 accel/tcg/tcg-cpus-icount.c create mode 100644 accel/tcg/tcg-cpus-icount.h create mode 100644 accel/tcg/tcg-cpus-mttcg.c create mode 100644 accel/tcg/tcg-cpus-mttcg.h create mode 100644 accel/tcg/tcg-cpus-rr.c create mode 100644 accel/tcg/tcg-cpus-rr.h
Signature · 1 line
Alex Bennée
Quoted 6 lines · Alex Bennée
Quoted 3 lines · Claudio Fontana
The purpose of this series is to split the tcg-cpus into 3 variants:
Quoted 6 lines
Quoted 3 lines
tcg_cpus_mttcg (multithreaded tcg vcpus) tcg_cpus_rr (single threaded round robin vcpus) tcg_cpus_icount (same as RR, but using icount)I've no objection to the cosmetic clean-up but I assume the 3 modes will still be available in TCG enabled binaries.
Hi Alex,
yes, all three will be available in the code when enabling TCG.
Quoted 11 lines
Quoted 11 lines
Alex, I read the comment in
tcg_start_vcpu_threadsaying:/*
* Initialize TCG regions--once. Now is a good time, because:
* (1) TCG's init context, prologue and target globals have been set up.
* (2)qemu_tcg_mttcg_enabled()works now (TCG init code runs before the
* -accel flag is processed, so the check doesn't work then).
*/
Quoted 6 lines
Quoted 1 line
Is this actually current?
Hmm probably not. Now everything is tied to the order of class initialisation and realisation. AIUI all properties set by the command line should be complete by the time an object realizes and parent classes should be processed before their children.
This is great news, as it allows more refactoring as showed on patch 2,
thanks a lot!
Ciao,
Claudio
Quoted 34 lines
Quoted 32 lines
I tried to refactor this (see patch 2), and it seems to work to do the init of regions in
tcg_init, and it seems thatmttcg_enabledis known already at that point..Ciao,
Claudio
Claudio Fontana (2):
accel/tcg: split CpusAccel into three TCG variants accel/tcg: splittcg_start_vcpu_threadaccel/tcg/meson.build | 9 +- accel/tcg/tcg-all.c | 13 +- accel/tcg/tcg-cpus-icount.c | 145 +++++++++++ accel/tcg/tcg-cpus-icount.h | 20 ++ accel/tcg/tcg-cpus-mttcg.c | 142 ++++++++++ accel/tcg/tcg-cpus-mttcg.h | 25 ++ accel/tcg/tcg-cpus-rr.c | 305 ++++++++++++++++++++++ accel/tcg/tcg-cpus-rr.h | 26 ++ accel/tcg/tcg-cpus.c | 500 +----------------------------------- accel/tcg/tcg-cpus.h | 9 +- softmmu/icount.c | 2 +- 11 files changed, 697 insertions(+), 499 deletions(-) create mode 100644 accel/tcg/tcg-cpus-icount.c create mode 100644 accel/tcg/tcg-cpus-icount.h create mode 100644 accel/tcg/tcg-cpus-mttcg.c create mode 100644 accel/tcg/tcg-cpus-mttcg.h create mode 100644 accel/tcg/tcg-cpus-rr.c create mode 100644 accel/tcg/tcg-cpus-rr.h
Quoted 6 lines · Alex Bennée
Quoted 3 lines · Claudio Fontana
The purpose of this series is to split the tcg-cpus into 3 variants:
Quoted 6 lines
Quoted 3 lines
tcg_cpus_mttcg (multithreaded tcg vcpus) tcg_cpus_rr (single threaded round robin vcpus) tcg_cpus_icount (same as RR, but using icount)I've no objection to the cosmetic clean-up but I assume the 3 modes will still be available in TCG enabled binaries.
Yes, I think so too, no point in disabling some.
However it seems to me it is now easier to review
for a newcomer.
Code easily understandable/reviewable is easier to maintain and less bug prone :)
Phil.