[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202110052146.D639C70@keescook>
Date: Tue, 5 Oct 2021 21:48:51 -0700
From: Kees Cook <keescook@...omium.org>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>
Cc: x86@...nel.org, Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] sched: task_struct: Fill unconditional hole induced by
sched_entity
On Thu, Sep 23, 2021 at 07:54:50PM -0700, Kees Cook wrote:
> With struct sched_entity before the other sched entities, its alignment
> won't induce a struct hole. This saves 64 bytes in defconfig task_struct:
Friendly ping. Can someone snag this for -tip please?
Thanks!
-Kees
>
> Before:
> ...
> unsigned int rt_priority; /* 120 4 */
>
> /* XXX 4 bytes hole, try to pack */
>
> /* --- cacheline 2 boundary (128 bytes) --- */
> const struct sched_class * sched_class; /* 128 8 */
>
> /* XXX 56 bytes hole, try to pack */
>
> /* --- cacheline 3 boundary (192 bytes) --- */
> struct sched_entity se __attribute__((__aligned__(64))); /* 192 448 */
> /* --- cacheline 10 boundary (640 bytes) --- */
> struct sched_rt_entity rt; /* 640 48 */
> struct sched_dl_entity dl __attribute__((__aligned__(8))); /* 688 224 */
> /* --- cacheline 14 boundary (896 bytes) was 16 bytes ago --- */
>
> After:
> ...
> unsigned int rt_priority; /* 120 4 */
>
> /* XXX 4 bytes hole, try to pack */
>
> /* --- cacheline 2 boundary (128 bytes) --- */
> struct sched_entity se __attribute__((__aligned__(64))); /* 128 448 */
> /* --- cacheline 9 boundary (576 bytes) --- */
> struct sched_rt_entity rt; /* 576 48 */
> struct sched_dl_entity dl __attribute__((__aligned__(8))); /* 624 224 */
> /* --- cacheline 13 boundary (832 bytes) was 16 bytes ago --- */
>
> Summary diff:
> - /* size: 7040, cachelines: 110, members: 188 */
> + /* size: 6976, cachelines: 109, members: 188 */
>
> Signed-off-by: Kees Cook <keescook@...omium.org>
> ---
> include/linux/sched.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 39039ce8ac4c..27ed1d40028f 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -775,10 +775,10 @@ struct task_struct {
> int normal_prio;
> unsigned int rt_priority;
>
> - const struct sched_class *sched_class;
> struct sched_entity se;
> struct sched_rt_entity rt;
> struct sched_dl_entity dl;
> + const struct sched_class *sched_class;
>
> #ifdef CONFIG_SCHED_CORE
> struct rb_node core_node;
> --
> 2.30.2
>
--
Kees Cook
Powered by blists - more mailing lists