[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] [v2] x86: apic: avoid -Wshadow warning in header
- To: Paolo Bonzini <pbonzini@xxxxxxxxxx>, Arvind Sankar <nivedita@xxxxxxxxxxxx>, David Laight <David.Laight@xxxxxxxxxx>
- From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
- Date: Thu, 29 Oct 2020 21:41:13 +0100
- Cc: 'Arnd Bergmann' <arnd@xxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, "x86\@kernel.org" <x86@xxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, "K. Y. Srinivasan" <kys@xxxxxxxxxxxxx>, Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>, Stephen Hemminger <sthemmin@xxxxxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx>, Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>, Wanpeng Li <wanpengli@xxxxxxxxxxx>, Jim Mattson <jmattson@xxxxxxxxxx>, Joerg Roedel <joro@xxxxxxxxxx>, "linux-hyperv\@vger.kernel.org" <linux-hyperv@xxxxxxxxxxxxxxx>, "linux-kernel\@vger.kernel.org" <linux-kernel@xxxxxxxxxxxxxxx>, "kvm\@vger.kernel.org" <kvm@xxxxxxxxxxxxxxx>, "platform-driver-x86\@vger.kernel.org" <platform-driver-x86@xxxxxxxxxxxxxxx>, "xen-devel\@lists.xenproject.org" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "iommu\@lists.linux-foundation.org" <iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Thu, 29 Oct 2020 20:41:21 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Thu, Oct 29 2020 at 17:59, Paolo Bonzini wrote:
> On 29/10/20 17:56, Arvind Sankar wrote:
>>> For those two just add:
>>> struct apic *apic = x86_system_apic;
>>> before all the assignments.
>>> Less churn and much better code.
>>>
>> Why would it be better code?
>>
>
> I think he means the compiler produces better code, because it won't
> read the global variable repeatedly. Not sure if that's true,(*) but I
> think I do prefer that version if Arnd wants to do that tweak.
It's not true.
foo *p = bar;
p->a = 1;
p->b = 2;
The compiler is free to reload bar after accessing p->a and with
bar->a = 1;
bar->b = 1;
it can either cache bar in a register or reread it after bar->a
The generated code is the same as long as there is no reason to reload,
e.g. register pressure.
Thanks,
tglx
|