diff options
-rw-r--r-- | Documentation/dynamic-debug-howto.txt | 184 | ||||
-rw-r--r-- | Documentation/kernel-parameters.txt | 7 | ||||
-rw-r--r-- | lib/Kconfig.debug | 17 |
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 @@ | |||
2 | Introduction | 2 | Introduction |
3 | ============ | 3 | ============ |
4 | 4 | ||
5 | This document describes how to use the dynamic debug (ddebug) feature. | 5 | This document describes how to use the dynamic debug (dyndbg) feature. |
6 | 6 | ||
7 | Dynamic debug is designed to allow you to dynamically enable/disable kernel | 7 | Dynamic debug is designed to allow you to dynamically enable/disable |
8 | code to obtain additional kernel information. Currently, if | 8 | kernel code to obtain additional kernel information. Currently, if |
9 | CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_dbg() calls can be | 9 | CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_dbg() calls can |
10 | dynamically enabled per-callsite. | 10 | be dynamically enabled per-callsite. |
11 | 11 | ||
12 | Dynamic debug has even more useful features: | 12 | Dynamic 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 | ||
26 | Controlling dynamic debug Behaviour | 27 | Controlling dynamic debug Behaviour |
27 | =================================== | 28 | =================================== |
28 | 29 | ||
29 | The behaviour of pr_debug()/dev_dbg()s are controlled via writing to a | 30 | The behaviour of pr_debug()/dev_dbg()s are controlled via writing to a |
30 | control file in the 'debugfs' filesystem. Thus, you must first mount the debugfs | 31 | control file in the 'debugfs' filesystem. Thus, you must first mount |
31 | filesystem, in order to make use of this feature. Subsequently, we refer to the | 32 | the debugfs filesystem, in order to make use of this feature. |
32 | control file as: <debugfs>/dynamic_debug/control. For example, if you want to | 33 | Subsequently, we refer to the control file as: |
33 | enable printing from source file 'svcsock.c', line 1603 you simply do: | 34 | <debugfs>/dynamic_debug/control. For example, if you want to enable |
35 | printing from source file 'svcsock.c', line 1603 you simply do: | ||
34 | 36 | ||
35 | nullarbor:~ # echo 'file svcsock.c line 1603 +p' > | 37 | nullarbor:~ # 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' > | |||
44 | Viewing Dynamic Debug Behaviour | 46 | Viewing Dynamic Debug Behaviour |
45 | =========================== | 47 | =========================== |
46 | 48 | ||
47 | You can view the currently configured behaviour of all the debug statements | 49 | You can view the currently configured behaviour of all the debug |
48 | via: | 50 | statements via: |
49 | 51 | ||
50 | nullarbor:~ # cat <debugfs>/dynamic_debug/control | 52 | nullarbor:~ # 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 | |||
65 | nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l | 67 | nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l |
66 | 42 | 68 | 42 |
67 | 69 | ||
68 | Note in particular that the third column shows the enabled behaviour | 70 | The third column shows the currently enabled flags for each debug |
69 | flags for each debug statement callsite (see below for definitions of the | 71 | statement callsite (see below for definitions of the flags). The |
70 | flags). The default value, no extra behaviour enabled, is "-". So | 72 | default value, with no flags enabled, is "=_". So you can view all |
71 | you can view all the debug statement callsites with any non-default flags: | 73 | the debug statement callsites with any non-default flags: |
72 | 74 | ||
73 | nullarbor:~ # awk '$3 != "-"' <debugfs>/dynamic_debug/control | 75 | nullarbor:~ # 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 | ||
104 | command ::= match-spec* flags-spec | 106 | command ::= match-spec* flags-spec |
105 | 107 | ||
106 | The match-spec's are used to choose a subset of the known dprintk() | 108 | The match-spec's are used to choose a subset of the known pr_debug() |
107 | callsites to which to apply the flags-spec. Think of them as a query | 109 | callsites to which to apply the flags-spec. Think of them as a query |
108 | with implicit ANDs between each pair. Note that an empty list of | 110 | with implicit ANDs between each pair. Note that an empty list of |
109 | match-specs is possible, but is not very useful because it will not | 111 | match-specs will select all debug statement callsites. |
110 | match any debug statement callsites. | ||
111 | 112 | ||
112 | A match specification comprises a keyword, which controls the attribute | 113 | A match specification comprises a keyword, which controls the |
113 | of the callsite to be compared, and a value to compare against. Possible | 114 | attribute of the callsite to be compared, and a value to compare |
114 | keywords are: | 115 | against. Possible keywords are: |
115 | 116 | ||
116 | match-spec ::= 'func' string | | 117 | match-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 | ||
173 | line | 174 | line |
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 | |||
188 | by one or more flag characters. The change operation is one | 189 | by one or more flag characters. The change operation is one |
189 | of the characters: | 190 | of 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 | ||
200 | The flags are: | 196 | The flags are: |
201 | 197 | ||
202 | f | 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 |
204 | l | 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 |
206 | m | 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) |
208 | p | 204 | |
209 | Causes a printk() message to be emitted to dmesg | 205 | For display, the flags are preceded by '=' |
210 | t | 206 | (mnemonic: what the flags are currently equal to). |
211 | Include thread ID in messages not generated from interrupt context | ||
212 | 207 | ||
213 | Note the regexp ^[-+=][flmpt]+$ matches a flags specification. | 208 | Note the regexp ^[-+=][flmpt_]+$ matches a flags specification. |
214 | Note also that there is no convenient syntax to remove all | 209 | To clear all flags at once, use "=_" or "-flmpt". |
215 | the flags at once, you need to use "-flmpt". | ||
216 | 210 | ||
217 | 211 | ||
218 | Debug messages during boot process | 212 | Debug messages during Boot Process |
219 | ================================== | 213 | ================================== |
220 | 214 | ||
221 | To be able to activate debug messages during the boot process, | 215 | To activate debug messages for core code and built-in modules during |
222 | even before userspace and debugfs exists, use the boot parameter: | 216 | the boot process, even before userspace and debugfs exists, use |
223 | ddebug_query="QUERY" | 217 | dyndbg="QUERY", module.dyndbg="QUERY", or ddebug_query="QUERY" |
218 | (ddebug_query is obsoleted by dyndbg, and deprecated). QUERY follows | ||
219 | the syntax described above, but must not exceed 1023 characters. Your | ||
220 | bootloader may impose lower limits. | ||
221 | |||
222 | These dyndbg params are processed just after the ddebug tables are | ||
223 | processed, as part of the arch_initcall. Thus you can enable debug | ||
224 | messages in all code run after this arch_initcall via this boot | ||
225 | parameter. | ||
224 | 226 | ||
225 | QUERY follows the syntax described above, but must not exceed 1023 | ||
226 | characters. The enablement of debug messages is done as an arch_initcall. | ||
227 | Thus you can enable debug messages in all code processed after this | ||
228 | arch_initcall via this boot parameter. | ||
229 | On an x86 system for example ACPI enablement is a subsys_initcall and | 227 | On an x86 system for example ACPI enablement is a subsys_initcall and |
230 | ddebug_query="file ec.c +p" | 228 | dyndbg="file ec.c +p" |
231 | will show early Embedded Controller transactions during ACPI setup if | 229 | will show early Embedded Controller transactions during ACPI setup if |
232 | your machine (typically a laptop) has an Embedded Controller. | 230 | your machine (typically a laptop) has an Embedded Controller. |
233 | PCI (or other devices) initialization also is a hot candidate for using | 231 | PCI (or other devices) initialization also is a hot candidate for using |
234 | this boot parameter for debugging purposes. | 232 | this boot parameter for debugging purposes. |
235 | 233 | ||
234 | If foo module is not built-in, foo.dyndbg will still be processed at | ||
235 | boot time, without effect, but will be reprocessed when module is | ||
236 | loaded later. dyndbg_query= and bare dyndbg= are only processed at | ||
237 | boot. | ||
238 | |||
239 | |||
240 | Debug Messages at Module Initialization Time | ||
241 | ============================================ | ||
242 | |||
243 | When "modprobe foo" is called, modprobe scans /proc/cmdline for | ||
244 | foo.params, strips "foo.", and passes them to the kernel along with | ||
245 | params given in modprobe args or /etc/modprob.d/*.conf files, | ||
246 | in the following order: | ||
247 | |||
248 | 1. # parameters given via /etc/modprobe.d/*.conf | ||
249 | options foo dyndbg=+pt | ||
250 | options foo dyndbg # defaults to +p | ||
251 | |||
252 | 2. # foo.dyndbg as given in boot args, "foo." is stripped and passed | ||
253 | foo.dyndbg=" func bar +p; func buz +mp" | ||
254 | |||
255 | 3. # args to modprobe | ||
256 | modprobe foo dyndbg==pmf # override previous settings | ||
257 | |||
258 | These dyndbg queries are applied in order, with last having final say. | ||
259 | This 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 | ||
261 | modprobe args to override both. | ||
262 | |||
263 | In 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 | |||
267 | The 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 | |||
274 | For CONFIG_DYNAMIC_DEBUG kernels, any settings given at boot-time (or | ||
275 | enabled by -DDEBUG flag during compilation) can be disabled later via | ||
276 | the sysfs interface if the debug messages are no longer needed: | ||
277 | |||
278 | echo "module module_name -p" > <debugfs>/dynamic_debug/control | ||
236 | 279 | ||
237 | Examples | 280 | Examples |
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+. |
261 | nullarbor:~ # echo -n 'format "nfsd: READ" +p' > | 304 | nullarbor:~ # echo -n 'format "nfsd: READ" +p' > |
262 | <debugfs>/dynamic_debug/control | 305 | <debugfs>/dynamic_debug/control |
306 | |||
307 | // enable all messages | ||
308 | nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control | ||
309 | |||
310 | // add module, function to all enabled messages | ||
311 | nullarbor:~ # echo -n '+mf' > <debugfs>/dynamic_debug/control | ||
312 | |||
313 | // boot-args example, with newlines and comments for readability | ||
314 | Kernel 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 | ||