linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Michael Petlan <mpetlan@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Thomas Richter <tmricht@linux.vnet.ibm.com>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 14/19] perf test shell: Add test using vfs_getname + 'perf trace'
Date: Mon, 14 Aug 2017 13:27:36 -0300	[thread overview]
Message-ID: <20170814162741.6101-15-acme@kernel.org> (raw)
In-Reply-To: <20170814162741.6101-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Uses the 'perf test shell' library to add probe:vfs_getname to the
system then use it with 'perf trace' using 'touch' to write to a temp
file, then checks that that was captured by the vfs_getname was used by
'perf trace', that already handles "probe:vfs_getname" if present, and
used in the "open" syscall "filename" argument beautifier.

Testing it:

  # perf test "trace + vfs_getname"
  61: Check open filename arg using perf trace + vfs_getname: Ok
  #

  # perf test -v "trace + vfs_getname"
  61: Check open filename arg using perf trace + vfs_getname:
  --- start ---
  test child forked, pid 30846
  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

       2.237 ( 0.012 ms): touch/30855 open(filename: /tmp/temporary_file.kmoWQ, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: IRUGO|IWUGO) = 3
  test child finished with 0
  ---- end ----
  Check open filename arg using perf trace + vfs_getname: 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-j02nobfvvn9c7yrphdsnbqx0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/shell/trace+probe_vfs_getname.sh | 31 +++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100755 tools/perf/tests/shell/trace+probe_vfs_getname.sh

diff --git a/tools/perf/tests/shell/trace+probe_vfs_getname.sh b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
new file mode 100755
index 000000000000..d0fba0c5e354
--- /dev/null
+++ b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
@@ -0,0 +1,31 @@
+# Check open filename arg using perf trace + vfs_getname
+
+# Uses the 'perf test shell' library to add probe:vfs_getname to the system
+# then use it with 'perf trace' using 'touch' to write to a temp file, then
+# checks that that was captured by the vfs_getname was used by 'perf trace',
+# that already handles "probe:vfs_getname" if present, and used in the
+# "open" syscall "filename" argument beautifier.
+
+# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
+
+. $(dirname $0)/lib/probe_vfs_getname.sh
+
+file=$(mktemp /tmp/temporary_file.XXXXX)
+
+trace_open_vfs_getname() {
+	perf trace -e open touch $file 2>&1 | \
+	egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open\(filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$"
+}
+
+
+add_probe_vfs_getname || skip_if_no_debuginfo
+err=$?
+if [ $err -ne 0 ] ; then
+	exit $err
+fi
+
+trace_open_vfs_getname
+err=$?
+rm -f ${file}
+cleanup_probe_vfs_getname
+exit $err
-- 
2.13.4

  parent reply	other threads:[~2017-08-14 16:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-14 16:27 [GIT PULL 00/19] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 01/19] perf scripting python: Add ppc64le to audit uname list Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 02/19] perf vendor events powerpc: remove suffix in mapfile Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 03/19] perf vendor events powerpc: Update POWER9 events Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 04/19] perf stat: Fix saved values rbtree lookup Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 05/19] perf tools: Add missing newline to expr parser error messages Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 06/19] perf test: Make 'list' subcommand match main 'perf test' numbering/matching Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 07/19] perf test: Add 'struct test *' to the test functions Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 08/19] perf test: Add infrastructure to run shell based tests Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 09/19] perf test: Make 'list' use same filtering code as main 'perf test' Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 10/19] perf test shell: Add 'probe_vfs_getname' shell test Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 11/19] perf test shell: Install shell tests Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 12/19] perf test shell: Move vfs_getname probe function to lib Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 13/19] perf test shell: Add test using probe:vfs_getname and verifying results Arnaldo Carvalho de Melo
2017-08-14 16:27 ` Arnaldo Carvalho de Melo [this message]
2017-08-14 16:27 ` [PATCH 15/19] perf util: Take elf_name as const string in dso__demangle_sym Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 16/19] perf srcline: Do not consider empty files as valid srclines Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 17/19] perf record: Fix wrong size in perf_record_mmap for last kernel module Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 18/19] perf report: Fix module symbol adjustment for s390x Arnaldo Carvalho de Melo
2017-08-14 16:27 ` [PATCH 19/19] perf test shell: Add uprobes + backtrace ping test Arnaldo Carvalho de Melo
2017-08-14 17:39 ` [GIT PULL 00/19] perf/core improvements and fixes Ingo Molnar
2017-08-14 17:52   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170814162741.6101-15-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpetlan@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=tmricht@linux.vnet.ibm.com \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).