tracing: Add hist trigger 'log2' modifier
Allow users to have numeric fields displayed as log2 values in case
value range is very wide by appending '.log2' to field names.
For example,
# echo 'hist:key=bytes_req' > kmalloc/trigger
# cat kmalloc/hist
{ bytes_req: 504 } hitcount: 1
{ bytes_req: 11 } hitcount: 1
{ bytes_req: 104 } hitcount: 1
{ bytes_req: 48 } hitcount: 1
{ bytes_req: 2048 } hitcount: 1
{ bytes_req: 4096 } hitcount: 1
{ bytes_req: 240 } hitcount: 1
{ bytes_req: 392 } hitcount: 1
{ bytes_req: 13 } hitcount: 1
{ bytes_req: 28 } hitcount: 1
{ bytes_req: 12 } hitcount: 1
{ bytes_req: 64 } hitcount: 2
{ bytes_req: 128 } hitcount: 2
{ bytes_req: 32 } hitcount: 2
{ bytes_req: 8 } hitcount: 11
{ bytes_req: 10 } hitcount: 13
{ bytes_req: 24 } hitcount: 25
{ bytes_req: 160 } hitcount: 29
{ bytes_req: 16 } hitcount: 33
{ bytes_req: 80 } hitcount: 36
When using '.log2' modifier, the output looks like:
# echo 'hist:key=bytes_req.log2' > kmalloc/trigger
# cat kmalloc/hist
{ bytes_req: ~ 2^12 } hitcount: 1
{ bytes_req: ~ 2^11 } hitcount: 1
{ bytes_req: ~ 2^9 } hitcount: 2
{ bytes_req: ~ 2^6 } hitcount: 3
{ bytes_req: ~ 2^3 } hitcount: 13
{ bytes_req: ~ 2^5 } hitcount: 19
{ bytes_req: ~ 2^8 } hitcount: 49
{ bytes_req: ~ 2^7 } hitcount: 57
{ bytes_req: ~ 2^4 } hitcount: 74
Link: http://lkml.kernel.org/r/7ff396b246c6a881f46b979735fddf05a0d6c71a.1457029949.git.tom.zanussi@linux.intel.com
Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 4e342d3..988a352 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3872,6 +3872,7 @@
"\t .sym-offset display an address as a symbol and offset\n"
"\t .execname display a common_pid as a program name\n"
"\t .syscall display a syscall id as a syscall name\n\n"
+ "\t .log2 display log2 value rather than raw number\n\n"
"\t The 'pause' parameter can be used to pause an existing hist\n"
"\t trigger or to start a hist trigger but not log any events\n"
"\t until told to do so. 'continue' can be used to start or\n"