From: Mark Rutland <mark.rutland@arm.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com,
lenb@kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, mhiramat@kernel.org,
ndesaulniers@google.com, ojeda@kernel.org, peterz@infradead.org,
rafael.j.wysocki@intel.com, revest@chromium.org,
robert.moore@intel.com, rostedt@goodmis.org, will@kernel.org
Subject: Re: [PATCH 1/8] Compiler attributes: GCC function alignment workarounds
Date: Mon, 9 Jan 2023 17:06:00 +0000 [thread overview]
Message-ID: <Y7xJeHDcanUJoHt+@FVFF77S0Q05N> (raw)
In-Reply-To: <CANiq72kgmFYEO_EB_NxAF=S7VOf45KM7W3uwxxvftVErwfWzjg@mail.gmail.com>
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@arm.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
Whoops: s/explciitly/explicitly/ here too; I'll go re-proofread the series.
> > 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.
Whoops: s/attibute/attribute/
> 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.
Sorry, that is something I had intendeed to do but I hadn't extracted a
reproducer yet. I'll try to come up with something that can be included in the
commit message and reported to GCC folk (and double-check at the same time that
there's not another hidden cause)
With this series applied and this patch reverted, it's possible to see when
building defconfig + CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B=y, where scanning
/proc/kallsyms with:
$ grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] '
... will show a bunch of cold functions (and their callees/callers), largely
init/exit functions (so I'll double-check whether section handling as an
effect), e.g.
ffffdf08be173b8c t snd_soc_exit
ffffdf08be173bc4 t apple_mca_driver_exit
ffffdf08be173be8 t failover_exit
ffffdf08be173c10 t inet_diag_exit
ffffdf08be173c60 t tcp_diag_exit
ffffdf08be173c84 t cubictcp_unregister
ffffdf08be173cac t af_unix_exit
ffffdf08be173cf4 t packet_exit
ffffdf08be173d3c t cleanup_sunrpc
ffffdf08be173d8c t exit_rpcsec_gss
ffffdf08be173dc4 t exit_p9
ffffdf08be173dec T p9_client_exit
ffffdf08be173e10 t p9_trans_fd_exit
ffffdf08be173e58 t p9_virtio_cleanup
ffffdf08be173e90 t exit_dns_resolver
> > + * '-falign-functions=N', and require alignment to be specificed via a function
>
> Nit: specificed -> specified
Thanks, fixed
> > +#if CONFIG_FUNCTION_ALIGNMENT > 0
> > +#define __function_aligned __aligned(CONFIG_FUNCTION_ALIGNMENT)
> > +#else
> > +#define __function_aligned
> > +#endif
>
> Currently, the file is intended for attributes that do not depend on
> `CONFIG_*` options.
>
> What I usually mention is that we could change that policy, but
> otherwise these would go into e.g. `compiler_types.h`.
I'm happy to move these, I just wasn't sure what the policy would be w.r.t. the
existing __weak and __cold defitions since those end up depending upon
__function_aligned.
I assume I should move them all? i.e. move __weak as well?
> > +#if !defined(CONFIG_CC_IS_GCC) || (CONFIG_FUNCTION_ALIGNMENT == 0)
> > #define __cold __attribute__((__cold__))
> > +#else
> > +#define __cold
> > +#endif
>
> Similarly, in this case this could go into `compiler-gcc.h` /
> `compiler-clang.h` etc., since the definition will be different for
> each.
Sure, can do.
Thanks,
Mark.
next prev parent reply other threads:[~2023-01-09 17:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 13:58 [PATCH 0/8] arm64/ftrace: Add support for DYNAMIC_FTRACE_WITH_CALL_OPS Mark Rutland
2023-01-09 13:58 ` [PATCH 1/8] Compiler attributes: GCC function alignment workarounds Mark Rutland
2023-01-09 14:43 ` Miguel Ojeda
2023-01-09 17:06 ` Mark Rutland [this message]
2023-01-09 22:35 ` Miguel Ojeda
2023-01-11 18:27 ` Mark Rutland
2023-01-12 11:38 ` Mark Rutland
2023-01-13 12:49 ` Mark Rutland
2023-01-15 21:32 ` Miguel Ojeda
2023-01-09 13:58 ` [PATCH 2/8] ACPI: Don't build ACPICA with '-Os' Mark Rutland
2023-01-10 13:45 ` Rafael J. Wysocki
2023-01-09 13:58 ` [PATCH 3/8] arm64: Extend support for CONFIG_FUNCTION_ALIGNMENT Mark Rutland
2023-01-10 20:35 ` Peter Zijlstra
2023-01-10 20:43 ` Will Deacon
2023-01-11 11:39 ` Mark Rutland
2023-01-11 11:36 ` Mark Rutland
2023-01-09 13:58 ` [PATCH 4/8] ftrace: Add DYNAMIC_FTRACE_WITH_CALL_OPS Mark Rutland
2023-01-12 6:48 ` Li Huafei
2023-01-12 11:00 ` Mark Rutland
2023-01-13 1:15 ` Li Huafei
2023-01-09 13:58 ` [PATCH 5/8] arm64: insn: Add helpers for BTI Mark Rutland
2023-01-09 13:58 ` [PATCH 6/8] arm64: patching: Add aarch64_insn_write_literal_u64() Mark Rutland
2023-01-09 13:58 ` [PATCH 7/8] arm64: ftrace: Update stale comment Mark Rutland
2023-01-09 13:58 ` [PATCH 8/8] arm64: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS Mark Rutland
2023-01-10 8:55 ` [PATCH 0/8] arm64/ftrace: Add support for DYNAMIC_FTRACE_WITH_CALL_OPS David Laight
2023-01-10 10:31 ` Mark Rutland
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=Y7xJeHDcanUJoHt+@FVFF77S0Q05N \
--to=mark.rutland@arm.com \
--cc=catalin.marinas@arm.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ndesaulniers@google.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=revest@chromium.org \
--cc=robert.moore@intel.com \
--cc=rostedt@goodmis.org \
--cc=will@kernel.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).