diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-08-04 13:39:37 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-08-11 15:06:30 -0400 |
commit | 6060c7264ded3f6fa17e74bca3e192ce477e8063 (patch) | |
tree | cd049cecdc90f308c9fab5459ba772355ed56f5b | |
parent | 5ce669a59503f7c05c4648c70fe72bbe42613743 (diff) |
perf test shell: Add test using probe:vfs_getname and verifying results
This test uses the 'perf test shell' library to add probe:vfs_getname to the
system then use it with 'perf record' using 'touch' to write to a temp file,
then checks that that was captured by the vfs_getname probe in the generated
perf.data file, with the temp file name as the pathname argument.
Using it:
# perf test "Use vfs_getname"
60: Use vfs_getname probe to get syscall args filenames: Ok
# perf test -v "Use vfs_getname"
60: Use vfs_getname probe to get syscall args filenames:
--- start ---
test child forked, pid 16414
Added new event:
probe:vfs_getname (on getname_flags:72 with pathname=result->name:string)
You can now use it in all perf tools, such as:
perf record -e probe:vfs_getname -aR sleep 1
Recording open file:
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.022 MB /tmp/vaca.perf.data.QZsn7 (13 samples) ]
Looking at perf.data file for vfs_getname records for the file we touched:
touch 16421 [002] 1255152.879561: probe:vfs_getname: (ffffffffa626e608) pathname="/tmp/vaca.l10SL"
test child finished with 0
---- end ----
Use vfs_getname probe to get syscall args filenames: Ok
#
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-t555fnhbcbxnukltk23dqxur@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | tools/perf/tests/shell/record+script_probe_vfs_getname.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh new file mode 100755 index 000000000000..2725c5db699a --- /dev/null +++ b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh | |||
@@ -0,0 +1,37 @@ | |||
1 | # Use vfs_getname probe to get syscall args filenames | ||
2 | |||
3 | # Uses the 'perf test shell' library to add probe:vfs_getname to the system | ||
4 | # then use it with 'perf record' using 'touch' to write to a temp file, then | ||
5 | # checks that that was captured by the vfs_getname probe in the generated | ||
6 | # perf.data file, with the temp file name as the pathname argument. | ||
7 | |||
8 | # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017 | ||
9 | |||
10 | . $(dirname $0)/lib/probe_vfs_getname.sh | ||
11 | |||
12 | perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) | ||
13 | file=$(mktemp /tmp/temporary_file.XXXXX) | ||
14 | |||
15 | record_open_file() { | ||
16 | echo "Recording open file:" | ||
17 | perf record -o ${perfdata} -e probe:vfs_getname touch $file | ||
18 | } | ||
19 | |||
20 | perf_script_filenames() { | ||
21 | echo "Looking at perf.data file for vfs_getname records for the file we touched:" | ||
22 | perf script -i ${perfdata} | \ | ||
23 | egrep " +touch +[0-9]+ +\[[0-9]+\] +[0-9]+\.[0-9]+: +probe:vfs_getname: +\([[:xdigit:]]+\) +pathname=\"${file}\"" | ||
24 | } | ||
25 | |||
26 | add_probe_vfs_getname || skip_if_no_debuginfo | ||
27 | err=$? | ||
28 | if [ $err -ne 0 ] ; then | ||
29 | exit $err | ||
30 | fi | ||
31 | |||
32 | record_open_file && perf_script_filenames | ||
33 | err=$? | ||
34 | rm -f ${perfdata} | ||
35 | rm -f ${file} | ||
36 | cleanup_probe_vfs_getname | ||
37 | exit $err | ||