[patch 00/25] dynamic_debug: multiple, pending queries in boot-arg
From: Jim Cromie
Date: Mon Jul 25 2011 - 17:48:55 EST
This patchset extends dynamic-debug facility to allow
use of pr_debug() within a loadable module's module_init()
function. Query/rules can be given on the boot-line,
and are saved to a pending list if they cannot be applied
immediately. Later, when the module is being loaded, the
pending list is scanned, and matching rules are applied.
Thus pr_debug() calls in the module's initialization function
are active when it is invoked.
Changes since rev1:
- rebased on top of Jasons & Joes patchset
- fixed accidental unescape removal, noted by Bart
- trim src-path patch checks for matching prefix before trimming
should now work for out-of-tree modules.
- undid verbose newline-strip in exec-queries - Bart
- verbose param 644, not 744 - Bart, Greg
- whitespace - Bart
- added 'a' flag - Jason, Bart
- drop pending_max - Bart
Changes since rev2:
1. lock around all list-work, pending-ct
In response to Bart's locking-bug observation, I hoisted locks up to
callers, so theyd protect all list, pending-ct manipulation. This
means longer hold-times, but less locking/unlocking. Left as separate
patch for now, partly cuz having pr_info's under lock gave me some
heartburn. That said, lockdep didnt complain. I think I got the
interim patches correct too.
Ive extended flags spec to have <match-flags>* <op> <new-flags>*
IE, matching /[pmflta]*[+-=][pmflta]*/
match-flags (optional) allows a query/rule to be more selective, which
increases the utility of otherwise unconstrained rules. So the
following query matches all call-sites that are already enabled,
adding the TID flag.
$> echo " p+t " > <dbgfs>/dynamic_debug/control
3. 'a' pending query modification, removal
Real purpose of 2 was to allow modification or deletion of currently
$> echo "module foo +ap" > <debugfs>/dynamic_debug/control
$> echo "module foo +apt" > <debugfs>/dynamic_debug/control
$> echo "module foo ap=_" > <debugfs>/dynamic_debug/control
1st command adds a pending query on module foo
2nd command modifies it by adding a TID flag
3rd command deletes the pending query by setting flags to 0
Note that 2,3 have exact match on the query-spec, the match-flags in 3
specify flags required to match against the pending query; the 't'
flag added in 2 is not required, but allowed.
With explicit deletion of pending rules, I removed the tacit
4. $> cat <dbfs>/dynamic_debug/pending
This displays currently pending queries, simplifying their deletion.
Its not correct right now; it iterates over set, but repeats
5. Fuller multi-command input
writes to control-file are parsed on '\n' as well as ';',
and '#' are recognized as comments.
With this, the following works.
root@voyage:~# cat debugfs-file
# blank lines ok
module dynamic_debug +p ; # turn on self-debugging
# these are quite noisy when grepping
# silence them (also, leading spaces allowed in comments)
func ddebug_proc_show -p
func ddebug_proc_next -p ; # trailing comments need cmd terminator
func pending_proc_show -p ;
func pending_proc_next -p
root@voyage:~# cat debugfs-file > /dbgfs/dynamic_debug/control
split into words: "module" "dynamic_debug" "+p"
changed $srcroot/lib/dynamic_debug.c:223 [dynamic_debug]ddebug_change =p
changed $srcroot/lib/dynamic_debug.c:576 [dynamic_debug]ddebug_save_pending =p
Here-docs work too, but shell interferes with comments.
1. echo " +p " > /dbg/dynamic_debug/control
The above felt a little radical, but it isnt really; it works on
mainline. Therefore one part of the Doc is slightly misleading (last
The match-spec's are used to choose a subset of the known dprintk()
callsites to which to apply the flags-spec. Think of them as a query
with implicit ANDs between each pair. Note that an empty list of
match-specs is possible, but is not very useful because it will not
match any debug statement callsites.
2. this runs 2 separate writes.
printf "module nsc_gpio +p\n module pc8736x_gpio +p\npc8736x_gpio +p\n" \
This form of command is seen by kernel as 2 separate writes, so the
form is not usable in boot-line in mainline; it breaks the debug
facility (see patch 6). Using ';' to separate multiple commands does
work on boot-line.
1-11 are straightforward, I think ready to go.
12-25 are the core feature addition, and have bigger implications.
I think theyre mostly solid, but they probably warrant more scrutiny.
25 needs some help.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/