All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Jakub Jelinek <jakub@redhat.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	kernel test robot <lkp@intel.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<x86@kernel.org>, LKP <lkp@lists.01.org>,
	Kees Cook <keescook@chromium.org>,
	"H.J. Lu" <hjl.tools@gmail.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-toolchains@vger.kernel.org,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Subject: Re: GCC section alignment, and GCC-4.9 being a weird one
Date: Wed, 21 Oct 2020 10:42:01 -0700	[thread overview]
Message-ID: <CAKwvOd=qi63We=6rLapb565giCVe-8a6d=-=3VZL6RWzhwAeZg@mail.gmail.com> (raw)
In-Reply-To: <20201021134436.GJ2628@hirez.programming.kicks-ass.net>

On Wed, Oct 21, 2020 at 6:45 AM Peter Zijlstra <peterz@infradead.org> 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.

> +
>         .enqueue_task           = enqueue_task_dl,
>         .dequeue_task           = dequeue_task_dl,
>         .yield_task             = yield_task_dl,
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index aa4c6227cd6d..9bfa9f545b9a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -11159,7 +11159,9 @@ static unsigned int get_rr_interval_fair(struct rq *rq, struct task_struct *task
>   * All the scheduling class methods:
>   */
>  const struct sched_class fair_sched_class
> -       __attribute__((section("__fair_sched_class"))) = {
> +       __attribute__((section("__fair_sched_class")))
> +       __attribute__((aligned(__alignof__(struct sched_class)))) = {
> +
>         .enqueue_task           = enqueue_task_fair,
>         .dequeue_task           = dequeue_task_fair,
>         .yield_task             = yield_task_fair,
> diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> index f324dc36fc43..c74ded2cabd2 100644
> --- a/kernel/sched/idle.c
> +++ b/kernel/sched/idle.c
> @@ -458,7 +458,9 @@ static void update_curr_idle(struct rq *rq)
>   * Simple, special scheduling class for the per-CPU idle tasks:
>   */
>  const struct sched_class idle_sched_class
> -       __attribute__((section("__idle_sched_class"))) = {
> +       __attribute__((section("__idle_sched_class")))
> +       __attribute__((aligned(__alignof__(struct sched_class)))) = {
> +
>         /* no enqueue/yield_task for idle tasks */
>
>         /* dequeue is not valid, we print a debug message there: */
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index f215eea6a966..002cdbfa5308 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2430,7 +2430,9 @@ static unsigned int get_rr_interval_rt(struct rq *rq, struct task_struct *task)
>  }
>
>  const struct sched_class rt_sched_class
> -       __attribute__((section("__rt_sched_class"))) = {
> +       __attribute__((section("__rt_sched_class")))
> +       __attribute__((aligned(__alignof__(struct sched_class)))) = {
> +
>         .enqueue_task           = enqueue_task_rt,
>         .dequeue_task           = dequeue_task_rt,
>         .yield_task             = yield_task_rt,
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index 28709f6b0975..42cf1e0cbf16 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -67,7 +67,6 @@
>  #include <linux/tsacct_kern.h>
>
>  #include <asm/tlb.h>
> -#include <asm-generic/vmlinux.lds.h>
>
>  #ifdef CONFIG_PARAVIRT
>  # include <asm/paravirt.h>
> @@ -1826,7 +1825,7 @@ struct sched_class {
>  #ifdef CONFIG_FAIR_GROUP_SCHED
>         void (*task_change_group)(struct task_struct *p, int type);
>  #endif
> -} __aligned(STRUCT_ALIGNMENT); /* STRUCT_ALIGN(), vmlinux.lds.h */
> +};
>
>  static inline void put_prev_task(struct rq *rq, struct task_struct *prev)
>  {
> diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
> index 394bc8126a1e..7bac6e0a9212 100644
> --- a/kernel/sched/stop_task.c
> +++ b/kernel/sched/stop_task.c
> @@ -110,7 +110,8 @@ static void update_curr_stop(struct rq *rq)
>   * Simple, special scheduling class for the per-CPU stop tasks:
>   */
>  const struct sched_class stop_sched_class
> -       __attribute__((section("__stop_sched_class"))) = {
> +       __attribute__((section("__stop_sched_class")))
> +       __attribute__((aligned(__alignof__(struct sched_class)))) = {
>
>         .enqueue_task           = enqueue_task_stop,
>         .dequeue_task           = dequeue_task_stop,



-- 
Thanks,
~Nick Desaulniers

  reply	other threads:[~2020-10-21 17:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29  0:31 [sched] c3a340f7e7: invalid_opcode:#[##] kernel test robot
2020-06-29  0:31 ` kernel test robot
2020-06-30 12:46 ` Peter Zijlstra
2020-06-30 12:46   ` Peter Zijlstra
2020-06-30 13:55   ` Rasmus Villemoes
2020-06-30 13:55     ` Rasmus Villemoes
2020-06-30 14:02     ` Peter Zijlstra
2020-06-30 14:02       ` Peter Zijlstra
2020-06-30 14:11       ` Peter Zijlstra
2020-06-30 14:11         ` Peter Zijlstra
2020-06-30 14:35       ` Peter Zijlstra
2020-06-30 14:35         ` Peter Zijlstra
2020-06-30 14:49   ` Peter Zijlstra
2020-06-30 14:49     ` Peter Zijlstra
2020-07-09  8:45     ` [tip: sched/core] sched, vmlinux.lds: Increase STRUCT_ALIGNMENT to 64 bytes for GCC-4.9 tip-bot2 for Peter Zijlstra
2020-10-20 23:39     ` [sched] c3a340f7e7: invalid_opcode:#[##] Florian Fainelli
2020-10-21  8:00       ` GCC section alignment, and GCC-4.9 being a weird one Peter Zijlstra
2020-10-21 13:18         ` Jakub Jelinek
2020-10-21 13:44           ` Peter Zijlstra
2020-10-21 17:42             ` Nick Desaulniers [this message]
2020-10-21 17:54               ` Miguel Ojeda
2020-10-21 18:35                 ` Joe Perches
2020-10-21 18:35                   ` [Linux-kernel-mentees] " Joe Perches
2020-10-21 19:27                   ` Miguel Ojeda
2020-10-21 19:27                     ` [Linux-kernel-mentees] " Miguel Ojeda
2020-10-22  7:38               ` Peter Zijlstra

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='CAKwvOd=qi63We=6rLapb565giCVe-8a6d=-=3VZL6RWzhwAeZg@mail.gmail.com' \
    --to=ndesaulniers@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=hjl.tools@gmail.com \
    --cc=jakub@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=lkp@intel.com \
    --cc=lkp@lists.01.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.