* [PATCH 0/2] driver core: Improve warning backtrace in device probing
@ 2019-11-20 14:36 Geert Uytterhoeven
2019-11-20 14:36 ` [PATCH 1/2] driver core: Add dev_WARN_ON() helper Geert Uytterhoeven
2019-11-20 14:36 ` [PATCH 2/2] driver core: Print device in really_probe() warning backtrace Geert Uytterhoeven
0 siblings, 2 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2019-11-20 14:36 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki; +Cc: linux-kernel, Geert Uytterhoeven
Hi Greg, Rafael,
Once in a while, the WARN_ON() in really_probe() is triggered due to a
bug in a driver or subsystem. While the backtrace provides some clues,
it does not reveal the offending device.
Hence this patch series adds a new dev_WARN_ON() helper, and uses that.
Thanks!
Geert Uytterhoeven (2):
driver core: Add dev_WARN_ON() helper
driver core: Print device in really_probe() warning backtrace
drivers/base/dd.c | 2 +-
include/linux/device.h | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
--
2.17.1
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] driver core: Add dev_WARN_ON() helper
2019-11-20 14:36 [PATCH 0/2] driver core: Improve warning backtrace in device probing Geert Uytterhoeven
@ 2019-11-20 14:36 ` Geert Uytterhoeven
2019-11-20 14:36 ` [PATCH 2/2] driver core: Print device in really_probe() warning backtrace Geert Uytterhoeven
1 sibling, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2019-11-20 14:36 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki; +Cc: linux-kernel, Geert Uytterhoeven
It is quite useful to print the related device in a warning backtrace.
Hence add a "dev_*" variant of WARN_ON() to handle this.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
include/linux/device.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h
index f05c5b92e61f535a..05089c329620472a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1902,6 +1902,9 @@ do { \
WARN_ONCE(condition, "%s %s: " format, \
dev_driver_string(dev), dev_name(dev), ## arg)
+#define dev_WARN_ON(dev, condition) \
+ WARN(condition, "%s %s", dev_driver_string(dev), dev_name(dev))
+
/* Create alias, so I can be autoloaded. */
#define MODULE_ALIAS_CHARDEV(major,minor) \
MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] driver core: Print device in really_probe() warning backtrace
2019-11-20 14:36 [PATCH 0/2] driver core: Improve warning backtrace in device probing Geert Uytterhoeven
2019-11-20 14:36 ` [PATCH 1/2] driver core: Add dev_WARN_ON() helper Geert Uytterhoeven
@ 2019-11-20 14:36 ` Geert Uytterhoeven
2019-11-21 13:57 ` Greg Kroah-Hartman
1 sibling, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2019-11-20 14:36 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki; +Cc: linux-kernel, Geert Uytterhoeven
If a device already has devres items attached before probing, a warning
backtrace is printed. However, this backtrace does not reveal the
offending device, leaving the user uninformed.
Use dev_WARN_ON() instead of WARN_ON() to fix this.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/base/dd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index d811e60610d33ae9..a7e8040ef0003f44 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -516,7 +516,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
atomic_inc(&probe_count);
pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
drv->bus->name, __func__, drv->name, dev_name(dev));
- WARN_ON(!list_empty(&dev->devres_head));
+ dev_WARN_ON(dev, !list_empty(&dev->devres_head));
re_probe:
dev->driver = drv;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] driver core: Print device in really_probe() warning backtrace
2019-11-20 14:36 ` [PATCH 2/2] driver core: Print device in really_probe() warning backtrace Geert Uytterhoeven
@ 2019-11-21 13:57 ` Greg Kroah-Hartman
2019-11-21 14:08 ` Geert Uytterhoeven
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2019-11-21 13:57 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Rafael J . Wysocki, linux-kernel
On Wed, Nov 20, 2019 at 03:36:19PM +0100, Geert Uytterhoeven wrote:
> If a device already has devres items attached before probing, a warning
> backtrace is printed. However, this backtrace does not reveal the
> offending device, leaving the user uninformed.
>
> Use dev_WARN_ON() instead of WARN_ON() to fix this.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> drivers/base/dd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index d811e60610d33ae9..a7e8040ef0003f44 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -516,7 +516,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
> atomic_inc(&probe_count);
> pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
> drv->bus->name, __func__, drv->name, dev_name(dev));
> - WARN_ON(!list_empty(&dev->devres_head));
> + dev_WARN_ON(dev, !list_empty(&dev->devres_head));
We really do not want WARN_ON() anywhere, as that causes systems with
panic-on-warn to reboot.
If this can happen, we should switch it to a real error message, with
dev_err() and the like, and recover properly.
I don't want to make it easier to add WARN_ON() lines, like
dev_WARN_ON() would allow, instead we should be removing them, as they
encourage slopping programming habits.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] driver core: Print device in really_probe() warning backtrace
2019-11-21 13:57 ` Greg Kroah-Hartman
@ 2019-11-21 14:08 ` Geert Uytterhoeven
0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2019-11-21 14:08 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Geert Uytterhoeven, Rafael J . Wysocki, Linux Kernel Mailing List
Hi Greg,
On Thu, Nov 21, 2019 at 2:57 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Wed, Nov 20, 2019 at 03:36:19PM +0100, Geert Uytterhoeven wrote:
> > If a device already has devres items attached before probing, a warning
> > backtrace is printed. However, this backtrace does not reveal the
> > offending device, leaving the user uninformed.
> >
> > Use dev_WARN_ON() instead of WARN_ON() to fix this.
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > --- a/drivers/base/dd.c
> > +++ b/drivers/base/dd.c
> > @@ -516,7 +516,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
> > atomic_inc(&probe_count);
> > pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
> > drv->bus->name, __func__, drv->name, dev_name(dev));
> > - WARN_ON(!list_empty(&dev->devres_head));
> > + dev_WARN_ON(dev, !list_empty(&dev->devres_head));
>
> We really do not want WARN_ON() anywhere, as that causes systems with
> panic-on-warn to reboot.
>
> If this can happen, we should switch it to a real error message, with
> dev_err() and the like, and recover properly.
If this happens, there's something serious wrong with resource management,
beyond recovery.
> I don't want to make it easier to add WARN_ON() lines, like
> dev_WARN_ON() would allow, instead we should be removing them, as they
> encourage slopping programming habits.
OK, will respin, using dev_warn().
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-11-21 14:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20 14:36 [PATCH 0/2] driver core: Improve warning backtrace in device probing Geert Uytterhoeven
2019-11-20 14:36 ` [PATCH 1/2] driver core: Add dev_WARN_ON() helper Geert Uytterhoeven
2019-11-20 14:36 ` [PATCH 2/2] driver core: Print device in really_probe() warning backtrace Geert Uytterhoeven
2019-11-21 13:57 ` Greg Kroah-Hartman
2019-11-21 14:08 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).