devres: Enable trace events
PATCH v2 1/1 devres: Enable trace events
In some cases the printf() mechanism is too heavy and can't be used. For example, when debugging a race condition involving devres API. When CONFIG_DEBUG_DEVRES is enabled I can't reproduce an issue, and otherwise it's quite visible with a useful information being collected.
Enable trace events for devres part of the driver core.
---
v2: fixed compilation error (lkp), elaborate commit message (Greg)
drivers/base/Makefile | 3 +++ drivers/base/devres.c | 23 +++++++++++------- drivers/base/trace.c | 10 ++++++++ drivers/base/trace.h | 56 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 drivers/base/trace.c create mode 100644 drivers/base/trace.h
drivers/base/Makefile +3 -0
@@ -30,3 +30,6 @@ obj-y += test/ ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +# define_trace.h needs to know how to find our header +CFLAGS_trace.o := -I$(src) +obj-$(CONFIG_TRACING) += trace.o
drivers/base/devres.c +14 -9
@@ -14,14 +14,13 @@#include <asm/sections.h> #include "base.h" +#include "trace.h" struct devres_node {struct list_head entry;dr_release_t release; -#ifdef CONFIG_DEBUG_DEVRES const char *name;size_t size; -#endif };struct devres {
@@ -43,10 +42,6 @@ struct devres_group {/* -- 8 pointers */ }; -#ifdef CONFIG_DEBUG_DEVRES -static int log_devres =0 ; -module_param_named (log, log_devres, int,S_IRUGO |S_IWUSR ); -static void set_node_dbginfo (struct devres_node *node,const char *name,size_t size) {
@@ -54,7 +49,11 @@ static void set_node_dbginfo(struct devres_node *node, const char *name, node->size = size; } -static void devres_log (struct device *dev,struct devres_node *node, +#ifdef CONFIG_DEBUG_DEVRES +static int log_devres =0 ; +module_param_named (log, log_devres, int,S_IRUGO |S_IWUSR ); + +static void devres_dbg (struct device *dev,struct devres_node *node,const char *op) {if (unlikely (log_devres))
@@ -62,10 +61,16 @@ static void devres_log(struct device *dev, struct devres_node *node, op, node, node->name, node->size); }#else /* CONFIG_DEBUG_DEVRES */ -#define set_node_dbginfo (node, n, s) do {} while (0) -#define devres_log (dev, node, op) do {} while (0) +#define devres_dbg (dev, node, op) do {} while (0)#endif /* CONFIG_DEBUG_DEVRES */ +static void devres_log (struct device *dev,struct devres_node *node, +const char *op) +{ +trace_devres_log (dev, op, node, node->name, node->size); +devres_dbg (dev, node, op); +} +/* * Release functions for devres group. These callbacks are used only * for identification.
drivers/base/trace.c new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Device core Trace Support +* Copyright (C) 2021, Intel Corporation +* +* Author: Andy Shevchenko <[email protected]> +*/ + +#define CREATE_TRACE_POINTS +#include "trace.h"
drivers/base/trace.h new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.30.2
Quoted 36 lines · Andy Shevchenko
In some cases the
printf()mechanism is too heavy and can't be used. For example, when debugging a race condition involving devres API. WhenCONFIG_DEBUG_DEVRESis enabled I can't reproduce an issue, and otherwise it's quite visible with a useful information being collected.Enable trace events for devres part of the driver core.
Signed-off-by Andy Shevchenko <[email protected]>---
v2: fixed compilation error (lkp), elaborate commit message (Greg)drivers/base/Makefile | 3 +++ drivers/base/devres.c | 23 +++++++++++------- drivers/base/trace.c | 10 ++++++++ drivers/base/trace.h | 56 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 drivers/base/trace.c create mode 100644 drivers/base/trace.hdrivers/base/Makefile +3
-0@@ -30,3 +30,6 @@ obj-y += test/ ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +# define_trace.h needs to know how to find our header +CFLAGS_trace.o := -I$(src) +obj-$(CONFIG_TRACING) += trace.odrivers/base/devres.c +0
-0@@ -14,14 +14,13 @@#include <asm/sections.h>
drivers/base/devres.c line 24
Quoted 10 lines
drivers/base/devres.c +1
-2#include "base.h" +#include "trace.h" struct devres_node {struct list_head entry;dr_release_t release; -#ifdef CONFIG_DEBUG_DEVRES const char *name;size_t size; -#endif
Those ifdefs are still required.
drivers/base/devres.c line 24
Quoted 1 line
drivers/base/devres.c +0
-0};
thanks,
Signature · 1 line
heikki
Quoted 7 lines · Heikki Krogerus
Quoted 6 lines · Andy Shevchenko
In some cases the
printf()mechanism is too heavy and can't be used. For example, when debugging a race condition involving devres API. WhenCONFIG_DEBUG_DEVRESis enabled I can't reproduce an issue, and otherwise it's quite visible with a useful information being collected.Enable trace events for devres part of the driver core.
...
Quoted 9 lines
drivers/base/devres.c line 24
Quoted 7 lines
struct
devres_node{drivers/base/devres.c +0
-2struct list_head entry;dr_release_t release; -#ifdef CONFIG_DEBUG_DEVRES const char *name;size_t size; -#endif Those ifdefs are still required.
Oh, yes, otherwise we end up with not filled name and size (as per header file). I'll rework in order to fill name and size always and get rid of ifdeffery in the header file.
Thanks!
Quoted 1 line
Quoted 1 line
};
Signature · 2 lines
With Best Regards, Andy Shevchenko