[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y8FTXyKkI77nFIMJ@FVFF77S0Q05N>
Date: Fri, 13 Jan 2023 12:49:35 +0000
From: Mark Rutland <mark.rutland@....com>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: linux-arm-kernel@...ts.infradead.org, catalin.marinas@....com,
lenb@...nel.org, linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org, mhiramat@...nel.org,
ndesaulniers@...gle.com, ojeda@...nel.org, peterz@...radead.org,
rafael.j.wysocki@...el.com, revest@...omium.org,
robert.moore@...el.com, rostedt@...dmis.org, will@...nel.org
Subject: Re: [PATCH 1/8] Compiler attributes: GCC function alignment
workarounds
On Thu, Jan 12, 2023 at 11:38:17AM +0000, Mark Rutland wrote:
> On Wed, Jan 11, 2023 at 06:27:53PM +0000, Mark Rutland wrote:
> > On Mon, Jan 09, 2023 at 03:43:16PM +0100, Miguel Ojeda wrote:
> > > On Mon, Jan 9, 2023 at 2:58 PM Mark Rutland <mark.rutland@....com> wrote:
> > > >
> > > > As far as I can tell, GCC doesn't respect '-falign-functions=N':
> > > >
> > > > * When the __weak__ attribute is used
> > > >
> > > > GCC seems to forget the alignment specified by '-falign-functions=N',
> > > > but will respect the '__aligned__(N)' function attribute. Thus, we can
> > > > work around this by explciitly setting the alignment for weak
> > > > functions.
> > > >
> > > > * When the __cold__ attribute is used
> > > >
> > > > GCC seems to forget the alignment specified by '-falign-functions=N',
> > > > and also doesn't seem to respect the '__aligned__(N)' function
> > > > attribute. The only way to work around this is to not use the __cold__
> > > > attibute.
> > >
> > > If you happen to have a reduced case, then it would be nice to link it
> > > in the commit. A bug report to GCC would also be nice.
> > >
> > > I gave it a very quick try in Compiler Explorer, but I couldn't
> > > reproduce it, so I guess it depends on flags, non-trivial functions or
> > > something else.
> >
> > So having spent today coming up with tests, it turns out it's not quite as I
> > described above, but in a sense worse. I'm posting a summary here for
> > posterity; I'll try to get this to compiler folk shortly.
>
> I've added the cold bits to an existing ticket:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88345
>
> I have not been able to reproduce the issue with __weak__, so I'll go dig into
> that some more; it's likely I was mistaken there.
It turns out that was a red herring; GCC is actually implicitly marking the
abort() function as cold, and as Linux's implementation happened to be marked
as weak I assumed that was the culprit.
I'll drop the changes to weak and update our abort implementation specifically,
with a comment.
I'll also go update the ticket above.
Thanks,
Mark.
Powered by blists - more mailing lists