[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] bulk: Prefer fast cpu_env() over slower CPU QOM cast macro
- To: Thomas Huth <thuth@xxxxxxxxxx>, qemu-devel@xxxxxxxxxx
- From: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
- Date: Fri, 26 Jan 2024 22:11:08 +0100
- Cc: Peter Maydell <peter.maydell@xxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Eduardo Habkost <eduardo@xxxxxxxxxxx>, Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, qemu-s390x@xxxxxxxxxx, qemu-ppc@xxxxxxxxxx, qemu-riscv@xxxxxxxxxx, qemu-arm@xxxxxxxxxx, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Cédric Le Goater <clg@xxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Frédéric Barrat <fbarrat@xxxxxxxxxxxxx>, Daniel Henrique Barboza <danielhb413@xxxxxxxxx>, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>, Harsh Prateek Bora <harshpb@xxxxxxxxxxxxx>, Alexander Graf <agraf@xxxxxxxxx>, Michael Rolnik <mrolnik@xxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, Cameron Esfahani <dirty@xxxxxxxxx>, Roman Bolshakov <rbolshakov@xxxxxxx>, Marcelo Tosatti <mtosatti@xxxxxxxxxx>, David Woodhouse <dwmw2@xxxxxxxxxxxxx>, Laurent Vivier <laurent@xxxxxxxxx>, Aurelien Jarno <aurelien@xxxxxxxxxxx>, Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>, Aleksandar Rikalo <aleksandar.rikalo@xxxxxxxxxx>, Huacai Chen <chenhuacai@xxxxxxxxxx>, Chris Wulff <crwulff@xxxxxxxxx>, Marek Vasut <marex@xxxxxxx>, Stafford Horne <shorne@xxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Bin Meng <bin.meng@xxxxxxxxxxxxx>, Weiwei Li <liwei1518@xxxxxxxxx>, Liu Zhiwei <zhiwei_liu@xxxxxxxxxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Ilya Leoshkevich <iii@xxxxxxxxxxxxx>, Halil Pasic <pasic@xxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, Artyom Tarasenko <atar4qemu@xxxxxxxxx>, Bastian Koppelmann <kbastian@xxxxxxxxxxxxxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx
- Delivery-date: Fri, 26 Jan 2024 21:11:27 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 26/1/24 18:09, Thomas Huth wrote:
On 25/01/2024 17.56, Philippe Mathieu-Daudé wrote:
Mechanical patch produced running the command documented
in scripts/coccinelle/cpu_env.cocci_template header.
Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
---
114 files changed, 273 insertions(+), 548 deletions(-)
A huge patch ... I wonder whether it would make sense to split it up by
target architecture to ease the review?
...
diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c
index a8d014d09a..eb0613bfbe 100644
--- a/hw/i386/vmmouse.c
+++ b/hw/i386/vmmouse.c
@@ -74,8 +74,7 @@ struct VMMouseState {
static void vmmouse_get_data(uint32_t *data)
{
- X86CPU *cpu = X86_CPU(current_cpu);
- CPUX86State *env = &cpu->env;
+ CPUX86State *env = cpu_env(CPU(current_cpu));
No need for the CPU() cast here, current_cpu is already
of type "CPUState *".
Yes, Paolo noticed and I fixed for v2.
I'll stop here, please respin with the cpu_env(CPU(current_cpu)) fixed to
cpu_env(current_cpu), and please split the patch by target CPU types.
Well I don't know, this is an reproducible mechanical patch..
But indeed as Paolo you found an optimization so worth not making
human review a pain.
I was about to post v2 but I'll see how to split.
Thanks for the review!
Phil.
|