Message ID | 20221115220520.2076189-1-pierre.gondois@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2964281wru; Tue, 15 Nov 2022 14:10:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf5vNFcIgXR5kxdIjt3d3HXY/ECxvnCrsw5hSHVVqkBXoLX5TZndc1lA1YjkwiX3hD4/Plo9 X-Received: by 2002:a17:90b:2644:b0:214:1a8a:a415 with SMTP id pa4-20020a17090b264400b002141a8aa415mr401013pjb.197.1668550216696; Tue, 15 Nov 2022 14:10:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668550216; cv=none; d=google.com; s=arc-20160816; b=aqydCDx5wO/IQm6HZZR+4DeYMJUQgcBg9Phf6Iz5SWZfBj5+19flyPEFn++DATAWde +ZAwskXM3QQE2+wEpIGdwc5C08kMkGcnsaSKJN8g5CioqH1lFmTCvoCboskHRyK0C/Te dKdmQqebSHC/zLUfovG5ctD8gUU1uj6L/tsBdKZAhbnMIJ9MLnVM98BwrpbfEPxsFxUP 6zm+X9VOgSm8IV6rGy+vj7Hc4S1vtgPGiwcayn6VAnDNVc2E/aptUjVbVpQy6kB2igCN ryiHV67EDKa7Qt6KKWFdMz717e5vaX5Mde6uq3ELOO4PofIZU/bYo3ly+mQvjEUzMWv6 JEiA== 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; bh=gJtDHoqrfNgiVhjNqc6CpZAXH+7OD6JW0J1wx6NqTYI=; b=b8NWT69alKhP7GrT7GiezMDwFYXyDiyrYatqZrFI2OBhVF/+qWu0K9ksq+F9GWyefW 0vLFxJtUQKvyiERI2V0mRK6dUiJkbJpNU2h2xGEVvn5rB3avybbJEb+YfTDbSQTjcJG0 A3nqONVbt60DhJYRnnGO/hE+6VjlYjyBr3bO5amXn2YaGiQV8ygCc34q9wmzEvriZlPK wmrFmwHQR8hJbhX+pP/QiTw5c/RphEAxi7WLz/C4M6V157hltxQsX6npX7/+pvw2leZT /sPq0YYCbhJoCQpz8e4PRZRRQgk8Rr1S43IiXCTQcl0mnXAe3q7Y03jcBb87MNGAw3Uk VPJg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5-20020a170902eb8500b001733a212ccfsi12412604plg.330.2022.11.15.14.10.00; Tue, 15 Nov 2022 14:10:16 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238391AbiKOWGA (ORCPT <rfc822;maxim.cournoyer@gmail.com> + 99 others); Tue, 15 Nov 2022 17:06:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232403AbiKOWF6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 15 Nov 2022 17:05:58 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D3B7F21272; Tue, 15 Nov 2022 14:05:57 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A0F1913D5; Tue, 15 Nov 2022 14:06:03 -0800 (PST) Received: from pierre123.arm.com (unknown [10.57.6.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C04963F73B; Tue, 15 Nov 2022 14:05:54 -0800 (PST) From: Pierre Gondois <pierre.gondois@arm.com> To: linux-kernel@vger.kernel.org Cc: Rob.Herring@arm.com, sudeep.holla@arm.com, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J . Wysocki" <rafael@kernel.org>, Linux-Renesas <linux-renesas-soc@vger.kernel.org>, Marek Szyprowski <m.szyprowski@samsung.com>, Geert Uytterhoeven <geert@linux-m68k.org>, Pierre Gondois <pierre.gondois@arm.com> Subject: [PATCH -next] cacheinfo: Remove of_node_put() for fw_token Date: Tue, 15 Nov 2022 23:05:20 +0100 Message-Id: <20221115220520.2076189-1-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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: <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?1749601711801125559?= X-GMAIL-MSGID: =?utf-8?q?1749601711801125559?= |
Series |
[-next] cacheinfo: Remove of_node_put() for fw_token
|
|
Commit Message
Pierre Gondois
Nov. 15, 2022, 10:05 p.m. UTC
fw_token is used for DT/ACPI systems to identify CPUs sharing caches.
For DT based systems, fw_token is set to a pointer to a DT node.
commit ("cacheinfo: Decrement refcount in cache_setup_of_node()")
doesn't increment the refcount of fw_token anymore in
cache_setup_of_node(). fw_token is indeed used as a token and not
as a (struct device_node*), so no reference to fw_token should be
kept.
However, [1] is triggered when hotplugging a CPU multiple times
since cache_shared_cpu_map_remove() decrements the refcount to
fw_token at each CPU unplugging, eventually reaching 0.
Remove of_node_put() for fw_token in cache_shared_cpu_map_remove().
[1]
[ 53.651182] ------------[ cut here ]------------
[ 53.651186] refcount_t: saturated; leaking memory.
[ 53.651223] WARNING: CPU: 4 PID: 32 at lib/refcount.c:22 refcount_warn_saturate (lib/refcount.c:22 (discriminator 3))
[ 53.651241] Modules linked in:
[ 53.651249] CPU: 4 PID: 32 Comm: cpuhp/4 Tainted: G W 6.1.0-rc1-14091-g9fdf2ca7b9c8 #76
[ 53.651261] Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Oct 31 2022
[ 53.651268] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 53.651279] pc : refcount_warn_saturate (lib/refcount.c:22 (discriminator 3))
[ 53.651293] lr : refcount_warn_saturate (lib/refcount.c:22 (discriminator 3))
[...]
[ 53.651513] Call trace:
[...]
[ 53.651735] of_node_release (drivers/of/dynamic.c:335)
[ 53.651750] kobject_put (lib/kobject.c:677 lib/kobject.c:704 ./include/linux/kref.h:65 lib/kobject.c:721)
[ 53.651762] of_node_put (drivers/of/dynamic.c:49)
[ 53.651776] free_cache_attributes.part.0 (drivers/base/cacheinfo.c:712)
[ 53.651792] cacheinfo_cpu_pre_down (drivers/base/cacheinfo.c:718)
[ 53.651807] cpuhp_invoke_callback (kernel/cpu.c:247 (discriminator 4))
[ 53.651819] cpuhp_thread_fun (kernel/cpu.c:785)
[ 53.651832] smpboot_thread_fn (kernel/smpboot.c:164 (discriminator 3))
[ 53.651847] kthread (kernel/kthread.c:376)
[ 53.651858] ret_from_fork (arch/arm64/kernel/entry.S:861)
[ 53.651869] ---[ end trace 0000000000000000 ]---
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
drivers/base/cacheinfo.c | 2 --
1 file changed, 2 deletions(-)
Comments
On Tue, Nov 15, 2022 at 11:05:20PM +0100, Pierre Gondois wrote: > fw_token is used for DT/ACPI systems to identify CPUs sharing caches. > For DT based systems, fw_token is set to a pointer to a DT node. > > commit ("cacheinfo: Decrement refcount in cache_setup_of_node()") Commit 3da72e18371c ("cacheinfo: Decrement refcount in cache_setup_of_node()") > doesn't increment the refcount of fw_token anymore in > cache_setup_of_node(). fw_token is indeed used as a token and not > as a (struct device_node*), so no reference to fw_token should be > kept. > > However, [1] is triggered when hotplugging a CPU multiple times > since cache_shared_cpu_map_remove() decrements the refcount to > fw_token at each CPU unplugging, eventually reaching 0. > > Remove of_node_put() for fw_token in cache_shared_cpu_map_remove(). > > [1] > [ 53.651182] ------------[ cut here ]------------ > [ 53.651186] refcount_t: saturated; leaking memory. > [ 53.651223] WARNING: CPU: 4 PID: 32 at lib/refcount.c:22 refcount_warn_saturate (lib/refcount.c:22 (discriminator 3)) > [ 53.651241] Modules linked in: > [ 53.651249] CPU: 4 PID: 32 Comm: cpuhp/4 Tainted: G W 6.1.0-rc1-14091-g9fdf2ca7b9c8 #76 > [ 53.651261] Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Oct 31 2022 > [ 53.651268] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) > [ 53.651279] pc : refcount_warn_saturate (lib/refcount.c:22 (discriminator 3)) > [ 53.651293] lr : refcount_warn_saturate (lib/refcount.c:22 (discriminator 3)) > [...] > [ 53.651513] Call trace: > [...] > [ 53.651735] of_node_release (drivers/of/dynamic.c:335) > [ 53.651750] kobject_put (lib/kobject.c:677 lib/kobject.c:704 ./include/linux/kref.h:65 lib/kobject.c:721) > [ 53.651762] of_node_put (drivers/of/dynamic.c:49) > [ 53.651776] free_cache_attributes.part.0 (drivers/base/cacheinfo.c:712) > [ 53.651792] cacheinfo_cpu_pre_down (drivers/base/cacheinfo.c:718) > [ 53.651807] cpuhp_invoke_callback (kernel/cpu.c:247 (discriminator 4)) > [ 53.651819] cpuhp_thread_fun (kernel/cpu.c:785) > [ 53.651832] smpboot_thread_fn (kernel/smpboot.c:164 (discriminator 3)) > [ 53.651847] kthread (kernel/kthread.c:376) > [ 53.651858] ret_from_fork (arch/arm64/kernel/entry.S:861) > [ 53.651869] ---[ end trace 0000000000000000 ]--- > Please remove the timestamp as they add no value to the commit log. Also it is worth adding IMO: Fixes: 3da72e18371c ("cacheinfo: Decrement refcount in cache_setup_of_node()") I did a quick test and so, Tested-by: Sudeep Holla <sudeep.holla@arm.com> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Thanks for fixing the quickly and sorry for not noticing the extra of_node_put even though I thought if it was just incrementing the refcount earlier.
On Tue, Nov 15, 2022 at 11:06 PM Pierre Gondois <pierre.gondois@arm.com> wrote: > fw_token is used for DT/ACPI systems to identify CPUs sharing caches. > For DT based systems, fw_token is set to a pointer to a DT node. > > commit ("cacheinfo: Decrement refcount in cache_setup_of_node()") > doesn't increment the refcount of fw_token anymore in > cache_setup_of_node(). fw_token is indeed used as a token and not > as a (struct device_node*), so no reference to fw_token should be > kept. > > However, [1] is triggered when hotplugging a CPU multiple times > since cache_shared_cpu_map_remove() decrements the refcount to > fw_token at each CPU unplugging, eventually reaching 0. > > Remove of_node_put() for fw_token in cache_shared_cpu_map_remove(). > > [1] > [ 53.651182] ------------[ cut here ]------------ > [ 53.651186] refcount_t: saturated; leaking memory. > [ 53.651223] WARNING: CPU: 4 PID: 32 at lib/refcount.c:22 refcount_warn_saturate (lib/refcount.c:22 (discriminator 3)) > [ 53.651241] Modules linked in: > [ 53.651249] CPU: 4 PID: 32 Comm: cpuhp/4 Tainted: G W 6.1.0-rc1-14091-g9fdf2ca7b9c8 #76 > [ 53.651261] Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Oct 31 2022 > [ 53.651268] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) > [ 53.651279] pc : refcount_warn_saturate (lib/refcount.c:22 (discriminator 3)) > [ 53.651293] lr : refcount_warn_saturate (lib/refcount.c:22 (discriminator 3)) > [...] > [ 53.651513] Call trace: > [...] > [ 53.651735] of_node_release (drivers/of/dynamic.c:335) > [ 53.651750] kobject_put (lib/kobject.c:677 lib/kobject.c:704 ./include/linux/kref.h:65 lib/kobject.c:721) > [ 53.651762] of_node_put (drivers/of/dynamic.c:49) > [ 53.651776] free_cache_attributes.part.0 (drivers/base/cacheinfo.c:712) > [ 53.651792] cacheinfo_cpu_pre_down (drivers/base/cacheinfo.c:718) > [ 53.651807] cpuhp_invoke_callback (kernel/cpu.c:247 (discriminator 4)) > [ 53.651819] cpuhp_thread_fun (kernel/cpu.c:785) > [ 53.651832] smpboot_thread_fn (kernel/smpboot.c:164 (discriminator 3)) > [ 53.651847] kthread (kernel/kthread.c:376) > [ 53.651858] ret_from_fork (arch/arm64/kernel/entry.S:861) > [ 53.651869] ---[ end trace 0000000000000000 ]--- > > Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> > Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> > Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Thanks, this fixes the issue for me! Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 04317cde800c..950b22cdb5f7 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -317,8 +317,6 @@ static void cache_shared_cpu_map_remove(unsigned int cpu) cpumask_clear_cpu(cpu, &sib_leaf->shared_cpu_map); cpumask_clear_cpu(sibling, &this_leaf->shared_cpu_map); } - if (of_have_populated_dt()) - of_node_put(this_leaf->fw_token); } }