Re: [PATCH v1 1/1] devres: Pass unique name of the resource to devm_add_action()
From: Andy Shevchenko
Date: Fri Mar 10 2023 - 09:13:49 EST
On Fri, Mar 10, 2023 at 02:21:24PM +0100, Mirsad Todorovac wrote:
> On 2/24/23 21:07, Andy Shevchenko wrote:
> > Pass the unique name of the resource to devm_add_action(),
> > so it will be easier to debug managed resources.
...
> (I'm late two weeks w testing, but those were rather busy two weeks.)
Thank you for this test!
> I see what it is meant to do, but I am unsure of how to test whether it works.
Your test below is good enough.
> Being the unfaithful Thomas, I always prefer to test rather to just assume it
> is OK.
>
> Is this OK output you expected to see in syslog?
Not really. It seems that we need to also wrap the devm_add_action_or_reset()
separately.
> Mar 8 22:20:36 pc-mtodorov kernel: gpio-sim gpio-sim.0: DEVRES ADD 00000000ea28d384 action (16 bytes)
> Mar 8 22:20:36 pc-mtodorov kernel: gpio-sim gpio-sim.0: DEVRES ADD 000000004090f288 action (16 bytes)
> Mar 8 22:20:36 pc-mtodorov kernel: gpio-sim gpio-sim.0: DEVRES REL 000000004090f288 action (16 bytes)
> Mar 8 22:20:36 pc-mtodorov kernel: gpio-sim gpio-sim.0: DEVRES REL 00000000ea28d384 action (16 bytes)
Instead of 'action' we need to see the real name of the action.
> NOTE: Maybe I should emphasise that this is not seen in either dmesg or kernel console.
Do you have 'ignore_loglevel' in the kernel command line? You should,
independently on this patch, for debug testing.
> I have just checked, and DEVRES lines are only in /var/log/messages (on AlmaLinux 8.7, CentOS fork).
>
> As you must have guessed yourself already, this will frustrate debugging past the lifetime of rsyslog process.
>
> Also, there is no way known to me to access dmesg log from the previous kernel run.
Can you test this on top?
diff --git a/include/linux/device.h b/include/linux/device.h
index 0f128520f6e5..12dc08aa5c0f 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -250,17 +250,19 @@ int __devm_add_action(struct device *dev, void (*action)(void *), void *data, co
#define devm_add_action(release, action, data) \
__devm_add_action(release, action, data, #action)
-static inline int devm_add_action_or_reset(struct device *dev,
- void (*action)(void *), void *data)
+static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
+ void *data, const char *name)
{
int ret;
- ret = devm_add_action(dev, action, data);
+ ret = __devm_add_action(dev, action, data, name);
if (ret)
action(data);
return ret;
}
+#define devm_add_action_or_reset(release, action, data) \
+ __devm_add_action_or_reset(release, action, data, #action)
/**
* devm_alloc_percpu - Resource-managed alloc_percpu
--
With Best Regards,
Andy Shevchenko