Message ID | 20230526073539.339203-1-wenst@chromium.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp291637vqr; Fri, 26 May 2023 00:43:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7pG30AyIwxnJMi/HkyTeixLVfdgS1enPC35a6REcrVuD+QTuOGCoVyq0T9GKqKuriHwIzn X-Received: by 2002:a17:903:230e:b0:1b0:4a2:590f with SMTP id d14-20020a170903230e00b001b004a2590fmr2146816plh.28.1685087028248; Fri, 26 May 2023 00:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685087028; cv=none; d=google.com; s=arc-20160816; b=MfrPupxHyHuxDouC0qdcX47YFcr9H38CCufnU1TmOqYxBIW6kugaOsj8hfxTYCrall c3MHaz3I4yUPWPA11kahacBAIocjjGcNLYSPdhbU8xz+2kNvRwfI2iw5Y1z3d08w/rzU iY4Xp0cbVZ0iQXyNRgVjwM1/oiNSpbHGKtxlwG2UoS3weOcT3pB1CkqXo6jwrf/evYvl MX/brfMZRUEiN6gBT7hLtKEqle4J5uB03u2074Poduq/rD8OgHI8GoLx+11n81OT2Yom 6wn2JxO+8M60MzZawZQY+Pt9Zo8nYe/J6gLClpEzRzzSYLctsHh6dDRKw3itysX8u6QZ AuIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bKWBdp4Kjo2s7gwqdnwE3qAnKBZlQrDQ7Bhod2F0iec=; b=g/Hfn9mqUrLIdqAPRR9+heDATn9EtOo6Fw2SeYFeuvEIdx5NMUWYnxWrLaUWwmJy7P hm59nFNXCBTFkOvS5O4ZpLTWDoAA+o6voSSqryKiSTwwl5nRewqXo602XG5n9jb2cu4I t/AdzOcdVJVJ0aSeh2hDdPvQwKluPc9bS4ah/5Uw/JR/49bgHutda2gJ6N8DJjIbdN6s N0Mt2zgR1tshs23NUX67XAR/o3M4E6jFogj8n8MsjYb9NAvrf14Au27k2k8Dv2MugsYA 7mHv/DtoOxU3vAjamrqEigsBMWr8wYtMhMTORNh7gfXWaWmEO4UByYYSacR8fWZx4I05 fYZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gq7rzjt3; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a170902c18900b001a644fba6d8si3256390pld.86.2023.05.26.00.43.33; Fri, 26 May 2023 00:43:48 -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=@chromium.org header.s=google header.b=gq7rzjt3; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242221AbjEZHgt (ORCPT <rfc822;zhanglyra.2023@gmail.com> + 99 others); Fri, 26 May 2023 03:36:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242192AbjEZHgY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 26 May 2023 03:36:24 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 706E710E9 for <linux-kernel@vger.kernel.org>; Fri, 26 May 2023 00:35:55 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ae40dcdc18so3088895ad.2 for <linux-kernel@vger.kernel.org>; Fri, 26 May 2023 00:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685086548; x=1687678548; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bKWBdp4Kjo2s7gwqdnwE3qAnKBZlQrDQ7Bhod2F0iec=; b=gq7rzjt3t/xc/7eKsys5HW5xi/ugBh+XpYqENlPCR35jv7yZFm4s7ACeAfsR8ZgZ75 cREmmzeZlILrUfAxYs5br/wSOosq5qXbbv3FnLu+3Gl8HlgaO7BYPhDaYuiXQvxosJuq w2UHiHQlSkVqtn9VBIu8kKzw3hhA0oituZDRY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685086548; x=1687678548; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bKWBdp4Kjo2s7gwqdnwE3qAnKBZlQrDQ7Bhod2F0iec=; b=aqKeN6gv1YjL6rNd3CupvK2LXiXQwvpTSwEad4rfJJysTfisEfca2fsuJ7oy6nQD4t xmUmQkaa6uSNeNuYFEnmwWXyvXaWwmwewY61YVnmaNgADUFXKxm3UsT0g/qc3awHEylY wz9w8hd2yl1cH+HhWYjfAI+X5noK1LmxNsSJAVc1JPyIYqNArE80okdP3KTVGvLpDL57 s15cOFSmeburqRCf7F79RstUnkzWTECVQJIYUhfqP9C9fm0zWTrQYAllKCpR9SYp8PUO 7SvqBsLPfGlfSCjFnfTzPdMPhGOcPE8GQhO9nsbri1dmceHA3i9MFADnDcLK182SHSIf 397Q== X-Gm-Message-State: AC+VfDzOaBbCDDL8r3s2RdlgYFwcUche8w3SszWyLdxlkL6qb2oViSA0 Flj0waeaVcOxuHPdV3xXq57A7Q== X-Received: by 2002:a17:903:228a:b0:1a2:3108:5cc9 with SMTP id b10-20020a170903228a00b001a231085cc9mr1674737plh.40.1685086548637; Fri, 26 May 2023 00:35:48 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:17b9:e0b5:a956:4510]) by smtp.gmail.com with ESMTPSA id l9-20020a170902eb0900b001ac78ac2cafsm2573408plb.239.2023.05.26.00.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:35:48 -0700 (PDT) From: Chen-Yu Tsai <wenst@chromium.org> To: Lai Jiangshan <jiangshanlai@gmail.com>, "Paul E. McKenney" <paulmck@kernel.org>, Josh Triplett <josh@joshtriplett.org>, Steven Rostedt <rostedt@goodmis.org>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Chen-Yu Tsai <wenst@chromium.org>, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= <nfraprado@collabora.com>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Subject: [PATCH] notifier: Initialize new struct srcu_usage field Date: Fri, 26 May 2023 15:35:37 +0800 Message-ID: <20230526073539.339203-1-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766941815771098325?= X-GMAIL-MSGID: =?utf-8?q?1766941815771098325?= |
Series |
notifier: Initialize new struct srcu_usage field
|
|
Commit Message
Chen-Yu Tsai
May 26, 2023, 7:35 a.m. UTC
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: <none>/-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 <wenst@chromium.org>
---
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(+)
Comments
Il 26/05/23 09:35, Chen-Yu Tsai ha scritto: > 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: <none>/-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 <wenst@chromium.org> Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
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: <none>/-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 <wenst@chromium.org> Good catch, thank you! Reviewed-by: Paul E. McKenney <paulmck@kernel.org> > --- > > 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 >
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 = \