Skip to contentSkip to conversation

perf, tools, script: Allow adding and removing fields

PATCH In review Andi Kleen 2 participants 6 messages May 1, 2017 – May 7, 2017 perf events

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

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 pid,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.

---
 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
index cb0eda3925e6..4547120c6ad3 100644
@@ -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
#1 lore raw
Quoted 13 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

Quoted 7 lines

perf script -F pid,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])

I haven't checked deeply yet, but I'm getting different pids with the new syntax, perhaps some mixing with tids column?

     0 [002] 42615.004240:       2172 cycles:  ffffffff86060c66 native_write_msr ([kernel.kallsyms])
     0 [002] 42615.004242:      19857 cycles:  ffffffff860abee0 irq_exit ([kernel.kallsyms])
     0 [002] 42615.004250:     412618 cycles:  ffffffff860d1429 ttwu_do_wakeup ([kernel.kallsyms])
- 1798 [001] 42615.008219:      46557 cycles:  ffffffff860dc718 update_blocked_averages ([kernel.kallsyms])

- 1798 [001] 42615.008239: 46557 cycles: 7f313dff0684 [unknown] (/usr/lib64/firefox/libxul.so)
- 1798 [001] 42615.008258: 112387 cycles: 7f313e32c71a [unknown] (/usr/lib64/firefox/libxul.so)
+ 1861 [001] 42615.008219: 46557 cycles: ffffffff860dc718 update_blocked_averages ([kernel.kallsyms])
+ 1861 [001] 42615.008239: 46557 cycles: 7f313dff0684 [unknown] (/usr/lib64/firefox/libxul.so)
+ 1861 [001] 42615.008258: 112387 cycles: 7f313e32c71a [unknown] (/usr/lib64/firefox/libxul.so)

  1687 [002] 42615.008268:    1711528 cycles:  ffffffffc01e74c7 i915_gem_set_domain_ioctl ([i915])
- 1798 [001] 42615.008303:     281652 cycles:  ffffffff860dc169 account_entity_dequeue ([kernel.kallsyms])
+ 1861 [001] 42615.008303:     281652 cycles:  ffffffff860dc169 account_entity_dequeue ([kernel.kallsyms])
  1798 [001] 42615.008440:     442473 cycles:      7f3147c6935b g_slice_free1 (/usr/lib64/libglib-2.0.so.0.5000.3)
- 1935 [001] 42615.009462:     487718 cycles:  ffffffff860f25bc cpuacct_charge ([kernel.kallsyms])
- 1935 [002] 42615.009955:    1711528 cycles:      7fa2a2ac748f [unknown] (/usr/lib64/firefox/libmozavcodec.so)
- 1935 [001] 42615.009989:     441676 cycles:      559627e901da [unknown] (/usr/lib64/firefox/firefox)
- 1935 [000] 42615.010233:      79099 cycles:      7fa2c2a11fa9 [unknown] (/usr/lib64/firefox/libxul.so)
+24128 [001] 42615.009462:     487718 cycles:  ffffffff860f25bc cpuacct_charge ([kernel.kallsyms])
+24182 [002] 42615.009955:    1711528 cycles:      7fa2a2ac748f [unknown] (/usr/lib64/firefox/libmozavcodec.so)
+24181 [001] 42615.009989:     441676 cycles:      559627e901da [unknown] (/usr/lib64/firefox/firefox)
+24112 [000] 42615.010233:      79099 cycles:      7fa2c2a11fa9 [unknown] (/usr/lib64/firefox/libxul.so)

thanks,
jirka

author
#2 lore raw
Quoted 17 lines · Jiri Olsa
Quoted 16 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 pid,cpu,time,event,sym,ip,dso,period

	    0 [000] 504345.383126:          1 cycles:  ffffffff90060c66 native_write_msr ([kernel.kallsyms])
Quoted 8 lines
Quoted 4 lines

with the new syntax

perf script -F -comm

	    0 [000] 504345.383126:          1 cycles:  ffffffff90060c66 native_write_msr ([kernel.kallsyms])

I haven't checked deeply yet, but I'm getting different pids with the new syntax, perhaps some mixing with tids column?

Cannot reproduce. Do you have an exact command line?

The patch shouldn't really change any columns.

-Andi

#3 lore raw
Quoted 24 lines · Andi Kleen
Quoted 23 lines · Jiri Olsa
Quoted 20 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 pid,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])
Quoted 7 lines
Quoted 2 lines

I haven't checked deeply yet, but I'm getting different pids with the new syntax, perhaps some mixing with tids column?

Cannot reproduce. Do you have an exact command line?

The patch shouldn't really change any columns.

[jolsa@krava perf]$ ./perf record -a
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.527 MB perf.data (2533 samples) ]

[jolsa@krava perf]$ ./perf script -F pid,cpu,time,event,sym,ip,dso,period > 1
Failed to open /tmp/perf-1841.map, continuing without symbols /run/user/1000/orcexec.1yoPtl was updated (is prelink enabled?). Restart the long running apps that use it! [vdso] with build id 0b94eba680f6a3bb2e3efbde9a2551c1f5b27e34 not found, continuing without symbols [jolsa@krava perf]$ ./perf script -F -comm > 2
Failed to open /tmp/perf-1841.map, continuing without symbols /run/user/1000/orcexec.1yoPtl was updated (is prelink enabled?). Restart the long running apps that use it! [vdso] with build id 0b94eba680f6a3bb2e3efbde9a2551c1f5b27e34 not found, continuing without symbols [jolsa@krava perf]$ diff -puw 1 2 | head -20

2 2017-05-05 09:56:04.469166203 +0200 renamed from 1 2017-05-05 09:56:00.088148174 +0200 +6 -6
@@ -6,16 +6,16 @@
     0 [000] 10374.768173:       1680 cycles:  ffffffff94116904 __next_timer_interrupt ([kernel.kallsyms])
     0 [000] 10374.768174:      32136 cycles:  ffffffff94116904 __next_timer_interrupt ([kernel.kallsyms])
     0 [000] 10374.768187:     846579 cycles:  ffffffff9484f3f6 __schedule ([kernel.kallsyms])
- 1706 [000] 10374.774848:    2417537 cycles:      7f362deaaf5e [unknown] (/usr/lib64/firefox/libxul.so)
- 1706 [003] 10374.775161:      31151 cycles:  ffffffff940dc520 update_blocked_averages ([kernel.kallsyms])
- 1841 [002] 10374.775163:      41524 cycles:  ffffffff940f3ec9 queued_spin_lock_slowpath ([kernel.kallsyms])
+ 1769 [000] 10374.774848:    2417537 cycles:      7f362deaaf5e [unknown] (/usr/lib64/firefox/libxul.so)
+ 1723 [003] 10374.775161:      31151 cycles:  ffffffff940dc520 update_blocked_averages ([kernel.kallsyms])
+ 1844 [002] 10374.775163:      41524 cycles:  ffffffff940f3ec9 queued_spin_lock_slowpath ([kernel.kallsyms])
     0 [001] 10374.775168:      24203 cycles:  ffffffff940d7e24 sched_clock_idle_wakeup_event ([kernel.kallsyms])
- 1706 [003] 10374.775175:      31151 cycles:  ffffffff94704227 copy_msghdr_from_user ([kernel.kallsyms])
+ 1723 [003] 10374.775175:      31151 cycles:  ffffffff94704227 copy_msghdr_from_user ([kernel.kallsyms])
  1841 [001] 10374.775178:      24203 cycles:      7f298cdb1d1b [unknown] (/usr/lib64/firefox/libxul.so)
- 1841 [002] 10374.775181:      41524 cycles:  ffffffff940ead8e __wake_up_common ([kernel.kallsyms])
- 1706 [003] 10374.775188:      94430 cycles:  ffffffff9438a7cb selinux_file_permission ([kernel.kallsyms])
+ 1844 [002] 10374.775181:      41524 cycles:  ffffffff940ead8e __wake_up_common ([kernel.kallsyms])
+ 1723 [003] 10374.775188:      94430 cycles:  ffffffff9438a7cb selinux_file_permission ([kernel.kallsyms])

[jolsa@krava perf]$

jirka

author
#4 lore raw
Quoted 28 lines · Jiri Olsa
Quoted 27 lines · Andi Kleen
Quoted 25 lines · Jiri Olsa
Quoted 13 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

Quoted 7 lines

perf script -F pid,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])

I haven't checked deeply yet, but I'm getting different pids with the new syntax, perhaps some mixing with tids column?

Quoted 6 lines
Quoted 4 lines

Cannot reproduce. Do you have an exact command line?

The patch shouldn't really change any columns.

[jolsa@krava perf]$ ./perf record -a

I looked at this, and I don't think it's different with my patch.

Any time you set fields you get different output versus default:

% perf script -F pid,cpu,time,event,sym,ip,dso,period,comm

vs

% perf script

First gives PID second TID.

It would be good to fix, but I don't think it should block my patch.

-Andi

#5 lore raw
Quoted 43 lines · Andi Kleen
Quoted 28 lines · Jiri Olsa
Quoted 27 lines · Andi Kleen
Quoted 25 lines · Jiri Olsa
Quoted 13 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

Quoted 7 lines

perf script -F pid,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])

I haven't checked deeply yet, but I'm getting different pids with the new syntax, perhaps some mixing with tids column?

Quoted 6 lines
Quoted 4 lines

Cannot reproduce. Do you have an exact command line?

The patch shouldn't really change any columns.

[jolsa@krava perf]$ ./perf record -a

I looked at this, and I don't think it's different with my patch.

Any time you set fields you get different output versus default:

% perf script -F pid,cpu,time,event,sym,ip,dso,period,comm

Quoted 7 lines

vs

% perf script

First gives PID second TID.

It would be good to fix, but I don't think it should block my patch.

your changelog says those 2 commands give same output, so either fix the changelog or provide related fix

thanks,
jirka