dyndbg: cleanup dynamic usage in ib_srp.c
Currently, in dynamic_debug.h we only provide DEFINE_DYNAMIC_DEBUG_METADATA() and DYNAMIC_DEBUG_BRANCH() definitions if CONFIG_DYNAMIC_CORE is enabled. Thus, drivers such as infiniband srp (see: drivers/infiniband/ulp/srp/ib_srp.c) must provide their own definitions for !CONFIG_DYNAMIC_CORE. Thus, let's move this !CONFIG_DYNAMIC_CORE case into dynamic_debug.h. However, the dynamic debug interfaces should really only be defined if CONFIG_DYNAMIC_DEBUG is set or CONFIG_DYNAMIC_CORE is set along with DYNAMIC_DEBUG_MODULE, (see: Documentation/admin-guide/dynamic-debug-howto.rst). Thus, the undefined case becomes: !((CONFIG_DYNAMIC_DEBUG || (CONFIG_DYNAMIC_CORE && DYNAMIC_DEBUG_MODULE)). With those changes in place, we can remove the !CONFIG_DYNAMIC_CORE case from ib_srp.c This change was prompted by a build breakeage in ib_srp.c stemming from the inclusion of dynamic_debug.h unconditionally in module.h, due to commit7deabd6749
("dyndbg: use the module notifier callbacks"). In that case, if we have CONFIG_DYNAMIC_CORE=y and CONFIG_DYNAMIC_DEBUG=n then the definitions for DEFINE_DYNAMIC_DEBUG_METADATA() and DYNAMIC_DEBUG_BRANCH() are defined once in ib_srp.c and then again in the dynamic_debug.h. This had been working prior to the above referenced commit because dynamic_debug.h was only pulled into ib_srp.c conditinally via printk.h if CONFIG_DYNAMIC_DEBUG was set. Also, the exported functions in lib/dynamic_debug.c itself may not have a prototype if CONFIG_DYNAMIC_DEBUG=n and CONFIG_DYNAMIC_CORE=y. This would trigger the -Wmissing-prototypes warning. The exported functions are behind (include/linux/dynamic_debug.h): if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) Thus, by adding -DDYNAMIC_CONFIG_MODULE to the lib/Makefile we can ensure that the exported functions have a prototype in all cases, since lib/dynamic_debug.c is built whenever CONFIG_DYNAMIC_DEBUG_CORE=y. Fixes:7deabd6749
("dyndbg: use the module notifier callbacks") Reported-by: kernel test robot <lkp@intel.com> Link: https://lore.kernel.org/oe-kbuild-all/202303071444.sIbZTDCy-lkp@intel.com/ Signed-off-by: Jason Baron <jbaron@akamai.com> [mcgrof: adjust commit log, and remove urldefense from URL] Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
parent
557aafac11
commit
7ce9372909
@ -62,11 +62,6 @@ MODULE_AUTHOR("Roland Dreier");
|
|||||||
MODULE_DESCRIPTION("InfiniBand SCSI RDMA Protocol initiator");
|
MODULE_DESCRIPTION("InfiniBand SCSI RDMA Protocol initiator");
|
||||||
MODULE_LICENSE("Dual BSD/GPL");
|
MODULE_LICENSE("Dual BSD/GPL");
|
||||||
|
|
||||||
#if !defined(CONFIG_DYNAMIC_DEBUG)
|
|
||||||
#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt)
|
|
||||||
#define DYNAMIC_DEBUG_BRANCH(descriptor) false
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static unsigned int srp_sg_tablesize;
|
static unsigned int srp_sg_tablesize;
|
||||||
static unsigned int cmd_sg_entries;
|
static unsigned int cmd_sg_entries;
|
||||||
static unsigned int indirect_sg_entries;
|
static unsigned int indirect_sg_entries;
|
||||||
|
@ -128,14 +128,16 @@ struct ddebug_class_param {
|
|||||||
const struct ddebug_class_map *map;
|
const struct ddebug_class_map *map;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(CONFIG_DYNAMIC_DEBUG_CORE)
|
/*
|
||||||
|
* pr_debug() and friends are globally enabled or modules have selectively
|
||||||
|
* enabled them.
|
||||||
|
*/
|
||||||
|
#if defined(CONFIG_DYNAMIC_DEBUG) || \
|
||||||
|
(defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
|
||||||
|
|
||||||
extern __printf(2, 3)
|
extern __printf(2, 3)
|
||||||
void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
|
void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
|
||||||
|
|
||||||
extern int ddebug_dyndbg_module_param_cb(char *param, char *val,
|
|
||||||
const char *modname);
|
|
||||||
|
|
||||||
struct device;
|
struct device;
|
||||||
|
|
||||||
extern __printf(3, 4)
|
extern __printf(3, 4)
|
||||||
@ -284,10 +286,6 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
|
|||||||
KERN_DEBUG, prefix_str, prefix_type, \
|
KERN_DEBUG, prefix_str, prefix_type, \
|
||||||
rowsize, groupsize, buf, len, ascii)
|
rowsize, groupsize, buf, len, ascii)
|
||||||
|
|
||||||
struct kernel_param;
|
|
||||||
int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp);
|
|
||||||
int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp);
|
|
||||||
|
|
||||||
/* for test only, generally expect drm.debug style macro wrappers */
|
/* for test only, generally expect drm.debug style macro wrappers */
|
||||||
#define __pr_debug_cls(cls, fmt, ...) do { \
|
#define __pr_debug_cls(cls, fmt, ...) do { \
|
||||||
BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \
|
BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \
|
||||||
@ -295,12 +293,39 @@ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp);
|
|||||||
dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__); \
|
dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#else /* !CONFIG_DYNAMIC_DEBUG_CORE */
|
#else /* !(CONFIG_DYNAMIC_DEBUG || (CONFIG_DYNAMIC_DEBUG_CORE && DYNAMIC_DEBUG_MODULE)) */
|
||||||
|
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/printk.h>
|
#include <linux/printk.h>
|
||||||
|
|
||||||
|
#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt)
|
||||||
|
#define DYNAMIC_DEBUG_BRANCH(descriptor) false
|
||||||
|
|
||||||
|
#define dynamic_pr_debug(fmt, ...) \
|
||||||
|
do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0)
|
||||||
|
#define dynamic_dev_dbg(dev, fmt, ...) \
|
||||||
|
do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0)
|
||||||
|
#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
|
||||||
|
groupsize, buf, len, ascii) \
|
||||||
|
do { if (0) \
|
||||||
|
print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, \
|
||||||
|
rowsize, groupsize, buf, len, ascii); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif /* CONFIG_DYNAMIC_DEBUG || (CONFIG_DYNAMIC_DEBUG_CORE && DYNAMIC_DEBUG_MODULE) */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_DYNAMIC_DEBUG_CORE
|
||||||
|
|
||||||
|
extern int ddebug_dyndbg_module_param_cb(char *param, char *val,
|
||||||
|
const char *modname);
|
||||||
|
struct kernel_param;
|
||||||
|
int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp);
|
||||||
|
int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
static inline int ddebug_dyndbg_module_param_cb(char *param, char *val,
|
static inline int ddebug_dyndbg_module_param_cb(char *param, char *val,
|
||||||
const char *modname)
|
const char *modname)
|
||||||
{
|
{
|
||||||
@ -313,25 +338,15 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define dynamic_pr_debug(fmt, ...) \
|
|
||||||
do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0)
|
|
||||||
#define dynamic_dev_dbg(dev, fmt, ...) \
|
|
||||||
do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0)
|
|
||||||
#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
|
|
||||||
groupsize, buf, len, ascii) \
|
|
||||||
do { if (0) \
|
|
||||||
print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, \
|
|
||||||
rowsize, groupsize, buf, len, ascii); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
struct kernel_param;
|
struct kernel_param;
|
||||||
static inline int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp)
|
static inline int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp)
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
static inline int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp)
|
static inline int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp)
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
#endif /* !CONFIG_DYNAMIC_DEBUG_CORE */
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern const struct kernel_param_ops param_ops_dyndbg_classes;
|
extern const struct kernel_param_ops param_ops_dyndbg_classes;
|
||||||
|
|
||||||
#endif
|
#endif /* _DYNAMIC_DEBUG_H */
|
||||||
|
@ -231,6 +231,9 @@ lib-$(CONFIG_GENERIC_BUG) += bug.o
|
|||||||
obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
|
obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
|
||||||
|
|
||||||
obj-$(CONFIG_DYNAMIC_DEBUG_CORE) += dynamic_debug.o
|
obj-$(CONFIG_DYNAMIC_DEBUG_CORE) += dynamic_debug.o
|
||||||
|
#ensure exported functions have prototypes
|
||||||
|
CFLAGS_dynamic_debug.o := -DDYNAMIC_DEBUG_MODULE
|
||||||
|
|
||||||
obj-$(CONFIG_SYMBOLIC_ERRNAME) += errname.o
|
obj-$(CONFIG_SYMBOLIC_ERRNAME) += errname.o
|
||||||
|
|
||||||
obj-$(CONFIG_NLATTR) += nlattr.o
|
obj-$(CONFIG_NLATTR) += nlattr.o
|
||||||
|
Loading…
Reference in New Issue
Block a user