From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Saravana Kannan <saravanak@google.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Francesco <francesco.dolcini@toradex.com>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Tomi Valkeinen" <tomi.valkeinen@ideasonboard.com>,
kernel-team@android.com, linux-kernel@vger.kernel.org,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
"Conor Dooley" <conor@kernel.org>,
"Hervé Codina" <herve.codina@bootlin.com>
Subject: Re: [PATCH v3] driver core: fw_devlink: Stop trying to optimize cycle detection logic
Date: Wed, 12 Feb 2025 16:33:20 +0100 [thread overview]
Message-ID: <20250212163320.24d30adb@booty> (raw)
In-Reply-To: <20241206103143.755f5e87@booty>
Hello,
On Fri, 6 Dec 2024 10:31:43 +0100
Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
> > After rebasing my work for the hotplug connector driver using device
> > tree overlays [0] on v6.13-rc1 I started getting these OF errors on
> > overlay removal:
> >
> > OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /addon-connector/devices/panel-dsi-lvds
> > OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /addon-connector/devices/backlight-addon
> > OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /addon-connector/devices/battery-charger
> > OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /addon-connector/devices/regulator-addon-5v0-sys
> > OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /addon-connector/devices/regulator-addon-3v3-sys
> >
> > ...and many more. Exactly one per each device in the overlay 'devices'
> > node, each implemented by a platform driver.
> >
> > Bisecting found this patch is triggering these error messages, which
> > in fact disappear by reverting it.
> >
> > I looked at the differences in dmesg and /sys/class/devlink/ in the
> > "good" and "bad" cases, and found almost no differences. The only
> > relevant difference is in cycle detection for the panel node, which was
> > expected, but nothing about all the other nodes like regulators.
> >
> > Enabling debug messages in core.c also does not show significant
> > changes between the two cases, even though it's hard to be sure given
> > the verbosity of the log and the reordering of messages.
> >
> > I suspect the new version of the cycle removal code is missing an
> > of_node_get() somewhere, but that is not directly visible in the patch
> > diff itself.
>
> I collected some more info by adding a bit of logging for one of the
> affected devices.
>
> It looks like the of_node_get() and of_node_put() in the overlay
> loading phase are the same, even though not completely in the same
> order. So after overlay insertion we should have the same refcount with
> and without your patch.
>
> There is a difference on overlay removal however: an of_node_put() call
> is absent with 6.13-rc1 code (errors emitted), and becomes present by
> just reverting your patch (the "good" case). Here's the stack trace of
> this call:
>
> Call trace:
> show_stack+0x20/0x38 (C)
> dump_stack_lvl+0x74/0x90
> dump_stack+0x18/0x28
> of_node_put+0x50/0x70
> platform_device_release+0x24/0x68
> device_release+0x3c/0xa0
> kobject_put+0xa4/0x118
> device_link_release_fn+0x60/0xd8
> process_one_work+0x158/0x3c0
> worker_thread+0x2d8/0x3e8
> kthread+0x118/0x128
> ret_from_fork+0x10/0x20
>
> So for some reason device_link_release_fn() is not leading to a
> of_node_put() call after adding your patch.
>
> Quick code inspection did not show any useful info for me to understand
> more.
I just sent a patch fixing
this: https://lore.kernel.org/20250212-fix__fw_devlink_relax_cycles_missing_device_put-v1-1-41818c7d7722@bootlin.com
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2025-02-12 15:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 17:10 [PATCH v3] driver core: fw_devlink: Stop trying to optimize cycle detection logic Saravana Kannan
2024-11-06 1:30 ` Saravana Kannan
2024-11-06 4:52 ` Greg Kroah-Hartman
2024-11-19 13:40 ` Geert Uytterhoeven
2024-11-20 2:04 ` Saravana Kannan
2024-11-20 8:43 ` Geert Uytterhoeven
2024-12-04 11:48 ` Luca Ceresoli
2024-12-04 12:52 ` Geert Uytterhoeven
2024-12-04 17:14 ` Luca Ceresoli
2024-12-06 9:31 ` Luca Ceresoli
2025-02-12 15:33 ` Luca Ceresoli [this message]
2025-02-13 8:08 ` Saravana Kannan
2025-01-06 15:16 ` Tomi Valkeinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250212163320.24d30adb@booty \
--to=luca.ceresoli@bootlin.com \
--cc=conor@kernel.org \
--cc=francesco.dolcini@toradex.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=herve.codina@bootlin.com \
--cc=kernel-team@android.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=tomi.valkeinen@ideasonboard.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.