From: Peter Zijlstra <peterz@infradead.org>
To: Stafford Horne <shorne@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
Marco Elver <elver@google.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Mike Rapoport <rppt@linux.ibm.com>,
Sami Tolvanen <samitolvanen@google.com>
Subject: Re: [PATCH] init: Align init_task to avoid conflict with MUTEX_FLAGS
Date: Fri, 26 Jun 2020 13:12:08 +0200 [thread overview]
Message-ID: <20200626111208.GD4817@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200625204410.3168791-1-shorne@gmail.com>
On Fri, Jun 26, 2020 at 05:44:09AM +0900, Stafford Horne wrote:
> When booting on 32-bit machines (seen on OpenRISC) I saw this warning
> with CONFIG_DEBUG_MUTEXES turned on.
> I traced this to kernel/locking/mutex.c storing 3 bits of MUTEX_FLAGS in
> the task_struct pointer (mutex.owner). There is a comment saying that
> task_structs are always aligned to L1_CACHE_BYTES. This is not true for
> the init_task.
>
> On 64-bit machines this is not a problem because symbol addresses are
> naturally aligned to 64-bits providing 3 bits for MUTEX_FLAGS. Howerver,
> for 32-bit machines the symbol address only has 2 bits available.
>
> Fix this by setting init_task alignment to at least L1_CACHE_BYTES.
Whoopsie, sorry about that.
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Stafford Horne <shorne@gmail.com>
> ---
> init/init_task.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/init/init_task.c b/init/init_task.c
> index 15089d15010a..d2d2af018d0d 100644
> --- a/init/init_task.c
> +++ b/init/init_task.c
> @@ -64,6 +64,8 @@ unsigned long init_shadow_call_stack[SCS_SIZE / sizeof(long)]
> struct task_struct init_task
> #ifdef CONFIG_ARCH_TASK_STRUCT_ON_STACK
> __init_task_data
> +#else
> + __aligned(L1_CACHE_BYTES)
> #endif
Why make this conditional? task_struct_cachep (in kernel/fork.c) has
max_t(int, L1_CACHE_BYTES, ARCH_MIN_TASKALIGN) alignment, so this really
should be aligned on L1_CACHE_BYTES at least.
next prev parent reply other threads:[~2020-06-26 11:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 20:44 [PATCH] init: Align init_task to avoid conflict with MUTEX_FLAGS Stafford Horne
2020-06-26 11:12 ` Peter Zijlstra [this message]
2020-06-26 11:45 ` Stafford Horne
2020-06-26 13:11 ` 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=20200626111208.GD4817@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=ebiederm@xmission.com \
--cc=elver@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@kernel.org \
--cc=rppt@linux.ibm.com \
--cc=samitolvanen@google.com \
--cc=shorne@gmail.com \
--cc=tglx@linutronix.de \
/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