Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sunrpc: add a Kconfig option to redirect dfprintk() output to trace buffer

We have a lot of old dprintk() call sites that aren't going anywhere
anytime soon. At the same time, turning them up is a serious burden on
the host due to the console locking overhead.

Add a new Kconfig option that redirects dfprintk() output to the trace
buffer. This is more efficient than logging to the console and allows
for proper interleaving of dprintk and static tracepoint events.

Since using trace_printk() causes scary warnings to pop at boot time,
this new option defaults to "n".

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>

authored by

Jeff Layton and committed by
Anna Schumaker
ec7d8e68 9082aae1

+22 -2
+8 -2
include/linux/sunrpc/debug.h
··· 30 30 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 31 31 # define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac)) 32 32 33 + # if IS_ENABLED(CONFIG_SUNRPC_DEBUG_TRACE) 34 + # define __sunrpc_printk(fmt, ...) trace_printk(fmt, ##__VA_ARGS__) 35 + # else 36 + # define __sunrpc_printk(fmt, ...) printk(KERN_DEFAULT fmt, ##__VA_ARGS__) 37 + # endif 38 + 33 39 # define dfprintk(fac, fmt, ...) \ 34 40 do { \ 35 41 ifdebug(fac) \ 36 - printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \ 42 + __sunrpc_printk(fmt, ##__VA_ARGS__); \ 37 43 } while (0) 38 44 39 45 # define dfprintk_rcu(fac, fmt, ...) \ 40 46 do { \ 41 47 ifdebug(fac) { \ 42 48 rcu_read_lock(); \ 43 - printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \ 49 + __sunrpc_printk(fmt, ##__VA_ARGS__); \ 44 50 rcu_read_unlock(); \ 45 51 } \ 46 52 } while (0)
+14
net/sunrpc/Kconfig
··· 101 101 102 102 If unsure, say Y. 103 103 104 + config SUNRPC_DEBUG_TRACE 105 + bool "RPC: Send dfprintk() output to the trace buffer" 106 + depends on SUNRPC_DEBUG && TRACING 107 + default n 108 + help 109 + dprintk() output can be voluminous, which can overwhelm the 110 + kernel's logging facility as it must be sent to the console. 111 + This option causes dprintk() output to go to the trace buffer 112 + instead of the kernel log. 113 + 114 + This will cause warnings about trace_printk() being used to be 115 + logged at boot time, so say N unless you are debugging a problem 116 + with sunrpc-based clients or services. 117 + 104 118 config SUNRPC_XPRT_RDMA 105 119 tristate "RPC-over-RDMA transport" 106 120 depends on SUNRPC && INFINIBAND && INFINIBAND_ADDR_TRANS