Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp631461rwd; Sat, 27 May 2023 04:08:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4biyLV4WWt11D9K5nVmfzVwJAt14IaFAy8cbGIwH8Q99jnjKU58gocYb4MwbuD1q9w5zJJ X-Received: by 2002:a05:6a21:328e:b0:10f:8798:9ffd with SMTP id yt14-20020a056a21328e00b0010f87989ffdmr2737883pzb.55.1685185699953; Sat, 27 May 2023 04:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685185699; cv=none; d=google.com; s=arc-20160816; b=dFoTRVySM6D3zJP/a8f8dN1dK08hLe6baU6GbA/fS3FGhTAVTXCi4dkWxUXTYbwFBw 9Gl3gxt3Ik+WDXuftFqj2V/CXG2Lo7zqrfMbER7N4kxYBkDzXrAS68X9Unwy28u9BoB0 RtCD1di/bb7hDyFlUZOuQm4/18GbvMzw4WfUGwzX3xo3py2BUzIovINwg9noadr7CO+j 7RYugjXxcghSPIg9bhQtSXrcpaJUlAIPCVDFriPTVebLHxiPxZQ1+i1morD3r58eqUN+ f8Yj3qJ7dzFjH7Ir0gSHY6OkbHacM2cGz426bRT20wOwfxXU40kYmdHIwW0IpY/MHuqu l3ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=DtV15axNIDqPdIs+cxeK3x1gW7VpQmKJASBWO5/b3no=; b=GStkJ2g2lRU6hLAw9Bhzz6fdfjMPTY9wxG0xw3FHGoqFBXk+pBRZWM+yxr8D8SWZ/C WK4VEpO0CPMniwv1DE3FVSNO6zAxb6Ht9qqnB6N7qgSjLvqYnTqCLaE70i6jbxyXVRHi 9VvWbF4D801at7wEX45jHJQos0kCa3qP7Y1/eYn01t8/d8i44e0EtTi2FiUKQEqdCIJ4 HWAo0+VqAbv2iZKXULczTtwWflujtZEhZY7AeCQzdZk/YmFNFU5UcVRnblP8W/Uzvlq5 BVE0nvgnV7f9+BZXYkngrXrkzmuKxt9jhrRq/iSpXM0YAYurKWKH1Y1wKYGYk/3AjTDV AxZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UABfiHUp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k130-20020a633d88000000b00528d0d8b7bbsi5534042pga.595.2023.05.27.04.08.07; Sat, 27 May 2023 04:08:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UABfiHUp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231967AbjE0K16 (ORCPT + 99 others); Sat, 27 May 2023 06:27:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjE0K14 (ORCPT ); Sat, 27 May 2023 06:27:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3FC7F7; Sat, 27 May 2023 03:27:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6C9C660AED; Sat, 27 May 2023 10:27:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A52F2C433EF; Sat, 27 May 2023 10:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685183273; bh=C+WzGt1q9d0lH05NNK05+tR4vVIYrPDgEpHVAqLkZAc=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=UABfiHUpb+nRYDT82tFdgWn3aMX4jyrsJFbjdNZp++nQO53C2VDYOfdSmmzOFGX10 Gh/BhqAouZ92Z/rYXq27XJu7/rgJNF2MkSFSqTbSJat111F0GD+XJxQoq0IHyJKxqR FCaamDN9nZlJJrnYyTG00nvRB6FT9LCP97PJpVER8LAj50EuN9UpO0+DcbN7ZI1pVy DC3PF50Olhqx0pZY7UB5Qe6yRAbRLScp51QFKGEtCFt0II6XroAms62KcyQCRCmyXW VzyRHC05Tn/N5JAAV9EgqTAnRlfP930lTzMP129hjSUI3mIrs1mBFl4wfdc/qsKFqL Ae6nCyHaGb7vg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D5FB7CE0DB0; Sat, 27 May 2023 03:27:50 -0700 (PDT) Date: Sat, 27 May 2023 03:27:50 -0700 From: "Paul E. McKenney" To: Chen-Yu Tsai Cc: Lai Jiangshan , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno , =?iso-8859-1?Q?N=EDcolas_F_=2E_R_=2E_A_=2E?= Prado , "Rafael J. Wysocki" Subject: Re: [PATCH] notifier: Initialize new struct srcu_usage field Message-ID: Reply-To: paulmck@kernel.org References: <20230526073539.339203-1-wenst@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230526073539.339203-1-wenst@chromium.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 26, 2023 at 03:35:37PM +0800, Chen-Yu Tsai wrote: > In commit 95433f726301 ("srcu: Begin offloading srcu_struct fields to > srcu_update"), a new struct srcu_usage field was added, but was not > properly initialized. This led to a "spinlock bad magic" BUG when > the SRCU notifier was ever used. This was observed in the MediaTek > CCI devfreq driver on next-20230525. Trimmed stack trace as follows: > > BUG: spinlock bad magic on CPU#4, swapper/0/1 > lock: 0xffffff80ff529ac0, .magic: 00000000, .owner: /-1, .owner_cpu: 0 > Call trace: > spin_bug+0xa4/0xe8 > do_raw_spin_lock+0xec/0x120 > _raw_spin_lock_irqsave+0x78/0xb8 > synchronize_srcu+0x3c/0x168 > srcu_notifier_chain_unregister+0x5c/0xa0 > cpufreq_unregister_notifier+0x94/0xe0 > devfreq_passive_event_handler+0x7c/0x3e0 > devfreq_remove_device+0x48/0xe8 > > Add __SRCU_USAGE_INIT() to SRCU_NOTIFIER_INIT() so that srcu_usage gets > initialized properly. > > Fixes: 95433f726301 ("srcu: Begin offloading srcu_struct fields to srcu_update") > Signed-off-by: Chen-Yu Tsai Good catch, thank you! Reviewed-by: Paul E. McKenney > --- > > Also, the original patch subject said "srcu_update", however the data > structure ended up as "srcu_usage". Maybe that could be updated? > > include/linux/notifier.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/include/linux/notifier.h b/include/linux/notifier.h > index 2aba75145144..86544707236a 100644 > --- a/include/linux/notifier.h > +++ b/include/linux/notifier.h > @@ -106,12 +106,22 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); > #define RAW_NOTIFIER_INIT(name) { \ > .head = NULL } > > +#ifdef CONFIG_TREE_SRCU > #define SRCU_NOTIFIER_INIT(name, pcpu) \ > { \ > .mutex = __MUTEX_INITIALIZER(name.mutex), \ > .head = NULL, \ > + .srcuu = __SRCU_USAGE_INIT(name.srcuu), \ > .srcu = __SRCU_STRUCT_INIT(name.srcu, name.srcuu, pcpu), \ > } > +#else > +#define SRCU_NOTIFIER_INIT(name, pcpu) \ > + { \ > + .mutex = __MUTEX_INITIALIZER(name.mutex), \ > + .head = NULL, \ > + .srcu = __SRCU_STRUCT_INIT(name.srcu, name.srcuu, pcpu), \ > + } > +#endif > > #define ATOMIC_NOTIFIER_HEAD(name) \ > struct atomic_notifier_head name = \ > -- > 2.41.0.rc0.172.g3f132b7071-goog >