From patchwork Fri Oct 14 17:08:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 2761 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp290259wrs; Fri, 14 Oct 2022 10:11:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48pogAiFK/kwUJLGeaqWHWEwMjaZNcsINupg01PKXlYJiu5gtHmIRTo3wE0w/EVOzlFdud X-Received: by 2002:a17:907:9618:b0:78d:fa75:e2b8 with SMTP id gb24-20020a170907961800b0078dfa75e2b8mr4314936ejc.65.1665767497783; Fri, 14 Oct 2022 10:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665767497; cv=none; d=google.com; s=arc-20160816; b=pdHFOiMz9qqnoFlDvCuQ5Z7PNdWA8VzmxwxuKsP0Wwpo6+nO+vl6QtZOJ+W4ohsG5U Oay44L0pPhX5aD48AB9AhLWcLnCuVUtkv3/sRLyNlcUuzMItYDlEuSwjGe8JzuuXeVm1 5H2yaAcLjhp5rLUx8kVcRT7v6p5v4N/7knk6StT+gvS7pmHYARi/zW3UCeZR4d6GajIt Ir85RWarR8g6TthxjXeHTgf5eWvEi+PqDCpgcWwJLMEBp7mAxQjbELtGGQ3Epx3f70f4 7w2/3uu/RtD2QWJvBUnH9DiAn5ztnA3B3O0InpGnqrHQfZzBip2ZIIIn078lmfBApGJN YwTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hlj9WrvESXHbvGAw1XYG7irl+2YAh4LU+heRfQt3MA4=; b=Uq7cD2Vi/FKG1/wLY9lEqtiaosFpIsDQDU8jvKm8sv72lFYjm2YJSwvXrpPBXLOrCe E0BDL6twN1rR2nVtjnHYWolEqLnE1GIbf34EvseoX7ievmiKt/n0N6/D1cGPN92qHo5K 3ra7jTLc4AixvxwX1SSCnJrIaNU2RosjN/XDSeRhNetS/C++3w1+J4eU62mMPypZTc2n uAKqehlXRs1wxVEZKitBNWQ06yqtcUubYwgGqrFjsNRs/k4u9Pwz/YzZw7ak2vTXJz7M vdubH17UniJ0ONte1VcEgYjAR4ZxTHmhyQmwzsuRCr1Lg8MNvu8YgiVVa1539TBouLwm 4+ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LouiBfqR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg5-20020a1709072cc500b00780636a4a58si2780140ejc.626.2022.10.14.10.11.12; Fri, 14 Oct 2022 10:11:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LouiBfqR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230482AbiJNRJe (ORCPT + 99 others); Fri, 14 Oct 2022 13:09:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230207AbiJNRJb (ORCPT ); Fri, 14 Oct 2022 13:09:31 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8491C1119FA; Fri, 14 Oct 2022 10:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665767370; x=1697303370; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jUrjMM7Alwl5r3W2FcMRVxujVyEHUtZGS+tz5iNw/vk=; b=LouiBfqRHfInu7ezLdXFLIwptCPgcH8/dChsSNyir1ct55Tni4kVQKGq UWJzpXw6C7mhDiS7nayl94gVFHLfAXd+cKTEwZiXiU/Zd93vI64xbpSSz E9MWKUK1H6/aiB+wakUG8HEFPMNTzAYPMRjch5THMGaQD/SbPIXl0ewIx oKsf1AA+LkCgpcCUDRuBa3vpea+WF2BlXGH6DKMSBwFH8rzgmSrxta/hJ uiuynIJHDHjp+msS36703UB9oXPl/MDvEB+3x+wf9oG82k7K8ZuR5vsR/ 7c54K/jpRjZJ47Xqb4Xe7KM+Ad61hNCpCdH8o8imtA5bRihhtVOZtw6gL A==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="303041969" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="303041969" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:30 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="696376922" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="696376922" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.43.79]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:28 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 1/7] perf test: test_intel_pt.sh: Fix return checking again Date: Fri, 14 Oct 2022 20:08:59 +0300 Message-Id: <20221014170905.64069-2-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014170905.64069-1-adrian.hunter@intel.com> References: <20221014170905.64069-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746683820231123934?= X-GMAIL-MSGID: =?utf-8?q?1746683820231123934?= count_result() does not always reset ret=0 which means the value can spill into the next test result. Fix by explicitly setting it to zero between tests. Fixes: fd9b45e39cfa ("perf test: test_intel_pt.sh: Fix return checking") Signed-off-by: Adrian Hunter --- tools/perf/tests/shell/test_intel_pt.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index efaad9566c34..4609a24c9340 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -265,13 +265,12 @@ count_result() return fi err_cnt=$((err_cnt + 1)) - ret=0 } ret=0 -test_system_wide_side_band || ret=$? ; count_result $ret -test_per_thread "" "" || ret=$? ; count_result $ret -test_per_thread "k" "(incl. kernel) " || ret=$? ; count_result $ret +test_system_wide_side_band || ret=$? ; count_result $ret ; ret=0 +test_per_thread "" "" || ret=$? ; count_result $ret ; ret=0 +test_per_thread "k" "(incl. kernel) " || ret=$? ; count_result $ret ; ret=0 cleanup From patchwork Fri Oct 14 17:09:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 2766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp291253wrs; Fri, 14 Oct 2022 10:13:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fBoMNkP+tFxWyR7XWJHpgPmfzcR7rh8sbcDUNKWEaGv5LXOotxJOQc+CTBwyrLCM0txcW X-Received: by 2002:a17:907:d89:b0:78d:b143:7aeb with SMTP id go9-20020a1709070d8900b0078db1437aebmr4182790ejc.459.1665767629065; Fri, 14 Oct 2022 10:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665767629; cv=none; d=google.com; s=arc-20160816; b=fMafEPcCgJn1HUuyCbht1RNFQZMi7aO8ixT7xxT3hakjj/gagOAAL39fx3Tzu+q20i GTPI5eXq8BUaSez2QfhMpEtz4PJs8JPCGIKPvlHLvApyZ8PCNn6p/AklAD0Ipnslu7Vj 1g5eYQtKuzqImlhHeCRD2c6ifLV3aMVUM9B31Ls7C6WWtvjYNMIe8JxXFWUB02ywohC/ oJXT4Bc7z+mO8LHGUjzOwo672HGA+74lNBwq/NoEnHaFdU6zFnpyKUfCoR8SxaKyKXU/ 1PyzSJtJPllnSrL9HrQoeXPFHA4+fDEeqeR0SRVD3MiBMoWf4bhl9qnKaKDdqgAmOqbl Ie2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nGV2zxm81AvuEgoXUDQaaUnbc/KAp3jhQtZ0CuYG6uY=; b=00n3raDc+2Bd5lGiXCNe+sNwd8DRdfYRzR5AH7q6y3WtNMfNNzztHKzQBHg4/mCzMh pC2KJL87mGQjOszpIbzDNHE8ErDwdTqIfZVeaGp/UAtfW4qn+rIbdRY0hs1MoP1xWJhy I1Z41koKWsOa6O0BzMK+X+qbsDUxHmWLZE1yPwaTEFlwIJnU7p/p0uhhIyWbbKu6QMav 1QK1i3ToAasM8DHLfDg6SBs8y4AGRRRfDO2YoYx7xGY7BPyriEkUlSD5ONSU5/EC6yBW 4OM0UYrXR+4njHDEyOhgcTsT5P3c1P6IwV9ItfI87Qv5P0wn2WRDNzYUOTAIUijkQFQt 4nZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a5VYWomR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a056402090500b00457e6752422si2416192edz.189.2022.10.14.10.13.23; Fri, 14 Oct 2022 10:13:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a5VYWomR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbiJNRJh (ORCPT + 99 others); Fri, 14 Oct 2022 13:09:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230438AbiJNRJe (ORCPT ); Fri, 14 Oct 2022 13:09:34 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECCD614DF0A; Fri, 14 Oct 2022 10:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665767372; x=1697303372; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jva74q/mI6mu3YiJK8quzWNt5hjNiitIrcO+L1oKapc=; b=a5VYWomRMemqXBspxOn12oKAMm+mZejsjuqV+H1LwXJ4gzUvcgDxhX8p 3GUgvRixsWK2+1QNP/8CllsmGEC5Xy8uFVBKQkB0qB5BrEktUlWQdwmGf eByB6DoJY2w1b6e/yr+YaAOrmt1II5cdB9q+wLg6GKUItArOp7WZf8cn1 p9lBHtUNujbmSml1TgwPQzgkeUDf5VfwI8/Z9s9H51R5i9sJzVde4Zw5v rHp1lN8JBjPlhLaxBEGf8bf2eWUpNJ3H0lR92hYvFI/QrFczrG5W/Fyce 8jJh9rk1Q2nau1QvxZnZ4CXI5KCilLs0LSO2+Ulplv4mURuXY2upiXpc2 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="303041973" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="303041973" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:32 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="696376928" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="696376928" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.43.79]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:30 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 2/7] perf test: test_intel_pt.sh: Tidy some perf record options Date: Fri, 14 Oct 2022 20:09:00 +0300 Message-Id: <20221014170905.64069-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014170905.64069-1-adrian.hunter@intel.com> References: <20221014170905.64069-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746683957525685047?= X-GMAIL-MSGID: =?utf-8?q?1746683957525685047?= When not decoding, the options "-B -N --no-bpf-event" speed up perf record. Make a common function for them. Signed-off-by: Adrian Hunter --- tools/perf/tests/shell/test_intel_pt.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index 4609a24c9340..334836f92bdc 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -42,6 +42,14 @@ trap_cleanup() trap trap_cleanup EXIT TERM INT +# perf record for testing without decoding +perf_record_no_decode() +{ + # Options to speed up recording: no post-processing, no build-id cache update, + # and no BPF events. + perf record -B -N --no-bpf-event "$@" +} + have_workload=false cat << _end_of_file_ | /usr/bin/cc -o "${workload}" -xc - -pthread && have_workload=true #include @@ -76,7 +84,7 @@ _end_of_file_ can_cpu_wide() { echo "Checking for CPU-wide recording on CPU $1" - if ! perf record -o "${tmpfile}" -B -N --no-bpf-event -e dummy:u -C "$1" true >/dev/null 2>&1 ; then + if ! perf_record_no_decode -o "${tmpfile}" -e dummy:u -C "$1" true >/dev/null 2>&1 ; then echo "No so skipping" return 2 fi @@ -93,7 +101,7 @@ test_system_wide_side_band() can_cpu_wide 1 || return $? # Record on CPU 0 a task running on CPU 1 - perf record -B -N --no-bpf-event -o "${perfdatafile}" -e intel_pt//u -C 0 -- taskset --cpu-list 1 uname + perf_record_no_decode -o "${perfdatafile}" -e intel_pt//u -C 0 -- taskset --cpu-list 1 uname # Should get MMAP events from CPU 1 because they can be needed to decode mmap_cnt=$(perf script -i "${perfdatafile}" --no-itrace --show-mmap-events -C 1 2>/dev/null | grep -c MMAP) @@ -109,7 +117,7 @@ test_system_wide_side_band() can_kernel() { - perf record -o "${tmpfile}" -B -N --no-bpf-event -e dummy:k true >/dev/null 2>&1 || return 2 + perf_record_no_decode -o "${tmpfile}" -e dummy:k true >/dev/null 2>&1 || return 2 return 0 } @@ -235,7 +243,7 @@ test_per_thread() wait_for_threads ${w1} 2 wait_for_threads ${w2} 2 - perf record -B -N --no-bpf-event -o "${perfdatafile}" -e intel_pt//u"${k}" -vvv --per-thread -p "${w1},${w2}" 2>"${errfile}" >"${outfile}" & + perf_record_no_decode -o "${perfdatafile}" -e intel_pt//u"${k}" -vvv --per-thread -p "${w1},${w2}" 2>"${errfile}" >"${outfile}" & ppid=$! echo "perf PID is $ppid" wait_for_perf_to_start ${ppid} "${errfile}" || return 1 From patchwork Fri Oct 14 17:09:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 2762 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp290599wrs; Fri, 14 Oct 2022 10:12:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+kVmK8XKRPs1MKoXZGom2T9VTAH86SRqH9d9mwkYIdiE4Ay1/TGeZ8konZQeRS03Cggo7 X-Received: by 2002:a17:907:724b:b0:782:f2bb:24d3 with SMTP id ds11-20020a170907724b00b00782f2bb24d3mr4119885ejc.555.1665767545255; Fri, 14 Oct 2022 10:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665767545; cv=none; d=google.com; s=arc-20160816; b=feGWRZCyt8ZOHcVpCmtJ+4uK10ZAkjJkYgkGH7Qs283o3iOG/QA3W/GoDRqjkhjy8C B5/1J1mSgsvG6tEG4dum3D1bn3O6BZ1drFXi/pjNXritXlehFn4ku7fTUfj5AySt8Iay hI7eSgNxImYYNaKNgne8c/8pLtV7ks5JQQPuunpzVwmqLUsy4UkDPePNqc7li/S3cl63 YTUAh+ScWjAYnn+AZm3zLVs5gTerGOfnJEEshKXhGWbdeANHou9GMZd2Uh2Gxhl/JOn1 r/ovHOAbAxl9bCn7Xi69YQR8F/8+NvXEsxsmI84eYYSwgVzfybmE5VHiUvo8ODvVuhRb jv+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FuTs6shg9oNWzsKhvVbIlo+0kmXWraXUzeTkFpKkxMU=; b=YAjnkC8U6+bB2Aab+jDIER7G4Dph/u6AuwR0nOtPmYmWUdsxOm1BUF/knV25Z+Uh7V lKgGNdtXuaJ1zMgxA2Q0XEGieq+SF9qRpXB/dF0HhLv2c7KpH+ft/N4FlW4Z4rajGjAJ fZ4EGv5Vsi3FqyVVUhY7iXScOeSsnVB8U9662Yvj4KC8hU9jJ/nZaRBw2HPLkE28wn86 7fI9fonoIWuqEiOI3ixufl4CAvDcVt8MWlQYtj/lHqfHvx6DbRU4yyNyu0K7ULZ21dcN 0euPo57K+mI8WBAulIF5B6kiw0YBIw4lm3MntLLO8ul+bJ0ENBAEssd1dvS1CBvhnVpl a61w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HAgrlFex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay26-20020a056402203a00b00453b9f11b56si2264965edb.261.2022.10.14.10.11.59; Fri, 14 Oct 2022 10:12:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HAgrlFex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231176AbiJNRJr (ORCPT + 99 others); Fri, 14 Oct 2022 13:09:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbiJNRJl (ORCPT ); Fri, 14 Oct 2022 13:09:41 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F91A2F7; Fri, 14 Oct 2022 10:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665767375; x=1697303375; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lAd0o379HfkSn8aHAVMv65Af3jNDxH5nPEb/kxUyFvs=; b=HAgrlFexjV9+JjH6PwN5N18gbubqvuUHpdwM9AV13nYnZmS3u0BVjKc+ qMDo/FRR70fmFVxmP0usaNN683K6u03q2HShQ3IWeoaiLCMgmgu5Sj12N 0kb3mHBEAQDz4l+ST9MEQT34hoP4C7+6roiH9SJ/ssrfwXmFO8nc9fTlt U12PKxOiXt8MEC+NcGD3jTV0mTVikkG56hCYFwKDEPUjiV1r5ZpZOjx4G ufvcJO/bPmlbA6Vwg0XJCzKyaoVvKhL/SOE6OqcoCDzkPW1MROjKz6hHS ZH1JgKs+IgMg7hG2RC+J/yu2+LAsy92DZrfgsFB72j97ZjqvtWhtMiwhS g==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="303041981" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="303041981" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:34 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="696376948" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="696376948" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.43.79]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:32 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 3/7] perf test: test_intel_pt.sh: Print a message when skipping kernel tracing Date: Fri, 14 Oct 2022 20:09:01 +0300 Message-Id: <20221014170905.64069-4-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014170905.64069-1-adrian.hunter@intel.com> References: <20221014170905.64069-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746683869577751144?= X-GMAIL-MSGID: =?utf-8?q?1746683869577751144?= Messages display with the perf test -v option. Add a message to show when skipping a test because the user cannot do kernel tracing. Signed-off-by: Adrian Hunter --- tools/perf/tests/shell/test_intel_pt.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index 334836f92bdc..9c746ff1c4d2 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -117,7 +117,14 @@ test_system_wide_side_band() can_kernel() { - perf_record_no_decode -o "${tmpfile}" -e dummy:k true >/dev/null 2>&1 || return 2 + if [ -z "${can_kernel_trace}" ] ; then + can_kernel_trace=0 + perf_record_no_decode -o "${tmpfile}" -e dummy:k true >/dev/null 2>&1 && can_kernel_trace=1 + fi + if [ ${can_kernel_trace} -eq 0 ] ; then + echo "SKIP: no kernel tracing" + return 2 + fi return 0 } From patchwork Fri Oct 14 17:09:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 2767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp291616wrs; Fri, 14 Oct 2022 10:14:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4MUQLSCHDwVpOn+HUOA+ELDFJAYu21NJ7AyRd5lQ5kRTETp/SwLQm32tN7gzXDJ0YlA9UG X-Received: by 2002:a17:906:dac8:b0:741:545b:796a with SMTP id xi8-20020a170906dac800b00741545b796amr4262187ejb.240.1665767683860; Fri, 14 Oct 2022 10:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665767683; cv=none; d=google.com; s=arc-20160816; b=i4Uj7lYiU8Sj9VjuwnHh8lzKUCbJOy/+hLUNE6+tTI+nfcnNkd+Xcl2jp2VESbAeax vKKK2IQOe2TlYUBSJu8zlw/hT6PLAQxGdwQcLwo0zorosrHcxd0aDgx4m3UWNediRF0z 4bB8/CH0P1VPz2MigD4aPBS0JvL9nyQiFF9NSCYVJHGyowPs0ckt96uNx+6qDGu1r5QX eO6sBxfXbNzN8/Ul2a4lc+nG4RSAGIoigWv14pGOENX/yxW2o9TCq4jbZK2RX1BCSiZb xyAUjdqVJc1AHzaZnLJCMyQ5iT8Df9yTjZvbdPXlpfscVJKvlhdkonEijVnJfZ4y2aPC zdcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZBRHs/x/XGyMoIyufBWJlhrM404cnDolFnPuEIarCcs=; b=I5KWx8SG3dvYocilhsFTeKru5LVhDHGnca/ubBPY1qvt9vU3gAMVa2migVgRLE2Okw fP70TzwuvQv3UVZBj6dPwwCL4WT1nbayg+q8eKbBoZlpJomLiscoSYDq7Ajb+K1UOubx yeia1FI/cxCotxVmASyZdeli8MRP7dBvl5O2YB4XHqtdhmdPte1tY1dUadxHpwujpNB+ 4nOYz0KnNxh+MAJ6vQsK3DeD04BORh6RkpBe8LF3yP5OKAPzZU0R67vGl0fneMCDK6re qne+A1mS2IeGRg2q7D2MKhVpq9XapZ5jtTXQhb7acloId57eqQC/awP4t1syZ91jfnV4 6zlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cqypmMsX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt19-20020a170907729300b00732fcbcfedesi2738821ejc.623.2022.10.14.10.14.16; Fri, 14 Oct 2022 10:14:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cqypmMsX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231233AbiJNRJ5 (ORCPT + 99 others); Fri, 14 Oct 2022 13:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231157AbiJNRJm (ORCPT ); Fri, 14 Oct 2022 13:09:42 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D51FB10F2; Fri, 14 Oct 2022 10:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665767377; x=1697303377; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=teTkEp602ihKMIylodGYkA9Vpz7WieiJ0+obkFaWITU=; b=cqypmMsX3tK3mumIoJp2jCAbODalCoklGzzRNQnYbvIM1DBFDqNBX2v/ 9AK2DlAaWeU6jw2niUx36HqGhUaytk2dgU+4X2zYCdtiVyn4avCGwKxwG YpjqRcajq6igz1tst/A87rsvsE+cWgS8h95/PbQZJ2k5/F9EItctGEoxS GrA4H1VnAj0wqfGAea/ty5dzspRpfAkCM4fB6FisHwtS3/V1SsAk9etZx zOENTY0sWMDR8mzaefT4akDdP7/EI/BrMBxZIBJbZQQUSOwFdRR+e2lOX oKtkNzgFP0U6FWEqxgzOX2K1rdNd7xbl68F4/1gp3pQ4JiIR/d0sJAA/M A==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="303041989" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="303041989" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:37 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="696376983" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="696376983" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.43.79]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:35 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 4/7] perf test: test_intel_pt.sh: Tidy some alignment Date: Fri, 14 Oct 2022 20:09:02 +0300 Message-Id: <20221014170905.64069-5-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014170905.64069-1-adrian.hunter@intel.com> References: <20221014170905.64069-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746684015058681979?= X-GMAIL-MSGID: =?utf-8?q?1746684015058681979?= Tidy alignment of test function lines to make them more readable. Signed-off-by: Adrian Hunter --- tools/perf/tests/shell/test_intel_pt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index 9c746ff1c4d2..79dde57b561d 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -283,9 +283,9 @@ count_result() } ret=0 -test_system_wide_side_band || ret=$? ; count_result $ret ; ret=0 -test_per_thread "" "" || ret=$? ; count_result $ret ; ret=0 -test_per_thread "k" "(incl. kernel) " || ret=$? ; count_result $ret ; ret=0 +test_system_wide_side_band || ret=$? ; count_result $ret ; ret=0 +test_per_thread "" "" || ret=$? ; count_result $ret ; ret=0 +test_per_thread "k" "(incl. kernel) " || ret=$? ; count_result $ret ; ret=0 cleanup From patchwork Fri Oct 14 17:09:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 2763 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp291052wrs; Fri, 14 Oct 2022 10:13:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PJF0x01xApP/okojPeanwhFyl4lx9XPkfwQL4VQxJ+DECSJtO2d2xI9JJWFLBMGkQ28xP X-Received: by 2002:a17:907:2d06:b0:78d:50db:130e with SMTP id gs6-20020a1709072d0600b0078d50db130emr4326196ejc.371.1665767599726; Fri, 14 Oct 2022 10:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665767599; cv=none; d=google.com; s=arc-20160816; b=V7e0jPep/QUgvFaxNL6H+6l/jLI70qG9LJUWGbbA9Qy8/GSZk3wJhe9auJlTWGN6ed khG2dFxUZuiyJDYOTPIJukI+bbzEw3RfuJ5rKaGwBzDAtfXMjQib0j5RY4qvaDF7Stde +0jhTR06dO59ysVdgt11fnNE1s6igs4q+KKroOYg2k0YoeZsXaRbTjfI4lFJAN/kjDBx umfKrknArTSSohSqBa9ORDNvqmfcq2x9XYBtZX9/WIlzx+5jNrKAKW70fkE/Ylx6Qsa/ kK4M9PEFha0T+/QYdOPtrUPC9cSnHn5LbJJjvdiKCZYasZwQoJrbozD7WrwF0Hl+9mdG Q1jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o53/4aNc+E13CXp4H20YRBY2z5ey25Hx9er/139oLaI=; b=ciuy7BBgqo2RZqgPAdjCIcxlaMhHucOtQbfDoUZgsIPm9C2Yb4U1gRxb3PPbdWh2U2 DQQhEhfR3TdAexKlO8BnWUmE05ImnjUqfkW6GYURYZi0z6fvv4nhmJbNNG1iy+WJdm6e LH7MUjfuDa5Hzvijjtj5VC1iSBfpx+2BXAkNhmMH/8xp9rOPaWpGAKFE/rnLcLoFniMs xk8CuokuqQN23zh/IQEISNizWqbbbvfbiMfnjIdJaFhUSJXMdD1+HTyG/5Y1Ecum6mqP vBu5ozQQUTzMom2OCdb2cnX+H3F/7BXNfqaHKyqLkMej+Ny+yoaHJ5K8rz+4e3kz1siZ W3/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U0IlDhdy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn41-20020a1709070d2900b0077cfdda438csi2991696ejc.35.2022.10.14.10.12.51; Fri, 14 Oct 2022 10:13:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U0IlDhdy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231238AbiJNRKG (ORCPT + 99 others); Fri, 14 Oct 2022 13:10:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231235AbiJNRJ5 (ORCPT ); Fri, 14 Oct 2022 13:09:57 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 002361E730; Fri, 14 Oct 2022 10:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665767386; x=1697303386; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BfjeSY7KNgsN+P4GwvYyJZrJWkkSdPm7/zXQBtNNFk4=; b=U0IlDhdyvZhbsV/LC4L/j1/BucB5//BxJRMKM2PN19++Qq8qdTMpVeIu T5THxKIz3dWGHEX5lpO7pfdELg/9wZc6jV/O195D5TXsAcWGPvXOLNFah aYaXzb1+ayIEW0iEafBaTEDBg+m5L9+PMUEA5pXJxNJDaIKRCzoRizWRR DjfErPmmxPgx4ghOMZ4Zd+t1btcBBqR6pc5zrLhG0irIkxvGOJ2AlBfw0 d3EBGQETrbfF1I+ZdrKIS/XZZHe7kwA09cff9abixoHQEqnfbascTY8B9 p1dphRA8jLZp11OgC7+iJrfqHyjLIrAVd46Z7U3Hl2ISsa5O8Ne1EfoIW w==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="303041997" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="303041997" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:43 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="696377013" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="696377013" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.43.79]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:37 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 5/7] perf test: test_intel_pt.sh: Add jitdump test Date: Fri, 14 Oct 2022 20:09:03 +0300 Message-Id: <20221014170905.64069-6-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014170905.64069-1-adrian.hunter@intel.com> References: <20221014170905.64069-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746683926630931945?= X-GMAIL-MSGID: =?utf-8?q?1746683926630931945?= Add a test for decoding self-modifying code using a jitdump file. The test creates a workload that uses self-modifying code and generates its own jitdump file. The result is processed with perf inject --jit and checked for decoding errors. Note the test will fail without patch "perf inject: Fix GEN_ELF_TEXT_OFFSET for jit" applied. Signed-off-by: Adrian Hunter Signed-off-by: Adrian Hunter --- tools/perf/tests/shell/test_intel_pt.sh | 162 ++++++++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index 79dde57b561d..e0bf75981b9c 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -22,6 +22,7 @@ outfile="${temp_dir}/test-out.txt" errfile="${temp_dir}/test-err.txt" workload="${temp_dir}/workload" awkscript="${temp_dir}/awkscript" +jitdump_workload="${temp_dir}/jitdump_workload" cleanup() { @@ -50,6 +51,13 @@ perf_record_no_decode() perf record -B -N --no-bpf-event "$@" } +# perf record for testing should not need BPF events +perf_record_no_bpf() +{ + # Options for no BPF events + perf record --no-bpf-event "$@" +} + have_workload=false cat << _end_of_file_ | /usr/bin/cc -o "${workload}" -xc - -pthread && have_workload=true #include @@ -269,6 +277,159 @@ test_per_thread() return 0 } +test_jitdump() +{ + echo "--- Test tracing self-modifying code that uses jitdump ---" + + script_path=$(realpath "$0") + script_dir=$(dirname "$script_path") + jitdump_incl_dir="${script_dir}/../../util" + jitdump_h="${jitdump_incl_dir}/jitdump.h" + + if [ ! -e "${jitdump_h}" ] ; then + echo "SKIP: Include file jitdump.h not found" + return 2 + fi + + if [ -z "${have_jitdump_workload}" ] ; then + have_jitdump_workload=false + # Create a workload that uses self-modifying code and generates its own jitdump file + cat <<- "_end_of_file_" | /usr/bin/cc -o "${jitdump_workload}" -I "${jitdump_incl_dir}" -xc - -pthread && have_jitdump_workload=true + #define _GNU_SOURCE + #include + #include + #include + #include + #include + #include + #include + + #include "jitdump.h" + + #define CHK_BYTE 0x5a + + static inline uint64_t rdtsc(void) + { + unsigned int low, high; + + asm volatile("rdtsc" : "=a" (low), "=d" (high)); + + return low | ((uint64_t)high) << 32; + } + + static FILE *open_jitdump(void) + { + struct jitheader header = { + .magic = JITHEADER_MAGIC, + .version = JITHEADER_VERSION, + .total_size = sizeof(header), + .pid = getpid(), + .timestamp = rdtsc(), + .flags = JITDUMP_FLAGS_ARCH_TIMESTAMP, + }; + char filename[256]; + FILE *f; + void *m; + + snprintf(filename, sizeof(filename), "jit-%d.dump", getpid()); + f = fopen(filename, "w+"); + if (!f) + goto err; + /* Create an MMAP event for the jitdump file. That is how perf tool finds it. */ + m = mmap(0, 4096, PROT_READ | PROT_EXEC, MAP_PRIVATE, fileno(f), 0); + if (m == MAP_FAILED) + goto err_close; + munmap(m, 4096); + if (fwrite(&header,sizeof(header),1,f) != 1) + goto err_close; + return f; + + err_close: + fclose(f); + err: + return NULL; + } + + static int write_jitdump(FILE *f, void *addr, const uint8_t *dat, size_t sz, uint64_t *idx) + { + struct jr_code_load rec = { + .p.id = JIT_CODE_LOAD, + .p.total_size = sizeof(rec) + sz, + .p.timestamp = rdtsc(), + .pid = getpid(), + .tid = gettid(), + .vma = (unsigned long)addr, + .code_addr = (unsigned long)addr, + .code_size = sz, + .code_index = ++*idx, + }; + + if (fwrite(&rec,sizeof(rec),1,f) != 1 || + fwrite(dat, sz, 1, f) != 1) + return -1; + return 0; + } + + static void close_jitdump(FILE *f) + { + fclose(f); + } + + int main() + { + /* Get a memory page to store executable code */ + void *addr = mmap(0, 4096, PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + /* Code to execute: mov CHK_BYTE, %eax ; ret */ + uint8_t dat[] = {0xb8, CHK_BYTE, 0x00, 0x00, 0x00, 0xc3}; + FILE *f = open_jitdump(); + uint64_t idx = 0; + int ret = 1; + + if (!f) + return 1; + /* Copy executable code to executable memory page */ + memcpy(addr, dat, sizeof(dat)); + /* Record it in the jitdump file */ + if (write_jitdump(f, addr, dat, sizeof(dat), &idx)) + goto out_close; + /* Call it */ + ret = ((int (*)(void))addr)() - CHK_BYTE; + out_close: + close_jitdump(f); + return ret; + } + _end_of_file_ + fi + + if ! $have_jitdump_workload ; then + echo "SKIP: No jitdump workload" + return 2 + fi + + # Change to temp_dir so jitdump collateral files go there + cd "${temp_dir}" + perf_record_no_bpf -o "${tmpfile}" -e intel_pt//u "${jitdump_workload}" + perf inject -i "${tmpfile}" -o "${perfdatafile}" --jit + decode_br_cnt=$(perf script -i "${perfdatafile}" --itrace=b | wc -l) + # Note that overflow and lost errors are suppressed for the error count + decode_err_cnt=$(perf script -i "${perfdatafile}" --itrace=e-o-l | grep -ci error) + cd - + # Should be thousands of branches + if [ "${decode_br_cnt}" -lt 1000 ] ; then + echo "Decode failed, only ${decode_br_cnt} branches" + return 1 + fi + # Should be no errors + if [ "${decode_err_cnt}" -ne 0 ] ; then + echo "Decode failed, ${decode_err_cnt} errors" + perf script -i "${perfdatafile}" --itrace=e-o-l + return 1 + fi + + echo OK + return 0 +} + count_result() { if [ "$1" -eq 2 ] ; then @@ -286,6 +447,7 @@ ret=0 test_system_wide_side_band || ret=$? ; count_result $ret ; ret=0 test_per_thread "" "" || ret=$? ; count_result $ret ; ret=0 test_per_thread "k" "(incl. kernel) " || ret=$? ; count_result $ret ; ret=0 +test_jitdump || ret=$? ; count_result $ret ; ret=0 cleanup From patchwork Fri Oct 14 17:09:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 2764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp291089wrs; Fri, 14 Oct 2022 10:13:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6gUkqqiHFhPw0IG6mX+YsxIz5uf2sJ1FRfvJsE1MVffCAn3dPK1fZb4M7dLRHxUcFUOnX5 X-Received: by 2002:a17:907:7b86:b0:78d:cb21:da0c with SMTP id ne6-20020a1709077b8600b0078dcb21da0cmr4437460ejc.24.1665767605475; Fri, 14 Oct 2022 10:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665767605; cv=none; d=google.com; s=arc-20160816; b=km+jlLU1ZY8aAXDoomsnZBwkKBn/czMBIS3bKSJEJh14v9CMTqVMQRZ863cjlg6ksy qcPrB/yqypsYlhoLKNOHBganFwTyC2C61Gai7wZ8NFVRdzKOj0YQDbYlwsAstqofc7wx SzpiQMu86olv0+qfHN2M+NSZN2j3iewo4K7cwWL2pTdycECzURzpECDY7I4no0QcR372 X7VzKJLiH6ghFQ0hdZsQiOTSRbbseeP2MZ2ZlLl4N2gTao+4tHf28+lVw4FNhjsgaMIh vHhOdAsUZgurZ2zqVkV5e9ByyR3Ft1fy5gD/lxN+dra2GuJoYDWvGlAkAdlrQqexOOnE ftow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iH1ptCbBrlRs9LY1fGLYdSPub9oAN2yLAIX1Vx4sx/g=; b=XnZlzVnkeUuRo2NZOBi8Q40POi53G8PWCg1bEcZDLMYVTosZ2fTCSodOL7vyB3pDzE jaH4tySOGxxl96pRYQfQloPJfpinkTpdVvsShQHlYk3/K5x+Y/A0ifleZD3F08pLEd28 rku5oKpXOZF0MgdNhBK93xlgjqWy+duJeoOOKFYtg1rqBKem5ydxSUHaOtHVhTfAOc9C 8sLDnPgnqTdK1ex8/VQ/5aZ1M8jsHY+SmjtB20xU52huvWJ3wjvwbFbzqDhllJw0OOuK BXStzSmaChFI+l1O7bBazRFkuPBoIzD8cIKtpOrtAMrNl6SAANH8o/9+4Iw2NCiiF5vk uJxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=f1Ur3SGW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz3-20020a1709072ce300b0078db371355esi583764ejc.987.2022.10.14.10.12.58; Fri, 14 Oct 2022 10:13:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=f1Ur3SGW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231218AbiJNRKj (ORCPT + 99 others); Fri, 14 Oct 2022 13:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbiJNRKh (ORCPT ); Fri, 14 Oct 2022 13:10:37 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF46A8E7BA; Fri, 14 Oct 2022 10:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665767433; x=1697303433; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ryhJMBhcoSpBFXuIFT30paYnhOJbS2OmeVDypFSB8to=; b=f1Ur3SGWhbGJglRg1tCKdGurWZAeLCNJBV88h/1GambI9ZvvsAxPVXZT ftX75dM97S8O5lPeDP6j58/AdHCN50Vj9HnKgO5a5J5j3/waypH+ptPay orP90vd9Runq390R+jGPAiRAjSrOBMMsbIH5spg6aojT1wpNHm/sG36V0 ebTlbMvZvX/q/mknzfzPDeaMNovHXQLSySv2DiM1RmNHeCY7P8Wmot8Zf uK3fyvUA0Fn+AhTS7ReC9F2eFSm1SrgvOHldHWAsuO0gly7v3uQqZSFcw WEzb0/GHVP0KYIFH5XRIsi05g7zldqYWR5s0QxEAGgIbQJ+fPLVgotjnN A==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="369622660" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="369622660" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:41 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="696377032" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="696377032" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.43.79]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:39 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 6/7] perf inject: Fix GEN_ELF_TEXT_OFFSET for jit Date: Fri, 14 Oct 2022 20:09:04 +0300 Message-Id: <20221014170905.64069-7-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014170905.64069-1-adrian.hunter@intel.com> References: <20221014170905.64069-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746683932888239666?= X-GMAIL-MSGID: =?utf-8?q?1746683932888239666?= When a program header was added, it moved the text section but GEN_ELF_TEXT_OFFSET was not updated. Fix by adding the program header size and aligning. Fixes: babd04386b1d ("perf jit: Include program header in ELF files") Signed-off-by: Adrian Hunter --- tools/perf/util/genelf.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/genelf.h b/tools/perf/util/genelf.h index b5c909546e3f..6af062d1c452 100644 --- a/tools/perf/util/genelf.h +++ b/tools/perf/util/genelf.h @@ -2,6 +2,8 @@ #ifndef __GENELF_H__ #define __GENELF_H__ +#include + /* genelf.c */ int jit_write_elf(int fd, uint64_t code_addr, const char *sym, const void *code, int csize, void *debug, int nr_debug_entries, @@ -76,6 +78,6 @@ int jit_add_debug_info(Elf *e, uint64_t code_addr, void *debug, int nr_debug_ent #endif /* The .text section is directly after the ELF header */ -#define GEN_ELF_TEXT_OFFSET sizeof(Elf_Ehdr) +#define GEN_ELF_TEXT_OFFSET round_up(sizeof(Elf_Ehdr) + sizeof(Elf_Phdr), 16) #endif From patchwork Fri Oct 14 17:09:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 2765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp291090wrs; Fri, 14 Oct 2022 10:13:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70pn1Y5dNlNjbqjBZ8sWQo53lEB5W95P8S8hSRqerBcolBVasJZRwRRBflEjVzh77euuY+ X-Received: by 2002:a17:907:971e:b0:78d:e7ed:7585 with SMTP id jg30-20020a170907971e00b0078de7ed7585mr4223353ejc.258.1665767605470; Fri, 14 Oct 2022 10:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665767605; cv=none; d=google.com; s=arc-20160816; b=GmQfhxCsHx/6BNrzBhBT0cxIgJLhyP3WrOQLmfWaIQRD/aklPFNBSWMeip+14rdQ9Z eTiXjxaN9OF89yRqyz68BWbYGd+NxtCKJeOudBJqmvrCKBq0cVBfERRO5NSOBdnQlUPz TypfPcNWWakj15aoB8WD/MRxpWEfeO3zp+dR/txk6QagmMNP7jxohrpiJCFR8BfEKsdp SH1alt+zAZQuZoxnfyZsDdzWC10KIrxFhnZVobjiwglYugNy48gPi8lK8Y3EDVMEyttY KcMU31S/nF69Yek2evC/Qg1WiguJp4/E+RoblvXgONNqkEtFO0BsMBAH64JRuU4gIJ9Z libg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lL9Q5YSW4mf+8GcZm7awTXE/w62XDSNbeVuBaGDmBGs=; b=AJGvS9p3kcZ+fRrcbr+DAe0tBSCvRopAihWQmsC13USDt45ySooSXDyG8DhsJhVjxi WT0ZtTTIxj1L8ZXD+MBqK/Ziq6+z97UrXZMqZQqIRa9Hf0b+P4v4iGSGRcLYE3KHBS0n pbGp7eWGhwn0BiXOO+AEZoecRS2b+46GFkIDhLrP1WkGfDXK5vDrJSryw0Pv5j605CUy PVTT/BobmpwEeRIOmdS5SgMafjtK8OSXWx5Sob4R7zGpPWVIajc5nPSNgp04FPIquhuK SGIkFJg5xC8Iz4eoagR3cM/RHsely1vMXaWtjF5p32ZtRclqxYz19WGYGu2s8rnKXXGO ZE/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SFjxob+D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne34-20020a1709077ba200b0078e23374ab4si1753085ejc.365.2022.10.14.10.12.59; Fri, 14 Oct 2022 10:13:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SFjxob+D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231189AbiJNRKq (ORCPT + 99 others); Fri, 14 Oct 2022 13:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbiJNRKn (ORCPT ); Fri, 14 Oct 2022 13:10:43 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82298AEA2E; Fri, 14 Oct 2022 10:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665767437; x=1697303437; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hwd2CIUhGHK6qQ/DysaH8oDK+SeFFMChlzMY14O6WEI=; b=SFjxob+DXxNXUvsVeamcWOMmfrvwpmqS0njgFmxW8Qq65zm+Ut/fTJOL BqZMaMUJ2pAV6m4BCfSmVaCM0QrXwVW3UlcaH4tgsGWpPXYHshGtXtR4o NJvYi3izI/IpLYISRNsX5izI12aw8Irm+zUACLbt5IVXSqhjIJhepiI8X ztygKqfk0cAf/xfvRo2ef5NZJHoZk4bXHGoml1KvpVhJZ93Lno0jkhI9o cS01eVZP99Gki2LxMb1okdRCow0qRIh0lDaWn/C8KynH80ii8/oRX11fZ WPR9z2IApiZYg8JzgCZNeAgxYUvhB7RysNBLDz0ioNQq1YL6jk6opCG0Y Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="369622666" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="369622666" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:43 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="696377057" X-IronPort-AV: E=Sophos;i="5.95,184,1661842800"; d="scan'208";a="696377057" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.43.79]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 10:09:41 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 7/7] perf test: test_intel_pt.sh: Add 9 tests Date: Fri, 14 Oct 2022 20:09:05 +0300 Message-Id: <20221014170905.64069-8-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014170905.64069-1-adrian.hunter@intel.com> References: <20221014170905.64069-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746683932746946648?= X-GMAIL-MSGID: =?utf-8?q?1746683932746946648?= From: Ammy Yi Add tests: Test with MTC and TSC disabled Test with branches disabled Test with/without CYC Test recording with sample mode Test with kernel trace Test virtual LBR Test power events Test with TNT packets disabled Test with event_trace These tests mostly check that perf record works with the corresponding Intel PT config terms, sometimes also checking that certain packets do or do not appear in the resulting trace as appropriate. The "Test virtual LBR" is slightly trickier, using a Python script to check that branch stacks are actually synthesized. Signed-off-by: Ammy Yi Signed-off-by: Adrian Hunter --- tools/perf/tests/shell/test_intel_pt.sh | 195 +++++++++++++++++++++++- 1 file changed, 194 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index e0bf75981b9c..4c0aabbe33bd 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -23,6 +23,7 @@ errfile="${temp_dir}/test-err.txt" workload="${temp_dir}/workload" awkscript="${temp_dir}/awkscript" jitdump_workload="${temp_dir}/jitdump_workload" +maxbrstack="${temp_dir}/maxbrstack.py" cleanup() { @@ -422,7 +423,7 @@ test_jitdump() # Should be no errors if [ "${decode_err_cnt}" -ne 0 ] ; then echo "Decode failed, ${decode_err_cnt} errors" - perf script -i "${perfdatafile}" --itrace=e-o-l + perf script -i "${perfdatafile}" --itrace=e-o-l --show-mmap-events | cat return 1 fi @@ -430,6 +431,189 @@ test_jitdump() return 0 } +test_packet_filter() +{ + echo "--- Test with MTC and TSC disabled ---" + # Disable MTC and TSC + perf_record_no_decode -o "${perfdatafile}" -e intel_pt/mtc=0,tsc=0/u uname + # Should not get MTC packet + mtc_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "MTC 0x") + if [ "${mtc_cnt}" -ne 0 ] ; then + echo "Failed to filter with mtc=0" + return 1 + fi + # Should not get TSC package + tsc_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "TSC 0x") + if [ "${tsc_cnt}" -ne 0 ] ; then + echo "Failed to filter with tsc=0" + return 1 + fi + echo OK + return 0 +} + +test_disable_branch() +{ + echo "--- Test with branches disabled ---" + # Disable branch + perf_record_no_decode -o "${perfdatafile}" -e intel_pt/branch=0/u uname + # Should not get branch related packets + tnt_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "TNT 0x") + tip_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "TIP 0x") + fup_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "FUP 0x") + if [ "${tnt_cnt}" -ne 0 ] || [ "${tip_cnt}" -ne 0 ] || [ "${fup_cnt}" -ne 0 ] ; then + echo "Failed to disable branches" + return 1 + fi + echo OK + return 0 +} + +test_time_cyc() +{ + echo "--- Test with/without CYC ---" + # Check if CYC is supported + cyc=$(cat /sys/bus/event_source/devices/intel_pt/caps/psb_cyc) + if [ "${cyc}" != "1" ] ; then + echo "SKIP: CYC is not supported" + return 2 + fi + # Enable CYC + perf_record_no_decode -o "${perfdatafile}" -e intel_pt/cyc/u uname + # should get CYC packets + cyc_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "CYC 0x") + if [ "${cyc_cnt}" = "0" ] ; then + echo "Failed to get CYC packet" + return 1 + fi + # Without CYC + perf_record_no_decode -o "${perfdatafile}" -e intel_pt//u uname + # Should not get CYC packets + cyc_cnt=$(perf script -i "${perfdatafile}" -D 2>/dev/null | grep -c "CYC 0x") + if [ "${cyc_cnt}" -gt 0 ] ; then + echo "Still get CYC packet without cyc" + return 1 + fi + echo OK + return 0 +} + +test_sample() +{ + echo "--- Test recording with sample mode ---" + # Check if recording with sample mode is working + if ! perf_record_no_decode -o "${perfdatafile}" --aux-sample=8192 -e '{intel_pt//u,branch-misses:u}' uname ; then + echo "perf record failed with --aux-sample" + return 1 + fi + echo OK + return 0 +} + +test_kernel_trace() +{ + echo "--- Test with kernel trace ---" + # Check if recording with kernel trace is working + can_kernel || return 2 + if ! perf_record_no_decode -o "${perfdatafile}" -e intel_pt//k -m1,128 uname ; then + echo "perf record failed with intel_pt//k" + return 1 + fi + echo OK + return 0 +} + +test_virtual_lbr() +{ + echo "--- Test virtual LBR ---" + + # Python script to determine the maximum size of branch stacks + cat << "_end_of_file_" > "${maxbrstack}" +from __future__ import print_function + +bmax = 0 + +def process_event(param_dict): + if "brstack" in param_dict: + brstack = param_dict["brstack"] + n = len(brstack) + global bmax + if n > bmax: + bmax = n + +def trace_end(): + print("max brstack", bmax) +_end_of_file_ + + # Check if virtual lbr is working + perf_record_no_bpf -o "${perfdatafile}" --aux-sample -e '{intel_pt//,cycles}:u' uname + times_val=$(perf script -i "${perfdatafile}" --itrace=L -s "${maxbrstack}" 2>/dev/null | grep "max brstack " | cut -d " " -f 3) + case "${times_val}" in + [0-9]*) ;; + *) times_val=0;; + esac + if [ "${times_val}" -lt 2 ] ; then + echo "Failed with virtual lbr" + return 1 + fi + echo OK + return 0 +} + +test_power_event() +{ + echo "--- Test power events ---" + # Check if power events are supported + power_event=$(cat /sys/bus/event_source/devices/intel_pt/caps/power_event_trace) + if [ "${power_event}" != "1" ] ; then + echo "SKIP: power_event_trace is not supported" + return 2 + fi + if ! perf_record_no_decode -o "${perfdatafile}" -a -e intel_pt/pwr_evt/u uname ; then + echo "perf record failed with pwr_evt" + return 1 + fi + echo OK + return 0 +} + +test_no_tnt() +{ + echo "--- Test with TNT packets disabled ---" + # Check if TNT disable is supported + notnt=$(cat /sys/bus/event_source/devices/intel_pt/caps/tnt_disable) + if [ "${notnt}" != "1" ] ; then + echo "SKIP: tnt_disable is not supported" + return 2 + fi + perf_record_no_decode -o "${perfdatafile}" -e intel_pt/notnt/u uname + # Should be no TNT packets + tnt_cnt=$(perf script -i "${perfdatafile}" -D | grep -c TNT) + if [ "${tnt_cnt}" -ne 0 ] ; then + echo "TNT packets still there after notnt" + return 1 + fi + echo OK + return 0 +} + +test_event_trace() +{ + echo "--- Test with event_trace ---" + # Check if event_trace is supported + event_trace=$(cat /sys/bus/event_source/devices/intel_pt/caps/event_trace) + if [ "${event_trace}" != 1 ] ; then + echo "SKIP: event_trace is not supported" + return 2 + fi + if ! perf_record_no_decode -o "${perfdatafile}" -e intel_pt/event/u uname ; then + echo "perf record failed with event trace" + return 1 + fi + echo OK + return 0 +} + count_result() { if [ "$1" -eq 2 ] ; then @@ -448,6 +632,15 @@ test_system_wide_side_band || ret=$? ; count_result $ret ; ret=0 test_per_thread "" "" || ret=$? ; count_result $ret ; ret=0 test_per_thread "k" "(incl. kernel) " || ret=$? ; count_result $ret ; ret=0 test_jitdump || ret=$? ; count_result $ret ; ret=0 +test_packet_filter || ret=$? ; count_result $ret ; ret=0 +test_disable_branch || ret=$? ; count_result $ret ; ret=0 +test_time_cyc || ret=$? ; count_result $ret ; ret=0 +test_sample || ret=$? ; count_result $ret ; ret=0 +test_kernel_trace || ret=$? ; count_result $ret ; ret=0 +test_virtual_lbr || ret=$? ; count_result $ret ; ret=0 +test_power_event || ret=$? ; count_result $ret ; ret=0 +test_no_tnt || ret=$? ; count_result $ret ; ret=0 +test_event_trace || ret=$? ; count_result $ret ; ret=0 cleanup