Re: [PATCH 02/25] perf stat record: Add record command

Arnaldo Carvalho de Melo
2015-11-05T20:51:09Z

Em Thu, Nov 05, 2015 at 03:40:46PM +0100, Jiri Olsa escreveu:
> Add 'perf stat record' command support. It creates simple
> (header only) perf.data file ATM.
>
> The record command could be specified anywhere among stat
> options. All stat command options are valid for stat record
> command with '-o' option exception. If specified for record
> command it denotes the perf data file name.
>
> Tested-by: Kan Liang <kan.liang@intel.com>
> Link: http://lkml.kernel.org/n/tip-0av5yfkwyywwgoiali88w4hi@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Still stopping here:

[acme@zoo linux]$ rm -f perf.data
[acme@zoo linux]$ perf stat record usleep 1

Performance counter stats for 'usleep 1':

0.621181 task-clock (msec) # 0.455 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
54 page-faults # 0.087 M/sec
917,006 cycles # 1.476 GHz
611,746 stalled-cycles-frontend # 66.71% frontend cycles idle
<not supported> stalled-cycles-backend
654,410 instructions # 0.71 insns per cycle
# 0.93 stalled cycles per insn
132,653 branches # 213.550 M/sec
7,432 branch-misses # 5.60% of all branches

0.001365369 seconds time elapsed

[acme@zoo linux]$ ls -la perf.data
-rw-------. 1 acme acme 1384 Nov 5 17:42 perf.data
[acme@zoo linux]$ perf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
non matching sample_type[acme@zoo linux]$

--------------------------------

When we pass one event it gets a bit better:

[acme@zoo linux]$ rm -f perf.data
[acme@zoo linux]$ perf stat -e cycles record usleep 1

Performance counter stats for 'usleep 1':

1,056,818 cycles

0.000715850 seconds time elapsed

[acme@zoo linux]$ ls -la perf.data
-rw-------. 1 acme acme 232 Nov 5 17:44 perf.data
[acme@zoo linux]$ perf evlist
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
cycles
[acme@zoo linux]$

-----

In the second case it almost works, modulo that warning.

I think that what we need to achieve is for older tools to be able to, with a
file produced by 'perf stat record', to show this:

[root@zoo ~]# perf report --no-header --stdio
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options.
#
[root@zoo ~]#

I.e. the file should look like one that is produced by this command, purposely
to not create any sample:

# perf record -e syscalls:sys_enter_accept usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.018 MB perf.data ]

I applied the first patch and added it to that perf/stat branch.

- Arnaldo