Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1218690imm; Wed, 25 Jul 2018 13:49:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf4tXUMK4aH/TOOgVvbBhpL0oWHfUgdDqXhkGjqhD4MmIn2+BC33CyretywqVgCzM51c/wj X-Received: by 2002:a62:864a:: with SMTP id x71-v6mr23844834pfd.252.1532551742183; Wed, 25 Jul 2018 13:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532551742; cv=none; d=google.com; s=arc-20160816; b=NTRDYOAFj866Ls5ftBrXn4j0feE0EXIdElA6cyVHJ/LNfE7bGE1Zv0vFTFPr5/pn+D x64kHRhXPcMuTpsZS38LoE5mQbg2p5x2AcONxjDB83aNrrz/GAmJ3q6IAgvl38vANFVS BcnvCNB0TVmGhpF3WkuAOZyJ356BbZWKhcEpimKWnS0s8YFdRiwWIruwvKrgP1Vda9Uo Gtr4C3fKvBaR8OQWsCx4UxYwKlHt5j2aAO//lRk8yWEHMQWuIXJ2Cvx79hci/FygzoQs eRJbiA1p6tcFgNmN/CGwMAdNpNRAeDu0NHZVxNmrQstJ0gB5vufjXn9Yp043cEcX+YOM PuLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=udvRRnXe586NfS5BHY3MnrEq//A8dEpyEDODjEboMv4=; b=sNUMLdmMnhXE1/q4dBIwcU5gKpCIsBXEqmKaz26H5TZW0U+V8fSqSKvY6c1LjMIgwk aZnORAFoSGisBhy1m/q7NNoiUjToJh/uUFY1eWjONYKGh7DmHL1wK2tCCpJXwPyPVlqx UM5YCq0cDjGA5o0PFapWNbl3PMfGFKs2G2xj8Obv48FUDaQzgKUnBwvuqkU+FPQHM74+ /7GL/VT76u6csaTFcOjpzecgrc+Z1fCau27E4r8Qi07vJGvKRRGN+Ole+SkCDHWteDAG IQ40q8g/WVvz1/xrrrKcbMMGylZNT0hHyJngGo1YkArB8ALAs/qT/DA6w02quFUAdT+C URJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24-v6si15198694pfk.56.2018.07.25.13.48.47; Wed, 25 Jul 2018 13:49:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731357AbeGYWAr (ORCPT + 99 others); Wed, 25 Jul 2018 18:00:47 -0400 Received: from terminus.zytor.com ([198.137.202.136]:58685 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729335AbeGYWAr (ORCPT ); Wed, 25 Jul 2018 18:00:47 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6PKlD5Q500903 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 25 Jul 2018 13:47:13 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6PKlCjn500899; Wed, 25 Jul 2018 13:47:12 -0700 Date: Wed, 25 Jul 2018 13:47:12 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Sandipan Das Message-ID: Cc: naveen.n.rao@linux.vnet.ibm.com, ravi.bangoria@linux.vnet.ibm.com, mingo@kernel.org, jolsa@redhat.com, kim.phillips@arm.com, acme@redhat.com, hpa@zytor.com, sandipan@linux.ibm.com, tglx@linutronix.de, linux-kernel@vger.kernel.org Reply-To: hpa@zytor.com, acme@redhat.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, sandipan@linux.ibm.com, naveen.n.rao@linux.vnet.ibm.com, mingo@kernel.org, jolsa@redhat.com, kim.phillips@arm.com, ravi.bangoria@linux.vnet.ibm.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tests: Fix record+probe_libc_inet_pton.sh when event exists Git-Commit-ID: 60089e42d38438772e2f83334e3e5b7497009366 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_48_96 autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 60089e42d38438772e2f83334e3e5b7497009366 Gitweb: https://git.kernel.org/tip/60089e42d38438772e2f83334e3e5b7497009366 Author: Sandipan Das AuthorDate: Tue, 10 Jul 2018 19:28:17 +0530 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 24 Jul 2018 14:52:19 -0300 perf tests: Fix record+probe_libc_inet_pton.sh when event exists 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 Cc: Jiri Olsa Cc: Kim Phillips Cc: Naveen N. Rao Cc: Ravi Bangoria Link: http://lkml.kernel.org/r/e11fecff96e6cf4c65cdbd9012463513d7b8356c.1530724939.git.sandipan@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- .../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