From: Arvind Sankar <nivedita@alum.mit.edu>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
Wanpeng Li <wanpengli@tencent.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>,
Arvind Sankar <nivedita@alum.mit.edu>,
"H. Peter Anvin" <hpa@zytor.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
"x86@kernel.org" <x86@kernel.org>, Ingo Molnar <mingo@redhat.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Arnd Bergmann <arnd@arndb.de>,
Haiyang Zhang <haiyangz@microsoft.com>,
Borislav Petkov <bp@alien8.de>, Jim Mattson <jmattson@google.com>,
'Arnd Bergmann' <arnd@kernel.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>,
David Laight <David.Laight@ACULAB.COM>,
Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: Re: [PATCH] [v2] x86: apic: avoid -Wshadow warning in header
Date: Thu, 29 Oct 2020 17:35:12 -0400 [thread overview]
Message-ID: <20201029213512.GA34524@rani.riverdale.lan> (raw)
In-Reply-To: <87v9esojdi.fsf@nanos.tec.linutronix.de>
On Thu, Oct 29, 2020 at 09:41:13PM +0100, Thomas Gleixner wrote:
> 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
It's not quite the same.
https://godbolt.org/z/4dzPbM
With -fno-strict-aliasing, the compiler reloads the pointer if you write
to the start of what it points to, but not if you write to later
elements.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-10-29 21:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 21:20 [PATCH] [v2] x86: apic: avoid -Wshadow warning in header Arnd Bergmann
2020-10-29 7:04 ` Paolo Bonzini
2020-10-29 9:51 ` Arnd Bergmann
2020-10-29 16:30 ` David Laight
2020-10-29 16:52 ` Thomas Gleixner
2020-10-29 15:05 ` David Laight
2020-10-29 16:56 ` Arvind Sankar
2020-10-29 16:59 ` Paolo Bonzini
2020-10-29 17:20 ` Arvind Sankar
2020-10-29 20:41 ` Thomas Gleixner
2020-10-29 21:35 ` Arvind Sankar [this message]
2020-10-29 22:12 ` David Laight
2020-10-30 18:16 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201029213512.GA34524@rani.riverdale.lan \
--to=nivedita@alum.mit.edu \
--cc=David.Laight@ACULAB.COM \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=bp@alien8.de \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=sthemmin@microsoft.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).