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: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Sandipan Das <sandipan@linux.ibm.com>,
	Jiri Olsa <jolsa@redhat.com>, Kim Phillips <kim.phillips@arm.com>,
	"Naveen N . Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 15/27] perf tests: Fix record+probe_libc_inet_pton.sh when event exists
Date: Wed, 25 Jul 2018 14:59:49 -0300	[thread overview]
Message-ID: <20180725180001.15108-16-acme@kernel.org> (raw)
In-Reply-To: <20180725180001.15108-1-acme@kernel.org>

From: Sandipan Das <sandipan@linux.ibm.com>

If the event 'probe_libc:inet_pton' already exists, this test fails and
deletes the existing event before exiting. This will then pass for any
subsequent executions.

Instead of skipping to deleting the existing event because of failing to
add a new event, a duplicate event is now created and the script
continues with the usual checks. Only the new duplicate event that is
created at the beginning of the test is deleted as a part of the
cleanups in the end. All existing events remain as it is.

This can be observed on a powerpc64 system running Fedora 27 as shown
below.

  # perf probe -x /usr/lib64/power8/libc-2.26.so -a inet_pton

  Added new event:
    probe_libc:inet_pton (on inet_pton in /usr/lib64/power8/libc-2.26.so)

Before:

  # perf test -v "probe libc's inet_pton & backtrace it with ping"

  62: probe libc's inet_pton & backtrace it with ping       :
  --- start ---
  test child forked, pid 21302
  test child finished with -1
  ---- end ----
  probe libc's inet_pton & backtrace it with ping: FAILED!

  # perf probe --list

After:

  # perf test -v "probe libc's inet_pton & backtrace it with ping"

  62: probe libc's inet_pton & backtrace it with ping       :
  --- start ---
  test child forked, pid 21490
  ping 21513 [035] 39357.565561: probe_libc:inet_pton_1: (7fffa4c623b0)
  7fffa4c623b0 __GI___inet_pton+0x0 (/usr/lib64/power8/libc-2.26.so)
  7fffa4c190dc gaih_inet.constprop.7+0xf4c (/usr/lib64/power8/libc-2.26.so)
  7fffa4c19c4c getaddrinfo+0x15c (/usr/lib64/power8/libc-2.26.so)
  111d93c20 main+0x3e0 (/usr/bin/ping)
  test child finished with 0
  ---- end ----
  probe libc's inet_pton & backtrace it with ping: Ok

  # perf probe --list

    probe_libc:inet_pton (on __inet_pton@resolv/inet_pton.c in /usr/lib64/power8/libc-2.26.so)

Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kim Phillips <kim.phillips@arm.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/e11fecff96e6cf4c65cdbd9012463513d7b8356c.1530724939.git.sandipan@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 .../tests/shell/record+probe_libc_inet_pton.sh     | 28 ++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 0502a9e04c79..3013ac8f83d0 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -13,11 +13,24 @@
 libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1/g')
 nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254
 
+event_pattern='probe_libc:inet_pton(\_[[:digit:]]+)?'
+
+add_libc_inet_pton_event() {
+
+	event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | tail -n +2 | head -n -5 | \
+			grep -P -o "$event_pattern(?=[[:space:]]\(on inet_pton in $libc\))")
+
+	if [ $? -ne 0 -o -z "$event_name" ] ; then
+		printf "FAIL: could not add event\n"
+		return 1
+	fi
+}
+
 trace_libc_inet_pton_backtrace() {
 
 	expected=`mktemp -u /tmp/expected.XXX`
 
-	echo "ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" > $expected
+	echo "ping[][0-9 \.:]+$event_name: \([[:xdigit:]]+\)" > $expected
 	echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
 	case "$(uname -m)" in
 	s390x)
@@ -41,7 +54,7 @@ trace_libc_inet_pton_backtrace() {
 
 	perf_data=`mktemp -u /tmp/perf.data.XXX`
 	perf_script=`mktemp -u /tmp/perf.script.XXX`
-	perf record -e probe_libc:inet_pton/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1
+	perf record -e $event_name/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1
 	perf script -i $perf_data > $perf_script
 
 	exec 3<$perf_script
@@ -62,13 +75,20 @@ trace_libc_inet_pton_backtrace() {
 	# even if the perf script output does not match.
 }
 
+delete_libc_inet_pton_event() {
+
+	if [ -n "$event_name" ] ; then
+		perf probe -q -d $event_name
+	fi
+}
+
 # Check for IPv6 interface existence
 ip a sh lo | fgrep -q inet6 || exit 2
 
 skip_if_no_perf_probe && \
-perf probe -q $libc inet_pton && \
+add_libc_inet_pton_event && \
 trace_libc_inet_pton_backtrace
 err=$?
 rm -f ${perf_data} ${perf_script} ${expected}
-perf probe -q -d probe_libc:inet_pton
+delete_libc_inet_pton_event
 exit $err
-- 
2.14.4

  parent reply	other threads:[~2018-07-25 17:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25 17:59 [GIT PULL 00/27] perf/core improvements and fixes Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 01/27] perf tests: Check that complex event name is parsed correctly Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 02/27] perf hists: Clarify callchain disabling when available Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 03/27] perf cs-etm: Introduce invalid address macro Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 04/27] perf cs-etm: Bail out immediately for instruction sample failure Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 05/27] Revert "perf list: Add s390 support for detailed/verbose PMU event description" Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 06/27] perf list: Add s390 support for detailed PMU event description Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 07/27] perf json: Add s390 transaction counter definition Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 08/27] perf stat: Add transaction flag (-T) support for s390 Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 09/27] perf kvm: Fix subcommands on s390 Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 10/27] perf list: Add missing documentation for --desc and --debug options Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 11/27] perf powerpc: Fix callchain ip filtering Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 12/27] perf powerpc: Fix callchain ip filtering when return address is in a register Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 13/27] perf tests: Fix record+probe_libc_inet_pton.sh for powerpc64 Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 14/27] perf tests: Fix record+probe_libc_inet_pton.sh to ensure cleanups Arnaldo Carvalho de Melo
2018-07-25 17:59 ` Arnaldo Carvalho de Melo [this message]
2018-07-25 17:59 ` [PATCH 16/27] tools include: Grab copies of arm64 dependent unistd.h files Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 17/27] perf arm64: Generate system call table from asm/unistd.h Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 18/27] perf trace arm64: Use generated syscall table Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 19/27] perf script: Show correct offsets for DWARF-based unwinding Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 20/27] perf tools: Synthesize GROUP_DESC feature in pipe mode Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 21/27] perf machine: Add threads__get_last_match function Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 22/27] perf machine: Add threads__set_last_match function Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 23/27] perf machine: Use last_match threads cache only in single thread mode Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 24/27] perf tools: Fix struct comm_str removal crash Arnaldo Carvalho de Melo
2018-07-25 17:59 ` [PATCH 25/27] perf tools: Use perf_evsel__match instead of open coded equivalent Arnaldo Carvalho de Melo
2018-07-25 18:00 ` [PATCH 26/27] perf stat: Get rid of extra clock display function Arnaldo Carvalho de Melo
2018-07-25 18:00 ` [PATCH 27/27] perf test: Fix subtest number when showing results Arnaldo Carvalho de Melo
2018-07-25 20:34 ` [GIT PULL 00/27] perf/core improvements and fixes Ingo Molnar

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=20180725180001.15108-16-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=kim.phillips@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=ravi.bangoria@linux.vnet.ibm.com \
    --cc=sandipan@linux.ibm.com \
    --cc=williams@redhat.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).