Messages in this thread Patch in this message |  | | From | Jim Cromie <> | Subject | [PATCH v2 21/24] dyndbg: adapt header macros to pass print-class | Date | Sat, 13 Jun 2020 09:57:35 -0600 |
| |
derive DEFINE_DYNAMIC_DEBUG_METADATA_CL from DEFINE_DYNAMIC_DEBUG_METADATA then redefine latter as former(0, ...)
Also rework /(_?_?dynamic_.+)/ macros, adding _cl suffix & cl arg1 and redefine them in terms of _cl version.
in printk.h: add pr_debug_n, fix pr_debug use it with pr_cls=0 --- include/linux/dynamic_debug.h | 69 +++++++++++++++++++++++------------ include/linux/printk.h | 5 ++- 2 files changed, 50 insertions(+), 24 deletions(-)
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 7ac822d6be87..d7f3dd6fc78a 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -80,7 +80,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const struct ib_device *ibdev, const char *fmt, ...); -#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ +#define DEFINE_DYNAMIC_DEBUG_METADATA_CL(cl, name, fmt) \ static struct _ddebug __aligned(8) \ __section(__dyndbg) name = { \ .modname = KBUILD_MODNAME, \ @@ -89,8 +89,11 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, .format = (fmt), \ .lineno = __LINE__, \ .flags = _DPRINTK_FLAGS_DEFAULT, \ + .pr_class = cl, \ _DPRINTK_KEY_INIT \ } +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + DEFINE_DYNAMIC_DEBUG_METADATA_CL(0, name, fmt) #ifdef CONFIG_JUMP_LABEL @@ -121,17 +124,21 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #endif -#define __dynamic_func_call(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(&id, ##__VA_ARGS__); \ +#define __dynamic_func_call_cl(cl, id, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CL(cl, id, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(&id, ##__VA_ARGS__); \ } while (0) +#define __dynamic_func_call(id, fmt, func, ...) \ + __dynamic_func_call_cl(0, id, fmt, func, ...) -#define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(__VA_ARGS__); \ +#define __dynamic_func_call_no_desc_cl(cl, id, fmt, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA_CL(cl, id, fmt); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(__VA_ARGS__); \ } while (0) +#define __dynamic_func_call_no_desc(cl, id, fmt, func, ...) \ + __dynamic_func_call_no_desc_cl(0, cl, id, fmt, func, ##__VA_ARGS__) /* * "Factory macro" for generating a call to func, guarded by a @@ -141,31 +148,44 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * the varargs. Note that fmt is repeated in invocations of this * macro. */ -#define _dynamic_func_call(fmt, func, ...) \ - __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call_cl(cl, fmt, func, ...) \ + __dynamic_func_call_cl(cl, __UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call(fmt, func, ...) \ + _dynamic_func_call_cl(0, fmt, func, ##__VA_ARGS__) /* * A variant that does the same, except that the descriptor is not * passed as the first argument to the function; it is only called * with precisely the macro's varargs. */ -#define _dynamic_func_call_no_desc(fmt, func, ...) \ - __dynamic_func_call_no_desc(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call_no_desc_cl(cl, fmt, func, ...) \ + __dynamic_func_call_no_desc_cl(cl, __UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call_no_desc(fmt, func, ...) \ + _dynamic_func_call_no_desc_cl(0, fmt, func, ##__VA_ARGS__) -#define dynamic_pr_debug(fmt, ...) \ - _dynamic_func_call(fmt, __dynamic_pr_debug, \ - pr_fmt(fmt), ##__VA_ARGS__) +#define dynamic_pr_debug_cl(cl, fmt, ...) \ + _dynamic_func_call_cl(cl, fmt, __dynamic_pr_debug, \ + pr_fmt(fmt), ##__VA_ARGS__) -#define dynamic_dev_dbg(dev, fmt, ...) \ - _dynamic_func_call(fmt,__dynamic_dev_dbg, \ +#define dynamic_dev_dbg_cl(cl, dev, fmt, ...) \ + _dynamic_func_call_cl(cl, fmt, __dynamic_dev_dbg, \ dev, fmt, ##__VA_ARGS__) -#define dynamic_netdev_dbg(dev, fmt, ...) \ - _dynamic_func_call(fmt, __dynamic_netdev_dbg, \ +#define dynamic_netdev_dbg_cl(cl, dev, fmt, ...) \ + _dynamic_func_call_cl(cl, fmt, __dynamic_netdev_dbg, \ dev, fmt, ##__VA_ARGS__) -#define dynamic_ibdev_dbg(dev, fmt, ...) \ - _dynamic_func_call(fmt, __dynamic_ibdev_dbg, \ - dev, fmt, ##__VA_ARGS__) +#define dynamic_ibdev_dbg_cl(cl, dev, fmt, ...) \ + _dynamic_func_call_cl(cl, fmt, __dynamic_ibdev_dbg, \ + dev, fmt, ##__VA_ARGS__) + +#define dynamic_pr_debug(...) \ + dynamic_pr_debug_cl(0, ##__VA_ARGS__) +#define dynamic_dev_dbg(...) \ + dynamic_dev_dbg_cl(0, ##__VA_ARGS__) +#define dynamic_netdev_dbg(...) \ + dynamic_netdev_dbg_cl(0, ##__VA_ARGS__) +#define dynamic_ibdev_dbg(...) \ + dynamic_ibdev_dbg_cl(0, ##__VA_ARGS__) #define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ groupsize, buf, len, ascii) \ @@ -202,6 +222,9 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, return -EINVAL; } +#define dynamic_pr_debug_cl(cl, ...) dynamic_pr_debug(__VA_ARGS__) +#define dynamic_dev_dbg_cl(cl, ...) dynamic_dev_dbg(__VA_ARGS__) + #define dynamic_pr_debug(fmt, ...) \ do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) #define dynamic_dev_dbg(dev, fmt, ...) \ diff --git a/include/linux/printk.h b/include/linux/printk.h index fc8f03c54543..693d7c9235b7 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -416,7 +416,10 @@ extern int kptr_restrict; * pr_fmt() internally). */ #define pr_debug(fmt, ...) \ - dynamic_pr_debug(fmt, ##__VA_ARGS__) + dynamic_pr_debug_cl(0, fmt, ##__VA_ARGS__) +#define pr_debug_n(num, fmt, ...) \ + dynamic_pr_debug_cl(num, fmt, ##__VA_ARGS__) + #elif defined(DEBUG) #define pr_debug(fmt, ...) \ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) -- 2.26.2
|  |