perf, tools, script: Allow adding and removing fields
PATCH 1/1 perf, tools, script: Allow adding and removing fields
From: Andi Kleen <[email protected]>
With perf script it is common that we just want to add or remove a field. Currently this requires figuring out the long list of default fields and specifying them first, and then adding/removing the new field.
This patch adds a new + - syntax to merely add or remove fields, that allows more succint and clearer command lines
For example to remove the comm field from PMU samples:
Previously
perf script -F tid,cpu,time,event,sym,ip,dso,period
0 [000] 504345.383126: 1 cycles: ffffffff90060c66 native_write_msr ([kernel.kallsyms])
with the new syntax
perf script -F -comm
0 [000] 504345.383126: 1 cycles: ffffffff90060c66 native_write_msr ([kernel.kallsyms])
The new syntax cannot be mixed with normal overriding.
v2: Fix example in description. Use tid vs pid. No functional changes.
--- tools/perf/Documentation/perf-script.txt | 8 ++++++ tools/perf/builtin-script.c | 42 +++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-script.txt +8 -0
@@ -130,6 +130,14 @@ OPTIONS i.e., the specified fields apply to all event types if the type string is not given. + In addition to overriding fields, it is also possible to add or remove + fields from the defaults. For example + + -F -cpu,+insn + + removes the cpu field and adds the insn field. Adding/removing fields + cannot be mixed with normal overriding. + The arguments are processed in the order received. A later usage can reset a prior request. e.g.:
tools/perf/builtin-script.c +39 -3
94 lines not on this page · raw message
Signature · 1 line
2.9.3
Quoted 14 lines · Andi Kleen
From: Andi Kleen <[email protected]>
With perf script it is common that we just want to add or remove a field. Currently this requires figuring out the long list of default fields and specifying them first, and then adding/removing the new field.
This patch adds a new + - syntax to merely add or remove fields, that allows more succint and clearer command lines
For example to remove the comm field from PMU samples:
Previously
perf script -F tid,cpu,time,event,sym,ip,dso,period
Quoted 8 lines
0 [000] 504345.383126: 1 cycles: ffffffff90060c66 native_write_msr ([kernel.kallsyms])with the new syntax
perf script -F -comm
0 [000] 504345.383126: 1 cycles: ffffffff90060c66 native_write_msr ([kernel.kallsyms])The new syntax cannot be mixed with normal overriding.
so the -F option for 'type:' does not have default set, and it looks like the +- don't make sense there:
[jolsa@krava perf]$ ./perf script -F hw:+comm | head -3
ex
ex
ex
jirka
Quoted 2 lines
so the -F option for 'type:' does not have default set, and it looks like the +- don't make sense there:
hw:+comm is just equivalent to hw:comm
Seems fine to me?
hw:-comm won't do anything, but I guess that's expected.
Don't see any need to change this?
Quoted 5 lines
[jolsa@krava perf]$ ./perf script -F hw:+comm | head -3
ex
ex
ex
-Andi
Quoted 10 lines · Andi Kleen
Quoted 2 lines
so the -F option for 'type:' does not have default set, and it looks like the +- don't make sense there:
hw:+comm is just equivalent to hw:comm
Seems fine to me?
hw:-comm won't do anything, but I guess that's expected.
Don't see any need to change this?
why did you add it in the first place then?
jirka
Quoted 6 lines · Jiri Olsa
Quoted 5 lines · Andi Kleen
Quoted 2 lines
so the -F option for 'type:' does not have default set, and it looks like the +- don't make sense there:
hw:+comm is just equivalent to hw:comm
Quoted 7 lines
Quoted 5 lines
Seems fine to me?
hw:-comm won't do anything, but I guess that's expected.
Don't see any need to change this?
why did you add it in the first place then?
You mean the Don't override defaults check in the hw types specified case?
I guess it could be removed yes.
-Andi