Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1075394ybt; Wed, 1 Jul 2020 18:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdx3OblQkCjh0Y4G0P9c9oeY5AkY4CPOgxVsb3Y+2Yta9+7XI4ELDt90uU4sfoYujO63+Y X-Received: by 2002:a50:ce45:: with SMTP id k5mr32685193edj.80.1593652229629; Wed, 01 Jul 2020 18:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593652229; cv=none; d=google.com; s=arc-20160816; b=Iywko+lM2cyQPJJXRizaJJNcGVbaOKW/Fi9nrtIl+YrASsaazuB4F4HWA5hZ36HCvn Iicyt+Mk2S+Ui8Lcq5Viju3IUxSlMSfbSWkXH2D1zkhsiaWl1mQEzvZ9EI7V+kR65EgA 57YCzVEaAsoML13qxOuf8wERAy4TSBUz00JduRFEDfq4KN1qe24pTyK7GIDiRAnuf37s ex/SWVRkmkFwUrVNpw0SEQYgaZXMcNENpAPYvhTUlp9GM2LVPg3Nn5ABFi2zlYHykKd0 PwcFellnVfIdHbU+cj0VS8NqGbmzj1eI0EedukzenwPeEvfiGmtzOqbW8W3JrKNNLwvM vYog== 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=PQEQS5p/+RjzH0qq3BBrpSd3Alq89nsezpjkTzvw95k=; b=JSQN873HiHZrk/aA2e/xXRFt3bHxMu5me0N/8TTPpWw/N62b7Lik3BdP2XN3PzRW7+ +kvzOmVaZ2MCphA+Qqz/Bg/Rl4DYqggONMi4qLn1cCUAlDqro+LeZycbBvj4CdsaoM7T 32mcrFrmhVRD0fU2lIWPhgTMzpDq1g6nqPYLCqRHBZ3aYbaXJFuKbMW2btIMSdJvW+/L 2JbYXq+bcNO0BjRoeRS9Egnxhzs/Q2RRJUEBQ7SvObdY8t2e8fJQj7h2kYE1lPla1Ywm LkmqMSUrqj2bme5bCVPVpPTZyOzqOxNlKEgkwAbQrsYoNMZKt1hQlqobJESrcFmSUhdG AJZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ibma5St4; 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 fi17si4596855ejb.724.2020.07.01.18.10.06; Wed, 01 Jul 2020 18:10:29 -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=ibma5St4; 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 S1727008AbgGBBJU (ORCPT + 99 others); Wed, 1 Jul 2020 21:09:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726637AbgGBBJT (ORCPT ); Wed, 1 Jul 2020 21:09:19 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F00AC08C5C1 for ; Wed, 1 Jul 2020 18:09:19 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id d194so9233407pga.13 for ; Wed, 01 Jul 2020 18:09:19 -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=PQEQS5p/+RjzH0qq3BBrpSd3Alq89nsezpjkTzvw95k=; b=ibma5St4sQQTI9fxuFS0Dl7IZc8oEUi1BtXgEPoNq0mIUKKf6Z7R/XGy92KtWrffNx vYC7ca34d+sedvj+8yLJJjmmAtKQ7Om73FWsFK8snVXdXZLADKVpt95SGNnCVHVOtepK yZwoBb7sagKD2u9Y+bfGSftDf7Jbl/M9AMeGb+yUeBfJleUUdCPHLJtEIAK8pqTyU+wu FYp0cWoqDFNDSW/Eim+PVm7nyCQMSlL24X9Fyx8kwI23/O1LYG5WET531b4Cwf8e6YRG amHHtY7MN+qSSHVjCKKnAG+9U9ELgiNpUsbnaWGFvUMFv4QUJZnBtuOWgsFQNX+iXZA+ 6BpQ== 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=PQEQS5p/+RjzH0qq3BBrpSd3Alq89nsezpjkTzvw95k=; b=mmqfFO0ubL/qGjtkJUpziTyly0jx3v1StMHBSYPW+d1/aMDO9G55KsfmBm1JX5kk6p Od6UX/NrxVhYzrEWp/dqq+C64j1JTAigjryYRj/vRPoAQBMVh+/sy7oFuSeWEC3jOIcS AS6pz3VRl9jcosCuYvLvEWU+mw07jyWI2IUH9xlo8ipHRNFiK5X9qdBxiCcdkRQdQwuW iCPrnHpnjlOuaDEIi4nQ9jsbCYAWLsqFDqjglqfpX26f1xNggeQYCgfW6W5sTd99EKM5 B5ito77Fn6P8W/0Fg3Cg0+2+YsvBgBV042x5zrwJo9KvAToby+UMXplcy9DvG/Q21cqW ss7A== X-Gm-Message-State: AOAM533+XeEEL9Gh7kIPKQ2VP9wHIji/U0WYcPzFMkR1fLNCpmHJGl12 U8g3XdgUHD+OYu4mKGOIFVWBhqDt X-Received: by 2002:a63:8ec2:: with SMTP id k185mr21573323pge.331.1593652158591; Wed, 01 Jul 2020 18:09:18 -0700 (PDT) Received: from localhost (g2.222-224-226.ppp.wakwak.ne.jp. [222.224.226.2]) by smtp.gmail.com with ESMTPSA id az16sm6091434pjb.7.2020.07.01.18.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 18:09:17 -0700 (PDT) Date: Thu, 2 Jul 2020 10:09:10 +0900 From: Stafford Horne To: LKML Cc: Peter Zijlstra , "Paul E. McKenney" , Marco Elver , "Eric W. Biederman" , Ingo Molnar , Thomas Gleixner , Mike Rapoport , Sami Tolvanen Subject: Re: [PATCH v2] init: Align init_task to avoid conflict with MUTEX_FLAGS Message-ID: <20200702010910.GA3545817@lianli.shorne-pla.net> References: <20200626210754.3338389-1-shorne@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200626210754.3338389-1-shorne@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Is there anyone willing to pick this up? I guess I could send it in the OpenRISC queue, but it doesn't really seem like the right thing. -Stafford On Sat, Jun 27, 2020 at 06:07:53AM +0900, Stafford Horne wrote: > When booting on 32-bit machines (seen on OpenRISC) I saw this warning > with CONFIG_DEBUG_MUTEXES turned on. > > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 0 at kernel/locking/mutex.c:1242 __mutex_unlock_slowpath+0x328/0x3ec > DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current) > Modules linked in: > CPU: 0 PID: 0 Comm: swapper Not tainted 5.8.0-rc1-simple-smp-00005-g2864e2171db4-dirty #179 > Call trace: > [<(ptrval)>] dump_stack+0x34/0x48 > [<(ptrval)>] __warn+0x104/0x158 > [<(ptrval)>] ? __mutex_unlock_slowpath+0x328/0x3ec > [<(ptrval)>] warn_slowpath_fmt+0x7c/0x94 > [<(ptrval)>] __mutex_unlock_slowpath+0x328/0x3ec > [<(ptrval)>] mutex_unlock+0x18/0x28 > [<(ptrval)>] __cpuhp_setup_state_cpuslocked.part.0+0x29c/0x2f4 > [<(ptrval)>] ? page_alloc_cpu_dead+0x0/0x30 > [<(ptrval)>] ? start_kernel+0x0/0x684 > [<(ptrval)>] __cpuhp_setup_state+0x4c/0x5c > [<(ptrval)>] page_alloc_init+0x34/0x68 > [<(ptrval)>] ? start_kernel+0x1a0/0x684 > [<(ptrval)>] ? early_init_dt_scan_nodes+0x60/0x70 > irq event stamp: 0 > > 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. > > Signed-off-by: Stafford Horne > Acked-by: Peter Zijlstra (Intel) > --- > Changes since v1: > - Make alignment unconditional suggested by Peter > > init/init_task.c | 1 + > 1 file changed, 1 insertion(+) > > 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), > -- > 2.26.2 >