target/riscv: Use env_archcpu for better performance
PATCH v3 1/1 target/riscv: Use env_archcpu for better performance
In v3:
- Use env_archcpu
- Rerun the benchmark to get new "after" figures
Rich.
PATCH v3 1/1 target/riscv: Use env_archcpu for better performance
RISCV_CPU(cs) uses a checked cast. When QOM cast debugging is enabled this adds about 5% total overhead when emulating RV64 on x86-64 host.
Using a RISC-V guest with 16 vCPUs, 16 GB of guest RAM, virtio-blk disk. The guest has a copy of the qemu source tree. The test involves compiling the qemu source tree with 'make clean; time make -j16'.
Before making this change the compile step took 449 & 447 seconds over two consecutive runs.
After making this change: 428 & 421 seconds.
The saving is over 5%.
Thanks: Paolo Bonzini
Thanks: Philippe Mathieu-Daudé
--- target/riscv/cpu_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/riscv/cpu_helper.c +1 -2
@@ -65,8 +65,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)void cpu_get_tb_cpu_state (CPURISCVState *env,vaddr *pc,uint64_t *cs_base,uint32_t *pflags) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); +RISCVCPU *cpu =env_archcpu (env);RISCVExtStatus fs, vs;uint32_t flags =0 ;
Signature · 1 line
2.41.0
Quoted 12 lines · Richard W.M. Jones
RISCV_CPU(cs)uses a checked cast. When QOM cast debugging is enabled this adds about 5% total overhead when emulating RV64 on x86-64 host.Using a RISC-V guest with 16 vCPUs, 16 GB of guest RAM, virtio-blk disk. The guest has a copy of the qemu source tree. The test involves compiling the qemu source tree with 'make clean; time make -j16'.
Before making this change the compile step took 449 & 447 seconds over two consecutive runs.
After making this change: 428 & 421 seconds.
Quoted 8 lines
The saving is over 5%.
Thanks: Paolo Bonzini
Thanks: Philippe Mathieu-DaudéSigned-off-by Richard W.M. Jones <[email protected]>--- target/riscv/cpu_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 12 lines · Richard W.M. Jones
RISCV_CPU(cs)uses a checked cast. When QOM cast debugging is enabled this adds about 5% total overhead when emulating RV64 on x86-64 host.Using a RISC-V guest with 16 vCPUs, 16 GB of guest RAM, virtio-blk disk. The guest has a copy of the qemu source tree. The test involves compiling the qemu source tree with 'make clean; time make -j16'.
Before making this change the compile step took 449 & 447 seconds over two consecutive runs.
After making this change: 428 & 421 seconds.
Quoted 8 lines
The saving is over 5%.
Thanks: Paolo Bonzini
Thanks: Philippe Mathieu-DaudéSigned-off-by Richard W.M. Jones <[email protected]>--- target/riscv/cpu_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
r~
Quoted 11 lines · Richard W.M. Jones
RISCV_CPU(cs)uses a checked cast. When QOM cast debugging is enabled this adds about 5% total overhead when emulating RV64 on x86-64 host.Using a RISC-V guest with 16 vCPUs, 16 GB of guest RAM, virtio-blk disk. The guest has a copy of the qemu source tree. The test involves compiling the qemu source tree with 'make clean; time make -j16'.
Before making this change the compile step took 449 & 447 seconds over two consecutive runs.
Quoted 7 lines
After making this change: 428 & 421 seconds.
The saving is over 5%.
Thanks: Paolo Bonzini
Thanks: Philippe Mathieu-DaudéSigned-off-by Richard W.M. Jones <[email protected]>
Alistair
Quoted 22 lines
--- target/riscv/cpu_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/riscv/cpu_helper.c +1
-3@@ -65,8 +65,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)void cpu_get_tb_cpu_state (CPURISCVState *env,vaddr *pc,uint64_t *cs_base,uint32_t *pflags) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); +RISCVCPU *cpu =env_archcpu (env);RISCVExtStatus fs, vs;uint32_t flags =0 ; --2.41.0
Alistair Francis
AppliedQuoted 11 lines · Richard W.M. Jones
RISCV_CPU(cs)uses a checked cast. When QOM cast debugging is enabled this adds about 5% total overhead when emulating RV64 on x86-64 host.Using a RISC-V guest with 16 vCPUs, 16 GB of guest RAM, virtio-blk disk. The guest has a copy of the qemu source tree. The test involves compiling the qemu source tree with 'make clean; time make -j16'.
Before making this change the compile step took 449 & 447 seconds over two consecutive runs.
Quoted 7 lines
After making this change: 428 & 421 seconds.
The saving is over 5%.
Thanks: Paolo Bonzini
Thanks: Philippe Mathieu-DaudéSigned-off-by Richard W.M. Jones <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 22 lines
--- target/riscv/cpu_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/riscv/cpu_helper.c +1
-3@@ -65,8 +65,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)void cpu_get_tb_cpu_state (CPURISCVState *env,vaddr *pc,uint64_t *cs_base,uint32_t *pflags) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); +RISCVCPU *cpu =env_archcpu (env);RISCVExtStatus fs, vs;uint32_t flags =0 ; --2.41.0