Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp293970pxj; Thu, 10 Jun 2021 00:28:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4LQojXpSqhBJsXy42Y4KxUBLZbQfaxQuC3P1bOHwdrE0ZShKSCfoD4IfRJ4GyUXWPhTCo X-Received: by 2002:a17:906:76d2:: with SMTP id q18mr3196951ejn.294.1623310107790; Thu, 10 Jun 2021 00:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623310107; cv=none; d=google.com; s=arc-20160816; b=YlK0121dWRZP1ymNK9l8zLa8DsvN+A09RNtCy7hayoIwSmM/FW+X7dIghI2DN2AX7x 5fDvniQBjoycDvvYm5qOTcFjCDm55imxMx9wCLpndsGIDeoYdDN3cSsFnU/Ysn+iHLTl ZC/6Y4bJwme5IGAayvnu+o1fjIYWQpnGYtXplYM3V2eHHRbzEofjKKYdmSTIFWc3KEQs tHCyB4NMBO3uzOy5brqTmUo3nGyGK6/Zbtm00WKiwH9xif+zaXJCvWJKtoEzlYiTsrp0 aCqX9Ylji8S3GIDy6xlbJ3nQddf1sJBVW723ZAvlE54ldmE1smWaK35Hacb3Mi+6gsTj Xong== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=oxiMhTHq4oUQKeM/Uzcvp4BPBEXwx0csMPIqc3DCF6A=; b=kIO/B8WYBoTEPoVT+SNfTWZPjcBc56kCuD7Be9vakohVPtAgNlguh9tUQQSA8IdoPp fVQIvlPX+kY6fiMDNof5SBWcS9lL+1IiyF2VsQZJkZBbFD6p1ST3dJJLfMybhIqfKxTB 2oPATvJeTfCugNqrJIjnIKTVBplQ09Lwq7rawuTAiqoy97aTPajQuwY1EKUuo9081LVu LJ4PwmzT5aBiTgNX6lQ4v8dm64xj5qv33iJ+bHzaF525g0upr3WKJ1ye5cThoxqOCncM k79cePdiQzmf2QZEgDw0dGj+a55Pc+4n/vMgg6tI3lOGAvgX7aRFrK3NmFSyOtvRs2tz 5S1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=first header.b=EOBhJsJW; 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=NONE dis=NONE) header.from=geanix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn42si2255340ejc.47.2021.06.10.00.28.04; Thu, 10 Jun 2021 00:28:27 -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=@geanix.com header.s=first header.b=EOBhJsJW; 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=NONE dis=NONE) header.from=geanix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbhFJHZl (ORCPT + 99 others); Thu, 10 Jun 2021 03:25:41 -0400 Received: from first.geanix.com ([116.203.34.67]:50230 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbhFJHZ2 (ORCPT ); Thu, 10 Jun 2021 03:25:28 -0400 Received: from [192.168.64.199] (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id 7419A46261A; Thu, 10 Jun 2021 07:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1623309810; bh=vyfep8YIAK6qo0oOxa4YXp/asnk+y+Zn5gtODqva2d0=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=EOBhJsJW93K3V42DZWKWSVDaCHBTSDuSUhvZg455ui0L2NxAQO8nlsmHWbFpPq9KQ a8VC0Ia3snmnV+qqWcTdkAKR8lxkKRPmvjBxG1IVPHwbiYP9oKntrgU9SyPN1iI3T5 gO2U1Fvo32uroq49HUqZm7WEnTXWGQ+M7m+LnBOm1XZcMN9+lG/7n3j9uG6HEMdAHo roP5lXMbovdF7o+JtiLs3qOgEdpc5f+KlHx+sV8CmJ9Le00Rb2vtvoOqqmTdXK9Hw3 hT00VntQ1iXnYOX8KL81bArtz3dlw/EBqyWoD4J/N20B9zqCAOPPqKL/h1+5OKRaoX 85zg6pIwNLqbg== Subject: Re: [PATCH] clk: fix possible circular locking in clk_notifier_register() To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210610071758.1560592-1-sean@geanix.com> From: Sean Nyekjaer Message-ID: Date: Thu, 10 Jun 2021 09:23:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210610071758.1560592-1-sean@geanix.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=4.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, URIBL_BLOCKED autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on 93bd6fdb21b5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/06/2021 09.17, Sean Nyekjaer wrote: > Allocating memory with prepare_lock mutex held makes lockdep unhappy > when memory pressure makes the system do fs_reclaim on eg. rawnand using > clk. > > Push the allocation outside the lock. > [...] > > Signed-off-by: Sean Nyekjaer Fixes: b2476490ef111 ("clk: introduce the common clock framework") We could possibly add this fixes tag ^^ > --- > drivers/clk/clk.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index 65508eb89ec9..c32b71b08ccb 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -4340,17 +4340,20 @@ int clk_notifier_register(struct clk *clk, struct notifier_block *nb) > if (!clk || !nb) > return -EINVAL; > > + /* allocate new clk_notifier */ > + cn = kzalloc(sizeof(*cn), GFP_KERNEL); > + if (!cn) > + goto out; > + > clk_prepare_lock(); > > /* search the list of notifiers for this clk */ > list_for_each_entry(cn, &clk_notifier_list, node) > - if (cn->clk == clk) > + if (cn->clk == clk) { > + /* if clk is in the notifier list, free new clk_notifier */ > + kfree(cn); > goto found; > - > - /* if clk wasn't in the notifier list, allocate new clk_notifier */ > - cn = kzalloc(sizeof(*cn), GFP_KERNEL); > - if (!cn) > - goto out; > + } > > cn->clk = clk; > srcu_init_notifier_head(&cn->notifier_head); > @@ -4362,9 +4365,9 @@ int clk_notifier_register(struct clk *clk, struct notifier_block *nb) > > clk->core->notifier_count++; > > -out: > clk_prepare_unlock(); > > +out: > return ret; > } > EXPORT_SYMBOL_GPL(clk_notifier_register); >