Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5531221pxu; Thu, 22 Oct 2020 05:02:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7w1CgjpplpNBgnmsdBbOujN/yNMXq53EHM/pk3yf9iOKs3SP0frNFtSw9LR8h6F+MuV/Q X-Received: by 2002:a17:907:40c0:: with SMTP id nu24mr1972395ejb.359.1603368177688; Thu, 22 Oct 2020 05:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603368177; cv=none; d=google.com; s=arc-20160816; b=nPuhmo67YX8mOkgFwynGQ51zLmS+og3jq9Qn+pT+CDI+sekVDx8fTgI8+Aos7TOit2 6FpJJd+APrlRdl02mYzAikRdjC9f6O5DaOJ06Ka6p+k6hDaZyDGYstbjZywGYJLLSJPs JiQGsh5LYHQvp3KS43+pGYZN98O/AS0+wK2bNNzrDe1wIeAPRowdmMexSyBaHZjBTy+6 xK3SlVNBqhQi/82YB51JtVmweQwBRn17FmObuthgMeY4O0dgm+NfAk0dCt3WPcCYaXjA znWwLde8f1AJ/tg1t8lL4pW4RmsWmM/n0myIEp5QjQnkYDyYrE4d7txyydN6xQ1uHUIg ZA4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=215/ymy+uvftzLr1t80NNKG87+/NQw0X6pRjkxN1Tp0=; b=oirBfzosYj22wEBDm5plzCbhbdmb702bUbDrcS/TdCg6WTk8LuuBrQSi7Bs/o/0cDJ FTzwe8BUVktR0iG1zxBms18RWMSsIXJp7Y6jqO5chVCY5Lgki7Qhy5VH3K/rteMtE9QW SuhEUGwzEUmAa+SRRgsi6Slf+bmLO/f8ipcdYf63IOz5ivRcsGepdmUkq9QcNpM9oaDo wAA2WMI92o90lFG2nxENQrlt5uzr9FnvW/FgTh51pEUoLooyLDlBd4as2QHfDZvStGRi 9A+p+qOSm1+nr1djnXr0uE1esQw4WD+UotKxpepwNEZdypq+z5Yf75pAP6O/M8S8GDX7 hnYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L1OKuBHV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id me10si663928ejb.753.2020.10.22.05.02.31; Thu, 22 Oct 2020 05:02:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L1OKuBHV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503667AbgJURmP (ORCPT + 99 others); Wed, 21 Oct 2020 13:42:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503364AbgJURmP (ORCPT ); Wed, 21 Oct 2020 13:42:15 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B636CC0613CE for ; Wed, 21 Oct 2020 10:42:13 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a17so1529181pju.1 for ; Wed, 21 Oct 2020 10:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=215/ymy+uvftzLr1t80NNKG87+/NQw0X6pRjkxN1Tp0=; b=L1OKuBHV+BBkBNrKbPhmgmqYgykKnT0+FERP1DWY2Gje3PJfaREB3N3jED10ItpnNa 3vTnxl3mpgFZ2pPzm+XH9cxpAQEVzHfgg/hQP6cqjb/v7DqQKcdh9rQA4Oz+gj4y2GIh sGyc3JLA02C/HZEOW+Y+Jycn8NZZAwewL4KTQKzntsN0kcpdjajOkaUpc6i1blndJlcr ImaMKnaZwV/4FtHUjsIrSN3laM9q/HqCSkMB8cY4WDdp/CUEwXmdcEfGzdvjsG789kVC hX0Y2cRDAyZHSE/3NNQeHlde3dZMRb1fs41mK6Utm+seEmN9zjMGHSWac9St7srw2Cm5 rgfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=215/ymy+uvftzLr1t80NNKG87+/NQw0X6pRjkxN1Tp0=; b=al5Rsh3+U1SA0keVQdPrrFxjdghL97inCPeETnLpOcFifQey5IDYr9hJknI8/abxV/ JwBjRt7DWIq6oeZ4HYyORoW4P/kX41F7vEOyBBqk00KBd6K33NfSYmMBSzISdoO3Ykt3 abJIf1ky+cFhm/M73GulpuHA+gEaeAlNoxVcLCTNq7WZJSMpRCVXmaf9o2BXjbjoew9d hFfdVTyS2GA6ortXg6bgOQCeOnQZOJ14TDGiTXKKzazvD3sPwJlUSa3ofpmJOjfSL7qF uwj61008jw04UN4DCQ8tWc039qoQUgNqCDBOBonmDK7+XONkcwf6d07StkYUM3jp5vTd QMAQ== X-Gm-Message-State: AOAM5321XtGEOpDTU+9b7L8+HVW6UvZHUzKEiSmTbp6HuHjHY8IV8v65 AOHfbFhEEN60J8kkouEgTP/ol8hHtC4gTamMczGbuw== X-Received: by 2002:a17:902:c40b:b029:d3:def2:d90f with SMTP id k11-20020a170902c40bb02900d3def2d90fmr4661882plk.29.1603302132985; Wed, 21 Oct 2020 10:42:12 -0700 (PDT) MIME-Version: 1.0 References: <20200629003127.GB5535@shao2-debian> <20200630124628.GV4817@hirez.programming.kicks-ass.net> <20200630144905.GX4817@hirez.programming.kicks-ass.net> <58ff47cc-dc55-e383-7a5b-37008d145aba@gmail.com> <20201021080031.GY2628@hirez.programming.kicks-ass.net> <20201021131806.GA2176@tucnak> <20201021134436.GJ2628@hirez.programming.kicks-ass.net> In-Reply-To: <20201021134436.GJ2628@hirez.programming.kicks-ass.net> From: Nick Desaulniers Date: Wed, 21 Oct 2020 10:42:01 -0700 Message-ID: Subject: Re: GCC section alignment, and GCC-4.9 being a weird one To: Peter Zijlstra Cc: Jakub Jelinek , Florian Fainelli , kernel test robot , Steven Rostedt , LKML , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , LKP , Kees Cook , "H.J. Lu" , Rasmus Villemoes , linux-toolchains@vger.kernel.org, Miguel Ojeda Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 21, 2020 at 6:45 AM Peter Zijlstra 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 > > #include > -#include > > #ifdef CONFIG_PARAVIRT > # include > @@ -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