[PATCH 0/2] hw, target: Prefer fast cpu_env() over slower CPU QOM cast macro

Philippe Mathieu-Daudé posted 2 patches 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240125165648.49898-1-philmd@linaro.org
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Stefano Stabellini <sstabellini@kernel.org>, Anthony Perard <anthony.perard@citrix.com>, Paul Durrant <paul@xen.org>, Peter Maydell <peter.maydell@linaro.org>, "Cédric Le Goater" <clg@kaod.org>, Nicholas Piggin <npiggin@gmail.com>, "Frédéric Barrat" <fbarrat@linux.ibm.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Alexander Graf <agraf@csgraf.de>, Michael Rolnik <mrolnik@gmail.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Marcelo Tosatti <mtosatti@redhat.com>, David Woodhouse <dwmw2@infradead.org>, Laurent Vivier <laurent@vivier.eu>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Huacai Chen <chenhuacai@kernel.org>, Chris Wulff <crwulff@gmail.com>, Marek Vasut <marex@denx.de>, Stafford Horne <shorne@gmail.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Bin Meng <bin.meng@windriver.com>, Weiwei Li <liwei1518@gmail.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, Thomas Huth <thuth@redhat.com>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Max Filippov <jcmvbkbc@gmail.com>
There is a newer version of this series
MAINTAINERS                               |  1 +
target/i386/hvf/vmx.h                     |  9 ++--
hw/i386/vmmouse.c                         |  6 +--
hw/i386/xen/xen-hvm.c                     |  3 +-
hw/intc/arm_gicv3_cpuif_common.c          |  3 +-
hw/ppc/mpc8544_guts.c                     |  3 +-
hw/ppc/pnv.c                              |  3 +-
hw/ppc/pnv_xscom.c                        |  3 +-
hw/ppc/ppce500_spin.c                     |  3 +-
hw/ppc/spapr.c                            |  3 +-
hw/ppc/spapr_caps.c                       |  6 +--
target/alpha/cpu.c                        | 21 +++-----
target/alpha/gdbstub.c                    |  6 +--
target/alpha/helper.c                     | 12 ++---
target/alpha/mem_helper.c                 |  9 ++--
target/arm/cpu.c                          | 15 ++----
target/arm/debug_helper.c                 |  6 +--
target/arm/gdbstub.c                      |  6 +--
target/arm/gdbstub64.c                    |  6 +--
target/arm/helper.c                       |  9 ++--
target/arm/hvf/hvf.c                      | 12 ++---
target/arm/kvm.c                          |  3 +-
target/arm/ptw.c                          |  3 +-
target/arm/tcg/cpu32.c                    |  3 +-
target/avr/cpu.c                          | 21 +++-----
target/avr/gdbstub.c                      |  6 +--
target/avr/helper.c                       |  9 ++--
target/cris/cpu.c                         |  3 +-
target/cris/gdbstub.c                     |  9 ++--
target/cris/helper.c                      | 12 ++---
target/cris/translate.c                   |  3 +-
target/hppa/cpu.c                         |  6 +--
target/hppa/int_helper.c                  |  6 +--
target/hppa/mem_helper.c                  |  3 +-
target/i386/arch_memory_mapping.c         |  3 +-
target/i386/cpu-dump.c                    |  3 +-
target/i386/cpu.c                         | 36 +++++---------
target/i386/helper.c                      | 30 ++++--------
target/i386/hvf/hvf.c                     |  6 +--
target/i386/hvf/x86.c                     |  3 +-
target/i386/hvf/x86_emu.c                 |  6 +--
target/i386/hvf/x86_task.c                | 10 ++--
target/i386/hvf/x86hvf.c                  |  6 +--
target/i386/kvm/kvm.c                     |  6 +--
target/i386/kvm/xen-emu.c                 | 30 ++++--------
target/i386/tcg/sysemu/bpt_helper.c       |  3 +-
target/i386/tcg/tcg-cpu.c                 | 12 ++---
target/i386/tcg/user/excp_helper.c        |  3 +-
target/i386/tcg/user/seg_helper.c         |  3 +-
target/m68k/cpu.c                         | 30 ++++--------
target/m68k/gdbstub.c                     |  6 +--
target/m68k/helper.c                      |  3 +-
target/m68k/m68k-semi.c                   |  6 +--
target/m68k/op_helper.c                   |  9 ++--
target/m68k/translate.c                   |  3 +-
target/microblaze/helper.c                |  3 +-
target/microblaze/translate.c             |  3 +-
target/mips/cpu.c                         |  9 ++--
target/mips/gdbstub.c                     |  6 +--
target/mips/kvm.c                         | 27 ++++------
target/mips/sysemu/physaddr.c             |  3 +-
target/mips/tcg/exception.c               |  3 +-
target/mips/tcg/op_helper.c               |  3 +-
target/mips/tcg/sysemu/special_helper.c   |  3 +-
target/mips/tcg/sysemu/tlb_helper.c       |  6 +--
target/mips/tcg/translate.c               |  3 +-
target/nios2/cpu.c                        |  9 ++--
target/nios2/helper.c                     |  3 +-
target/nios2/nios2-semi.c                 |  6 +--
target/openrisc/gdbstub.c                 |  3 +-
target/openrisc/interrupt.c               |  6 +--
target/openrisc/translate.c               |  3 +-
target/ppc/cpu_init.c                     |  9 ++--
target/ppc/excp_helper.c                  |  3 +-
target/ppc/gdbstub.c                      | 12 ++---
target/ppc/kvm.c                          |  6 +--
target/ppc/ppc-qmp-cmds.c                 |  3 +-
target/ppc/user_only_helper.c             |  3 +-
target/riscv/arch_dump.c                  |  6 +--
target/riscv/cpu.c                        | 15 ++----
target/riscv/cpu_helper.c                 | 13 ++---
target/riscv/debug.c                      |  9 ++--
target/riscv/gdbstub.c                    |  6 +--
target/riscv/kvm/kvm-cpu.c                |  6 +--
target/riscv/tcg/tcg-cpu.c                |  9 ++--
target/riscv/translate.c                  |  3 +-
target/rx/gdbstub.c                       |  6 +--
target/rx/helper.c                        |  6 +--
target/rx/translate.c                     |  3 +-
target/s390x/cpu-dump.c                   |  3 +-
target/s390x/gdbstub.c                    |  6 +--
target/s390x/helper.c                     |  3 +-
target/s390x/kvm/kvm.c                    |  6 +--
target/s390x/tcg/excp_helper.c            |  9 ++--
target/s390x/tcg/translate.c              |  3 +-
target/sh4/cpu.c                          | 15 ++----
target/sh4/gdbstub.c                      |  6 +--
target/sh4/helper.c                       |  9 ++--
target/sh4/translate.c                    |  3 +-
target/sparc/cpu.c                        | 12 ++---
target/sparc/gdbstub.c                    |  3 +-
target/sparc/int32_helper.c               |  3 +-
target/sparc/int64_helper.c               |  3 +-
target/sparc/ldst_helper.c                |  6 +--
target/sparc/mmu_helper.c                 | 15 ++----
target/sparc/translate.c                  |  3 +-
target/tricore/cpu.c                      | 12 ++---
target/tricore/gdbstub.c                  |  6 +--
target/tricore/helper.c                   |  3 +-
target/tricore/translate.c                |  3 +-
target/xtensa/dbg_helper.c                |  3 +-
target/xtensa/exc_helper.c                |  3 +-
target/xtensa/gdbstub.c                   |  6 +--
target/xtensa/helper.c                    |  9 ++--
target/xtensa/translate.c                 |  3 +-
scripts/coccinelle/cpu_env.cocci_template | 60 +++++++++++++++++++++++
116 files changed, 334 insertions(+), 548 deletions(-)
create mode 100644 scripts/coccinelle/cpu_env.cocci_template
[PATCH 0/2] hw, target: Prefer fast cpu_env() over slower CPU QOM cast macro
Posted by Philippe Mathieu-Daudé 10 months ago
Use cpu_env() -- which is fast path -- when possible.
Bulk conversion using Coccinelle spatch (script included).

Philippe Mathieu-Daudé (2):
  scripts/coccinelle: Add cpu_env.cocci_template script
  bulk: Prefer fast cpu_env() over slower CPU QOM cast macro

 MAINTAINERS                               |  1 +
 target/i386/hvf/vmx.h                     |  9 ++--
 hw/i386/vmmouse.c                         |  6 +--
 hw/i386/xen/xen-hvm.c                     |  3 +-
 hw/intc/arm_gicv3_cpuif_common.c          |  3 +-
 hw/ppc/mpc8544_guts.c                     |  3 +-
 hw/ppc/pnv.c                              |  3 +-
 hw/ppc/pnv_xscom.c                        |  3 +-
 hw/ppc/ppce500_spin.c                     |  3 +-
 hw/ppc/spapr.c                            |  3 +-
 hw/ppc/spapr_caps.c                       |  6 +--
 target/alpha/cpu.c                        | 21 +++-----
 target/alpha/gdbstub.c                    |  6 +--
 target/alpha/helper.c                     | 12 ++---
 target/alpha/mem_helper.c                 |  9 ++--
 target/arm/cpu.c                          | 15 ++----
 target/arm/debug_helper.c                 |  6 +--
 target/arm/gdbstub.c                      |  6 +--
 target/arm/gdbstub64.c                    |  6 +--
 target/arm/helper.c                       |  9 ++--
 target/arm/hvf/hvf.c                      | 12 ++---
 target/arm/kvm.c                          |  3 +-
 target/arm/ptw.c                          |  3 +-
 target/arm/tcg/cpu32.c                    |  3 +-
 target/avr/cpu.c                          | 21 +++-----
 target/avr/gdbstub.c                      |  6 +--
 target/avr/helper.c                       |  9 ++--
 target/cris/cpu.c                         |  3 +-
 target/cris/gdbstub.c                     |  9 ++--
 target/cris/helper.c                      | 12 ++---
 target/cris/translate.c                   |  3 +-
 target/hppa/cpu.c                         |  6 +--
 target/hppa/int_helper.c                  |  6 +--
 target/hppa/mem_helper.c                  |  3 +-
 target/i386/arch_memory_mapping.c         |  3 +-
 target/i386/cpu-dump.c                    |  3 +-
 target/i386/cpu.c                         | 36 +++++---------
 target/i386/helper.c                      | 30 ++++--------
 target/i386/hvf/hvf.c                     |  6 +--
 target/i386/hvf/x86.c                     |  3 +-
 target/i386/hvf/x86_emu.c                 |  6 +--
 target/i386/hvf/x86_task.c                | 10 ++--
 target/i386/hvf/x86hvf.c                  |  6 +--
 target/i386/kvm/kvm.c                     |  6 +--
 target/i386/kvm/xen-emu.c                 | 30 ++++--------
 target/i386/tcg/sysemu/bpt_helper.c       |  3 +-
 target/i386/tcg/tcg-cpu.c                 | 12 ++---
 target/i386/tcg/user/excp_helper.c        |  3 +-
 target/i386/tcg/user/seg_helper.c         |  3 +-
 target/m68k/cpu.c                         | 30 ++++--------
 target/m68k/gdbstub.c                     |  6 +--
 target/m68k/helper.c                      |  3 +-
 target/m68k/m68k-semi.c                   |  6 +--
 target/m68k/op_helper.c                   |  9 ++--
 target/m68k/translate.c                   |  3 +-
 target/microblaze/helper.c                |  3 +-
 target/microblaze/translate.c             |  3 +-
 target/mips/cpu.c                         |  9 ++--
 target/mips/gdbstub.c                     |  6 +--
 target/mips/kvm.c                         | 27 ++++------
 target/mips/sysemu/physaddr.c             |  3 +-
 target/mips/tcg/exception.c               |  3 +-
 target/mips/tcg/op_helper.c               |  3 +-
 target/mips/tcg/sysemu/special_helper.c   |  3 +-
 target/mips/tcg/sysemu/tlb_helper.c       |  6 +--
 target/mips/tcg/translate.c               |  3 +-
 target/nios2/cpu.c                        |  9 ++--
 target/nios2/helper.c                     |  3 +-
 target/nios2/nios2-semi.c                 |  6 +--
 target/openrisc/gdbstub.c                 |  3 +-
 target/openrisc/interrupt.c               |  6 +--
 target/openrisc/translate.c               |  3 +-
 target/ppc/cpu_init.c                     |  9 ++--
 target/ppc/excp_helper.c                  |  3 +-
 target/ppc/gdbstub.c                      | 12 ++---
 target/ppc/kvm.c                          |  6 +--
 target/ppc/ppc-qmp-cmds.c                 |  3 +-
 target/ppc/user_only_helper.c             |  3 +-
 target/riscv/arch_dump.c                  |  6 +--
 target/riscv/cpu.c                        | 15 ++----
 target/riscv/cpu_helper.c                 | 13 ++---
 target/riscv/debug.c                      |  9 ++--
 target/riscv/gdbstub.c                    |  6 +--
 target/riscv/kvm/kvm-cpu.c                |  6 +--
 target/riscv/tcg/tcg-cpu.c                |  9 ++--
 target/riscv/translate.c                  |  3 +-
 target/rx/gdbstub.c                       |  6 +--
 target/rx/helper.c                        |  6 +--
 target/rx/translate.c                     |  3 +-
 target/s390x/cpu-dump.c                   |  3 +-
 target/s390x/gdbstub.c                    |  6 +--
 target/s390x/helper.c                     |  3 +-
 target/s390x/kvm/kvm.c                    |  6 +--
 target/s390x/tcg/excp_helper.c            |  9 ++--
 target/s390x/tcg/translate.c              |  3 +-
 target/sh4/cpu.c                          | 15 ++----
 target/sh4/gdbstub.c                      |  6 +--
 target/sh4/helper.c                       |  9 ++--
 target/sh4/translate.c                    |  3 +-
 target/sparc/cpu.c                        | 12 ++---
 target/sparc/gdbstub.c                    |  3 +-
 target/sparc/int32_helper.c               |  3 +-
 target/sparc/int64_helper.c               |  3 +-
 target/sparc/ldst_helper.c                |  6 +--
 target/sparc/mmu_helper.c                 | 15 ++----
 target/sparc/translate.c                  |  3 +-
 target/tricore/cpu.c                      | 12 ++---
 target/tricore/gdbstub.c                  |  6 +--
 target/tricore/helper.c                   |  3 +-
 target/tricore/translate.c                |  3 +-
 target/xtensa/dbg_helper.c                |  3 +-
 target/xtensa/exc_helper.c                |  3 +-
 target/xtensa/gdbstub.c                   |  6 +--
 target/xtensa/helper.c                    |  9 ++--
 target/xtensa/translate.c                 |  3 +-
 scripts/coccinelle/cpu_env.cocci_template | 60 +++++++++++++++++++++++
 116 files changed, 334 insertions(+), 548 deletions(-)
 create mode 100644 scripts/coccinelle/cpu_env.cocci_template

-- 
2.41.0