Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp531742ybt; Fri, 26 Jun 2020 05:35:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrMZwjDidfi4fYzokUZVGt5LJkRTmwMbJps7lvRD9aWlbLHp71cfOC/wYi023qVeiTN9Cu X-Received: by 2002:a17:906:2581:: with SMTP id m1mr2528496ejb.89.1593174958130; Fri, 26 Jun 2020 05:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593174958; cv=none; d=google.com; s=arc-20160816; b=YZICqC+8tEIa3d2xip50uA9n7hRrXc45fKQqu1VI62JS3mPWHl068vtD2Vu6uehSXP KpHyiDNa7lNxaDD0767XZSLmZ5NyIiRTOfcSx8ovISx68JSkZklrwBrEeRCdUVkt4l4U l1qWOupmO4Eu+le7u1W8DTqeChqYN/Pxm7A/3R+PtmwYXEbj357Wrc07QQdROBBF4ZwR ysaBubHDiK8m7EDAMio7sIzCkFy31eaVszP+v81aB5DLbf3LsEe46AiOrT/19MHL7mS2 3mRLCh2wI3qQONaQF4vjbq6ec4a7IW+0MWzNg0kZ+KwbBAA+LBVmVJmFvWxavR4Iha+W K/+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Uemf3Wf/R6czU5LxRGz5sapyQc/xnDzfVNcAquTwxq8=; b=Zlv1QTZgMetFdDpQB4Kw/qx+3+OF2dV8TZpSMJ604Rf6v6FQvf09uZuY4RX+EXkeeA LX3cts3DJaX8RHVx3oQ5jFaqHxyC1AYjOxfymMi8MnsQKjhN7bxHh7zDvTNvGMbNYR40 VpGfSeOCJJ3JDeNg8VUAa1atgXJAeZACySgBh5TVSVZtlJnODHChUvIEQUN0HUnZ3jhe H3cYtGr6yv2V+1vJFt985oV1NOndJX2hPIT/OiTovj1Ml83dQbrRreYzA/N5pj1RPmpI cn557W/n30D2zYqHn5SQ2EoHIWYtI8JW95M+N0rYruj2oTfJSmj0Q0OdUdW5WjYGaoy3 FNAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RSrvVyf3; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lu24si9985048ejb.477.2020.06.26.05.35.35; Fri, 26 Jun 2020 05:35:58 -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=@gmail.com header.s=20161025 header.b=RSrvVyf3; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726999AbgFZLp1 (ORCPT + 99 others); Fri, 26 Jun 2020 07:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725836AbgFZLp0 (ORCPT ); Fri, 26 Jun 2020 07:45:26 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B486C08C5C1 for ; Fri, 26 Jun 2020 04:45:26 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id g67so3954384pgc.8 for ; Fri, 26 Jun 2020 04:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Uemf3Wf/R6czU5LxRGz5sapyQc/xnDzfVNcAquTwxq8=; b=RSrvVyf3Eb1DB8S5lB2jO3n7h84pb7nmU/W6ydX/b61Gg+ZpFaPJDhOz5kS0lOW4Ci WwRHOILqA2kbYdwszqlEV7whL9Srgk7EvCEuzjWpOhrEWE38Yi1jvF0EpmBN3zhnJNf7 lBcs2+PEze92bpepa4yTtaeKhBzjvqy1sJ/gzRRffVX+KmmF9GG0KZF3za5197kyW6h6 KOfbeY9zW7/Ulj/DYwG97R80GG4yLiQNXmS40kJrvda1Gujecob6C0h2FnJWTz0Bp1OJ wUCs5zb7wLTb24OJ2s6ITXuE8n9rfo47UkLFK6lTxs/y+LE2CUnsBD546Bh3Dn4JDTqF hY0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Uemf3Wf/R6czU5LxRGz5sapyQc/xnDzfVNcAquTwxq8=; b=LesiDufWniTfVP2B2HLO7nee9xWzlegfgU5t2spMqMyZKslUXSSzzdEwKCbofIeP2o iwVADxHfBIv3s5QaIjvRxgJnZ/gng3i7NS6xUBMEhaDUldQY3iot63iat3Yrxx55wzg0 G00S17ABOkWyC263XodSPPXeQzovr16D+XcsLm2fGYt9WEC2X1/UJZY00RuG6FbTHf2g mH4+Tvov59zSlmqcH4WsSb+f2ZhJjo7v0FqinTDlUsGoAzLDOeaCT6rdqUePk083Ea11 CUP7iz5mvZyDItAxgOGIe7YxUL8/xmA4S7KDtYHg4vuyXCORhqgt5E9j/DsXw69s8bce qjeQ== X-Gm-Message-State: AOAM532C8ovJu4LHjRripVzEff5jK0KyDvkicvW1GaA6g7Ll2mW33elB 6Tadxy2cLxPn6YoDCiGWKns= X-Received: by 2002:a63:1104:: with SMTP id g4mr2323128pgl.369.1593171925472; Fri, 26 Jun 2020 04:45:25 -0700 (PDT) Received: from localhost (g2.222-224-226.ppp.wakwak.ne.jp. [222.224.226.2]) by smtp.gmail.com with ESMTPSA id v13sm11679520pjd.9.2020.06.26.04.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 04:45:24 -0700 (PDT) Date: Fri, 26 Jun 2020 20:45:22 +0900 From: Stafford Horne To: Peter Zijlstra Cc: LKML , "Paul E. McKenney" , Marco Elver , "Eric W. Biederman" , Ingo Molnar , Thomas Gleixner , Mike Rapoport , Sami Tolvanen Subject: Re: [PATCH] init: Align init_task to avoid conflict with MUTEX_FLAGS Message-ID: <20200626114522.GI1401039@lianli.shorne-pla.net> References: <20200625204410.3168791-1-shorne@gmail.com> <20200626111208.GD4817@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200626111208.GD4817@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 26, 2020 at 01:12:08PM +0200, Peter Zijlstra wrote: > 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 > > Signed-off-by: Stafford Horne > > --- > > 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. I think we can make this unconditional. The only reason I used the condition is because the only architecture that sets CONFIG_ARCH_TASK_STRUCT_ON_STACK is ia64 which already has 64-bit alignment. I can change it to (not incorporating max_t(ARCH_MIN_TASKALIGN) as not sure how): diff --git a/init/init_task.c b/init/init_task.c index 15089d15010a..ab6173f8e6a8 100644 --- a/init/init_task.c +++ b/init/init_task.c @@ -65,6 +65,7 @@ struct task_struct init_task #ifdef CONFIG_ARCH_TASK_STRUCT_ON_STACK __init_task_data #endif + __aligned(L1_CACHE_BYTES) = { #ifdef CONFIG_THREAD_INFO_IN_TASK .thread_info = INIT_THREAD_INFO(init_task), -Stafford