aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/dynamic-debug-howto.txt184
-rw-r--r--Documentation/kernel-parameters.txt7
-rw-r--r--lib/Kconfig.debug17
3 files changed, 138 insertions, 70 deletions
diff --git a/Documentation/dynamic-debug-howto.txt b/Documentation/dynamic-debug-howto.txt
index 74e6c7782678..6e1684981da2 100644
--- a/Documentation/dynamic-debug-howto.txt
+++ b/Documentation/dynamic-debug-howto.txt
@@ -2,17 +2,17 @@
2Introduction 2Introduction
3============ 3============
4 4
5This document describes how to use the dynamic debug (ddebug) feature. 5This document describes how to use the dynamic debug (dyndbg) feature.
6 6
7Dynamic debug is designed to allow you to dynamically enable/disable kernel 7Dynamic debug is designed to allow you to dynamically enable/disable
8code to obtain additional kernel information. Currently, if 8kernel code to obtain additional kernel information. Currently, if
9CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_dbg() calls can be 9CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_dbg() calls can
10dynamically enabled per-callsite. 10be dynamically enabled per-callsite.
11 11
12Dynamic debug has even more useful features: 12Dynamic debug has even more useful features:
13 13
14 * Simple query language allows turning on and off debugging statements by 14 * Simple query language allows turning on and off debugging
15 matching any combination of 0 or 1 of: 15 statements by matching any combination of 0 or 1 of:
16 16
17 - source filename 17 - source filename
18 - function name 18 - function name
@@ -20,17 +20,19 @@ Dynamic debug has even more useful features:
20 - module name 20 - module name
21 - format string 21 - format string
22 22
23 * Provides a debugfs control file: <debugfs>/dynamic_debug/control which can be 23 * Provides a debugfs control file: <debugfs>/dynamic_debug/control
24 read to display the complete list of known debug statements, to help guide you 24 which can be read to display the complete list of known debug
25 statements, to help guide you
25 26
26Controlling dynamic debug Behaviour 27Controlling dynamic debug Behaviour
27=================================== 28===================================
28 29
29The behaviour of pr_debug()/dev_dbg()s are controlled via writing to a 30The behaviour of pr_debug()/dev_dbg()s are controlled via writing to a
30control file in the 'debugfs' filesystem. Thus, you must first mount the debugfs 31control file in the 'debugfs' filesystem. Thus, you must first mount
31filesystem, in order to make use of this feature. Subsequently, we refer to the 32the debugfs filesystem, in order to make use of this feature.
32control file as: <debugfs>/dynamic_debug/control. For example, if you want to 33Subsequently, we refer to the control file as:
33enable printing from source file 'svcsock.c', line 1603 you simply do: 34<debugfs>/dynamic_debug/control. For example, if you want to enable
35printing from source file 'svcsock.c', line 1603 you simply do:
34 36
35nullarbor:~ # echo 'file svcsock.c line 1603 +p' > 37nullarbor:~ # echo 'file svcsock.c line 1603 +p' >
36 <debugfs>/dynamic_debug/control 38 <debugfs>/dynamic_debug/control
@@ -44,15 +46,15 @@ nullarbor:~ # echo 'file svcsock.c wtf 1 +p' >
44Viewing Dynamic Debug Behaviour 46Viewing Dynamic Debug Behaviour
45=========================== 47===========================
46 48
47You can view the currently configured behaviour of all the debug statements 49You can view the currently configured behaviour of all the debug
48via: 50statements via:
49 51
50nullarbor:~ # cat <debugfs>/dynamic_debug/control 52nullarbor:~ # cat <debugfs>/dynamic_debug/control
51# filename:lineno [module]function flags format 53# filename:lineno [module]function flags format
52/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup - "SVCRDMA Module Removed, deregister RPC RDMA transport\012" 54/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012"
53/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init - "\011max_inline : %d\012" 55/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline : %d\012"
54/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init - "\011sq_depth : %d\012" 56/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =_ "\011sq_depth : %d\012"
55/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init - "\011max_requests : %d\012" 57/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =_ "\011max_requests : %d\012"
56... 58...
57 59
58 60
@@ -65,12 +67,12 @@ nullarbor:~ # grep -i rdma <debugfs>/dynamic_debug/control | wc -l
65nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l 67nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l
6642 6842
67 69
68Note in particular that the third column shows the enabled behaviour 70The third column shows the currently enabled flags for each debug
69flags for each debug statement callsite (see below for definitions of the 71statement callsite (see below for definitions of the flags). The
70flags). The default value, no extra behaviour enabled, is "-". So 72default value, with no flags enabled, is "=_". So you can view all
71you can view all the debug statement callsites with any non-default flags: 73the debug statement callsites with any non-default flags:
72 74
73nullarbor:~ # awk '$3 != "-"' <debugfs>/dynamic_debug/control 75nullarbor:~ # awk '$3 != "=_"' <debugfs>/dynamic_debug/control
74# filename:lineno [module]function flags format 76# filename:lineno [module]function flags format
75/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012" 77/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012"
76 78
@@ -103,15 +105,14 @@ specifications, followed by a flags change specification.
103 105
104command ::= match-spec* flags-spec 106command ::= match-spec* flags-spec
105 107
106The match-spec's are used to choose a subset of the known dprintk() 108The match-spec's are used to choose a subset of the known pr_debug()
107callsites to which to apply the flags-spec. Think of them as a query 109callsites to which to apply the flags-spec. Think of them as a query
108with implicit ANDs between each pair. Note that an empty list of 110with implicit ANDs between each pair. Note that an empty list of
109match-specs is possible, but is not very useful because it will not 111match-specs will select all debug statement callsites.
110match any debug statement callsites.
111 112
112A match specification comprises a keyword, which controls the attribute 113A match specification comprises a keyword, which controls the
113of the callsite to be compared, and a value to compare against. Possible 114attribute of the callsite to be compared, and a value to compare
114keywords are: 115against. Possible keywords are:
115 116
116match-spec ::= 'func' string | 117match-spec ::= 'func' string |
117 'file' string | 118 'file' string |
@@ -164,15 +165,15 @@ format
164 characters (") or single quote characters ('). 165 characters (") or single quote characters (').
165 Examples: 166 Examples:
166 167
167 format svcrdma: // many of the NFS/RDMA server dprintks 168 format svcrdma: // many of the NFS/RDMA server pr_debugs
168 format readahead // some dprintks in the readahead cache 169 format readahead // some pr_debugs in the readahead cache
169 format nfsd:\040SETATTR // one way to match a format with whitespace 170 format nfsd:\040SETATTR // one way to match a format with whitespace
170 format "nfsd: SETATTR" // a neater way to match a format with whitespace 171 format "nfsd: SETATTR" // a neater way to match a format with whitespace
171 format 'nfsd: SETATTR' // yet another way to match a format with whitespace 172 format 'nfsd: SETATTR' // yet another way to match a format with whitespace
172 173
173line 174line
174 The given line number or range of line numbers is compared 175 The given line number or range of line numbers is compared
175 against the line number of each dprintk() callsite. A single 176 against the line number of each pr_debug() callsite. A single
176 line number matches the callsite line number exactly. A 177 line number matches the callsite line number exactly. A
177 range of line numbers matches any callsite between the first 178 range of line numbers matches any callsite between the first
178 and last line number inclusive. An empty first number means 179 and last line number inclusive. An empty first number means
@@ -188,51 +189,93 @@ The flags specification comprises a change operation followed
188by one or more flag characters. The change operation is one 189by one or more flag characters. The change operation is one
189of the characters: 190of the characters:
190 191
191- 192 - remove the given flags
192 remove the given flags 193 + add the given flags
193 194 = set the flags to the given flags
194+
195 add the given flags
196
197=
198 set the flags to the given flags
199 195
200The flags are: 196The flags are:
201 197
202f 198 p enables the pr_debug() callsite.
203 Include the function name in the printed message 199 f Include the function name in the printed message
204l 200 l Include line number in the printed message
205 Include line number in the printed message 201 m Include module name in the printed message
206m 202 t Include thread ID in messages not generated from interrupt context
207 Include module name in the printed message 203 _ No flags are set. (Or'd with others on input)
208p 204
209 Causes a printk() message to be emitted to dmesg 205For display, the flags are preceded by '='
210t 206(mnemonic: what the flags are currently equal to).
211 Include thread ID in messages not generated from interrupt context
212 207
213Note the regexp ^[-+=][flmpt]+$ matches a flags specification. 208Note the regexp ^[-+=][flmpt_]+$ matches a flags specification.
214Note also that there is no convenient syntax to remove all 209To clear all flags at once, use "=_" or "-flmpt".
215the flags at once, you need to use "-flmpt".
216 210
217 211
218Debug messages during boot process 212Debug messages during Boot Process
219================================== 213==================================
220 214
221To be able to activate debug messages during the boot process, 215To activate debug messages for core code and built-in modules during
222even before userspace and debugfs exists, use the boot parameter: 216the boot process, even before userspace and debugfs exists, use
223ddebug_query="QUERY" 217dyndbg="QUERY", module.dyndbg="QUERY", or ddebug_query="QUERY"
218(ddebug_query is obsoleted by dyndbg, and deprecated). QUERY follows
219the syntax described above, but must not exceed 1023 characters. Your
220bootloader may impose lower limits.
221
222These dyndbg params are processed just after the ddebug tables are
223processed, as part of the arch_initcall. Thus you can enable debug
224messages in all code run after this arch_initcall via this boot
225parameter.
224 226
225QUERY follows the syntax described above, but must not exceed 1023
226characters. The enablement of debug messages is done as an arch_initcall.
227Thus you can enable debug messages in all code processed after this
228arch_initcall via this boot parameter.
229On an x86 system for example ACPI enablement is a subsys_initcall and 227On an x86 system for example ACPI enablement is a subsys_initcall and
230ddebug_query="file ec.c +p" 228 dyndbg="file ec.c +p"
231will show early Embedded Controller transactions during ACPI setup if 229will show early Embedded Controller transactions during ACPI setup if
232your machine (typically a laptop) has an Embedded Controller. 230your machine (typically a laptop) has an Embedded Controller.
233PCI (or other devices) initialization also is a hot candidate for using 231PCI (or other devices) initialization also is a hot candidate for using
234this boot parameter for debugging purposes. 232this boot parameter for debugging purposes.
235 233
234If foo module is not built-in, foo.dyndbg will still be processed at
235boot time, without effect, but will be reprocessed when module is
236loaded later. dyndbg_query= and bare dyndbg= are only processed at
237boot.
238
239
240Debug Messages at Module Initialization Time
241============================================
242
243When "modprobe foo" is called, modprobe scans /proc/cmdline for
244foo.params, strips "foo.", and passes them to the kernel along with
245params given in modprobe args or /etc/modprob.d/*.conf files,
246in the following order:
247
2481. # parameters given via /etc/modprobe.d/*.conf
249 options foo dyndbg=+pt
250 options foo dyndbg # defaults to +p
251
2522. # foo.dyndbg as given in boot args, "foo." is stripped and passed
253 foo.dyndbg=" func bar +p; func buz +mp"
254
2553. # args to modprobe
256 modprobe foo dyndbg==pmf # override previous settings
257
258These dyndbg queries are applied in order, with last having final say.
259This allows boot args to override or modify those from /etc/modprobe.d
260(sensible, since 1 is system wide, 2 is kernel or boot specific), and
261modprobe args to override both.
262
263In the foo.dyndbg="QUERY" form, the query must exclude "module foo".
264"foo" is extracted from the param-name, and applied to each query in
265"QUERY", and only 1 match-spec of each type is allowed.
266
267The dyndbg option is a "fake" module parameter, which means:
268
269- modules do not need to define it explicitly
270- every module gets it tacitly, whether they use pr_debug or not
271- it doesnt appear in /sys/module/$module/parameters/
272 To see it, grep the control file, or inspect /proc/cmdline.
273
274For CONFIG_DYNAMIC_DEBUG kernels, any settings given at boot-time (or
275enabled by -DDEBUG flag during compilation) can be disabled later via
276the sysfs interface if the debug messages are no longer needed:
277
278 echo "module module_name -p" > <debugfs>/dynamic_debug/control
236 279
237Examples 280Examples
238======== 281========
@@ -260,3 +303,18 @@ nullarbor:~ # echo -n 'func svc_process -p' >
260// enable messages for NFS calls READ, READLINK, READDIR and READDIR+. 303// enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
261nullarbor:~ # echo -n 'format "nfsd: READ" +p' > 304nullarbor:~ # echo -n 'format "nfsd: READ" +p' >
262 <debugfs>/dynamic_debug/control 305 <debugfs>/dynamic_debug/control
306
307// enable all messages
308nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control
309
310// add module, function to all enabled messages
311nullarbor:~ # echo -n '+mf' > <debugfs>/dynamic_debug/control
312
313// boot-args example, with newlines and comments for readability
314Kernel command line: ...
315 // see whats going on in dyndbg=value processing
316 dynamic_debug.verbose=1
317 // enable pr_debugs in 2 builtins, #cmt is stripped
318 dyndbg="module params +p #cmt ; module sys +p"
319 // enable pr_debugs in 2 functions in a module loaded later
320 pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p"
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index c1601e5a8b71..d224225616b7 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -610,7 +610,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
610 610
611 ddebug_query= [KNL,DYNAMIC_DEBUG] Enable debug messages at early boot 611 ddebug_query= [KNL,DYNAMIC_DEBUG] Enable debug messages at early boot
612 time. See Documentation/dynamic-debug-howto.txt for 612 time. See Documentation/dynamic-debug-howto.txt for
613 details. 613 details. Deprecated, see dyndbg.
614 614
615 debug [KNL] Enable kernel debugging (events log level). 615 debug [KNL] Enable kernel debugging (events log level).
616 616
@@ -730,6 +730,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
730 730
731 dscc4.setup= [NET] 731 dscc4.setup= [NET]
732 732
733 dyndbg[="val"] [KNL,DYNAMIC_DEBUG]
734 module.dyndbg[="val"]
735 Enable debug messages at boot time. See
736 Documentation/dynamic-debug-howto.txt for details.
737
733 earlycon= [KNL] Output early console device and options. 738 earlycon= [KNL] Output early console device and options.
734 uart[8250],io,<addr>[,options] 739 uart[8250],io,<addr>[,options]
735 uart[8250],mmio,<addr>[,options] 740 uart[8250],mmio,<addr>[,options]
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 6777153f18f3..ef8192bc0c33 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1205,8 +1205,13 @@ config DYNAMIC_DEBUG
1205 otherwise be available at runtime. These messages can then be 1205 otherwise be available at runtime. These messages can then be
1206 enabled/disabled based on various levels of scope - per source file, 1206 enabled/disabled based on various levels of scope - per source file,
1207 function, module, format string, and line number. This mechanism 1207 function, module, format string, and line number. This mechanism
1208 implicitly enables all pr_debug() and dev_dbg() calls. The impact of 1208 implicitly compiles in all pr_debug() and dev_dbg() calls, which
1209 this compile option is a larger kernel text size of about 2%. 1209 enlarges the kernel text size by about 2%.
1210
1211 If a source file is compiled with DEBUG flag set, any
1212 pr_debug() calls in it are enabled by default, but can be
1213 disabled at runtime as below. Note that DEBUG flag is
1214 turned on by many CONFIG_*DEBUG* options.
1210 1215
1211 Usage: 1216 Usage:
1212 1217
@@ -1223,16 +1228,16 @@ config DYNAMIC_DEBUG
1223 lineno : line number of the debug statement 1228 lineno : line number of the debug statement
1224 module : module that contains the debug statement 1229 module : module that contains the debug statement
1225 function : function that contains the debug statement 1230 function : function that contains the debug statement
1226 flags : 'p' means the line is turned 'on' for printing 1231 flags : '=p' means the line is turned 'on' for printing
1227 format : the format used for the debug statement 1232 format : the format used for the debug statement
1228 1233
1229 From a live system: 1234 From a live system:
1230 1235
1231 nullarbor:~ # cat <debugfs>/dynamic_debug/control 1236 nullarbor:~ # cat <debugfs>/dynamic_debug/control
1232 # filename:lineno [module]function flags format 1237 # filename:lineno [module]function flags format
1233 fs/aio.c:222 [aio]__put_ioctx - "__put_ioctx:\040freeing\040%p\012" 1238 fs/aio.c:222 [aio]__put_ioctx =_ "__put_ioctx:\040freeing\040%p\012"
1234 fs/aio.c:248 [aio]ioctx_alloc - "ENOMEM:\040nr_events\040too\040high\012" 1239 fs/aio.c:248 [aio]ioctx_alloc =_ "ENOMEM:\040nr_events\040too\040high\012"
1235 fs/aio.c:1770 [aio]sys_io_cancel - "calling\040cancel\012" 1240 fs/aio.c:1770 [aio]sys_io_cancel =_ "calling\040cancel\012"
1236 1241
1237 Example usage: 1242 Example usage:
1238 1243