accel/tcg: Remove qemu_tcg_mttcg_enabled()
cover accel/tcg: Remove qemu_tcg_mttcg_enabled()
Remove qemu_tcg_mttcg_enabled():
- check for CF_PARALLEL in riscv cpu_init(),
- directly check 'mttcg_enabled' in TCG code.
Philippe Mathieu-Daudé (2):
target/riscv: Check for CF_PARALLEL instead of qemu_tcg_mttcg_enabled accel/tcg: Replace qemu_tcg_mttcg_enabled() by mttcg_enabled
accel/tcg/tcg-accel-ops-mttcg.h | 8 ++++++++ include/hw/core/cpu.h | 9 --------- accel/tcg/tcg-accel-ops.c | 2 +- target/riscv/cpu.c | 2 +- tcg/region.c | 3 ++- 5 files changed, 12 insertions(+), 12 deletions(-)
Signature · 1 line
2.38.1
PATCH 1/2 target/riscv: Check for CF_PARALLEL instead of qemu_tcg_mttcg_enabled
A CPU knows whether MTTCG is enabled or not because it is reflected in its TCG flags via the CF_PARALLEL bit.
--- target/riscv/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu.c +1 -1
@@ -473,7 +473,7 @@ static void rv64_veyron_v1_cpu_init(Object *obj)static void rv128_base_cpu_init (Object *obj) { -if (qemu_tcg_mttcg_enabled ()) { +if (CPU (obj)->tcg_cflags &CF_PARALLEL ) {/* Missing 128-bit aligned atomics */ error_report ("128-bit RISC-V currently does not work with Multi " "Threaded TCG. Please use: -accel tcg,thread=single" );
Signature · 1 line
2.38.1
Re: [PATCH 1/2] target/riscv: Check for CF_PARALLEL instead of qemu_tcg_mttcg_enabled
Quoted 14 lines · Philippe Mathieu-Daudé
A CPU knows whether MTTCG is enabled or not because it is reflected in its TCG flags via the
CF_PARALLELbit.Suggested-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/riscv/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/cpu.c +0
-0
target/riscv/cpu.c static void rv64_veyron_v1_cpu_init(Object *obj) · line 476
Quoted 5 lines
target/riscv/cpu.c +1
-1@@ -473,7 +473,7 @@ static void rv64_veyron_v1_cpu_init(Object *obj)static void rv128_base_cpu_init (Object *obj) { -if (qemu_tcg_mttcg_enabled ()) { +if (CPU (obj)->tcg_cflags &CF_PARALLEL ) {
Hmm have you checked that tcg_cpu_init_cflags() has executed by this point?
target/riscv/cpu.c static void rv64_veyron_v1_cpu_init(Object *obj) · line 479
Quoted 3 lines
target/riscv/cpu.c +0
-0/* Missing 128-bit aligned atomics */ error_report ("128-bit RISC-V currently does not work with Multi " "Threaded TCG. Please use: -accel tcg,thread=single" );
Not that we can do anything about it but in linux-user we start with CF_PARALLEL unset and only set it at the point we spawn a new thread.
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH 1/2] target/riscv: Check for CF_PARALLEL instead of qemu_tcg_mttcg_enabled
Quoted 18 lines · Alex Bennée
Quoted 15 lines · Philippe Mathieu-Daudé
A CPU knows whether MTTCG is enabled or not because it is reflected in its TCG flags via the
CF_PARALLELbit.Suggested-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/riscv/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/cpu.c +0
-0@@ -473,7 +473,7 @@ static void rv64_veyron_v1_cpu_init(Object *obj)
Quoted 6 lines
target/riscv/cpu.c static void rv64_veyron_v1_cpu_init(Object *obj) · line 476
Quoted 4 lines
target/riscv/cpu.c +1
-1static void rv128_base_cpu_init (Object *obj) { -if (qemu_tcg_mttcg_enabled ()) { +if (CPU (obj)->tcg_cflags &CF_PARALLEL ) {Hmm have you checked that
tcg_cpu_init_cflags()has executed by this point?
$arch_cpu_realize
-> qemu_init_vcpu
-> mttcg_start_vcpu_thread
-> tcg_cpu_init_cflagsI'll document in the commit description.
Quoted 6 lines
target/riscv/cpu.c static void rv64_veyron_v1_cpu_init(Object *obj) · line 479
Quoted 3 lines
target/riscv/cpu.c +0
-0/* Missing 128-bit aligned atomics */ error_report ("128-bit RISC-V currently does not work with Multi " "Threaded TCG. Please use: -accel tcg,thread=single" );Not that we can do anything about it but in linux-user we start with
CF_PARALLELunset and only set it at the point we spawn a new thread.
Hmm I'll give it more thinking then.
Thanks,
Phil.
PATCH 2/2 accel/tcg: Replace qemu_tcg_mttcg_enabled() by mttcg_enabled
In reply to Philippe Mathieu-DaudéMove 'mttcg_enabled' declaration to "tcg-accel-ops-mttcg.h" which is a TCG-internal header; un-inline and remove the qemu_tcg_mttcg_enabled() definition.
--- accel/tcg/tcg-accel-ops-mttcg.h | 8 ++++++++ include/hw/core/cpu.h | 9 --------- accel/tcg/tcg-accel-ops.c | 2 +- tcg/region.c | 3 ++- 4 files changed, 11 insertions(+), 11 deletions(-)
accel/tcg/tcg-accel-ops-mttcg.h +8 -0
@@ -10,6 +10,14 @@#ifndef TCG_ACCEL_OPS_MTTCG_H #define TCG_ACCEL_OPS_MTTCG_H +/** +* qemu_tcg_mttcg_enabled: +* Check whether we are running MultiThread TCG or not. +* +* Returns: %true if we are in MTTCG mode %false otherwise. +*/ +extern bool mttcg_enabled; +/* kick MTTCG vCPU thread */ void mttcg_kick_vcpu_thread (CPUState *cpu);
include/hw/core/cpu.h +0 -9
@@ -456,15 +456,6 @@ extern CPUTailQ cpus;extern __threadCPUState *current_cpu; -/** -* qemu_tcg_mttcg_enabled: -* Check whether we are running MultiThread TCG or not. -* -* Returns: %true if we are in MTTCG mode %false otherwise. -*/ -extern bool mttcg_enabled; -#define qemu_tcg_mttcg_enabled () (mttcg_enabled) -/** * cpu_paging_enabled: * @cpu: The CPU whose state is to be inspected.
accel/tcg/tcg-accel-ops.c +1 -1
@@ -188,7 +188,7 @@ static inline void tcg_remove_all_breakpoints(CPUState *cpu)static void tcg_accel_ops_init (AccelOpsClass *ops) { -if (qemu_tcg_mttcg_enabled ()) { +if (mttcg_enabled) { ops->create_vcpu_thread = mttcg_start_vcpu_thread; ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; ops->handle_interrupt = tcg_handle_interrupt;
tcg/region.c +2 -1
@@ -32,6 +32,7 @@#include "qapi/error.h" #include "tcg/tcg.h" #include "exec/translation-block.h" +#include "accel/tcg/tcg-accel-ops-mttcg.h" #include "tcg-internal.h"
@@ -413,7 +414,7 @@ static size_t tcg_n_regions(size_t tb_size, unsigned max_cpus)* dividing the code_gen_buffer among the vCPUs. */ /* Use a single region if all we have is one vCPU thread */ -if (max_cpus ==1 || !qemu_tcg_mttcg_enabled ()) { +if (max_cpus ==1 || !mttcg_enabled) {return 1 ; }
Signature · 1 line
2.38.1
Re: [PATCH 2/2] accel/tcg: Replace qemu_tcg_mttcg_enabled() by mttcg_enabled
Quoted 17 lines · Philippe Mathieu-Daudé
Move '
mttcg_enabled' declaration to "tcg-accel-ops-mttcg.h" which is a TCG-internal header; un-inline and remove theqemu_tcg_mttcg_enabled()definition.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/tcg/tcg-accel-ops-mttcg.h | 8 ++++++++ include/hw/core/cpu.h | 9 --------- accel/tcg/tcg-accel-ops.c | 2 +- tcg/region.c | 3 ++- 4 files changed, 11 insertions(+), 11 deletions(-)accel/tcg/tcg-accel-ops-mttcg.h +0
-0
accel/tcg/tcg-accel-ops-mttcg.h line 18
Quoted 9 lines
accel/tcg/tcg-accel-ops-mttcg.h +6
-0@@ -10,6 +10,14 @@#ifndef TCG_ACCEL_OPS_MTTCG_H #define TCG_ACCEL_OPS_MTTCG_H +/** +* qemu_tcg_mttcg_enabled: +* Check whether we are running MultiThread TCG or not. +* +* Returns: %true if we are in MTTCG mode %false otherwise. +*/
Bah, outdated comment... To be removed.
Quoted 21 lines
accel/tcg/tcg-accel-ops-mttcg.h +2
-0+extern bool mttcg_enabled; +/* kick MTTCG vCPU thread */ void mttcg_kick_vcpu_thread (CPUState *cpu);include/hw/core/cpu.h +0
-8@@ -456,15 +456,6 @@ extern CPUTailQ cpus;extern __threadCPUState *current_cpu; -/** -* qemu_tcg_mttcg_enabled: -* Check whether we are running MultiThread TCG or not. -* -* Returns: %true if we are in MTTCG mode %false otherwise. -*/ -extern bool mttcg_enabled; -#define qemu_tcg_mttcg_enabled () (mttcg_enabled)