Re: GCC section alignment, and GCC-4.9 being a weird one

From: Peter Zijlstra
Date: Thu Oct 22 2020 - 03:38:38 EST


On Wed, Oct 21, 2020 at 10:42:01AM -0700, Nick Desaulniers wrote:
> On Wed, Oct 21, 2020 at 6:45 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >
> > Ah, thanks!
> >
> > In that case something like the below ought to make it good.
> >
> > I'll go feed it to the robots, see if anything falls over.
> >
> > ---
> > kernel/sched/deadline.c | 4 +++-
> > kernel/sched/fair.c | 4 +++-
> > kernel/sched/idle.c | 4 +++-
> > kernel/sched/rt.c | 4 +++-
> > kernel/sched/sched.h | 3 +--
> > kernel/sched/stop_task.c | 3 ++-
> > 6 files changed, 15 insertions(+), 7 deletions(-)
> >
> > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> > index 6d93f4518734..f4855203143d 100644
> > --- a/kernel/sched/deadline.c
> > +++ b/kernel/sched/deadline.c
> > @@ -2504,7 +2504,9 @@ static void prio_changed_dl(struct rq *rq, struct task_struct *p,
> > }
> >
> > const struct sched_class dl_sched_class
> > - __attribute__((section("__dl_sched_class"))) = {
> > + __attribute__((section("__dl_sched_class")))
> > + __attribute__((aligned(__alignof__(struct sched_class)))) = {
>
> If you used some of the macros from
> include/linux/compiler_attributes.h like __section and __aligned, I
> would prefer it. Please consider spelling out __attribute__(()) an
> antipattern.

Feh, and then suffer more patches because someone doesn't like how
__section uses # :/