From patchwork Mon May 8 09:39:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 91056 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2066344vqo; Mon, 8 May 2023 04:06:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Gdu4gqnDdjNfhlYCbQNX+sMX06iV2Pe9/y9Ngm80IUiKxmshyv4gt1E0bXfYcHWUiL8ad X-Received: by 2002:a17:90a:8807:b0:249:842d:312f with SMTP id s7-20020a17090a880700b00249842d312fmr10231872pjn.4.1683543970964; Mon, 08 May 2023 04:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683543970; cv=none; d=google.com; s=arc-20160816; b=hgq3Wr4m32YMlPgrtml+lhQI3juJaKlsd2HAwbWosDMKpo3LEdh9Z4jKJBmPcceBcd cfob8ZLiRmHuK1aU19bL0CsEGIIaiFgHqVi5aFZqLyD8a0hoNGIVV0KEJoqSzJHaHYA9 cfOhjFbd+kpSWnBQF8uTIy+2hEJGM2x+FIv7O7cTwG6WMVmIADlkF2abkzBLZBG9w5ig yWXWelJMj/zj2Qxmd4xyHrKORaf1FGW9ZsgifSzT93IAxBFgWN5hRLzBmK4l5X+Oawch ainlh5xoldh+sHULbF6kJR96J7LtUP8f1TuOWZxQep65ZCE+j9ZLz2wI2FnxPPV8F3sh DcWw== 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=k9pohIlARNdvP2r9o+BTBOTRYJfsS5Ul4FwKk9ThLJ0=; b=CnD2B3peRkQUk2UkAO33wBJ8qmQijhvA3hPfqrhHjVcFsG82Zz7kj3lr8x5S/PcbZ4 wY6utq3lsEcoVpDhpSD9JJSbj91M1PwXhAXwjokt84XPy2rNzL6vKzD0Y/uOcoJd819L ZeUr+vWqRBfLEvSoDerisv4vLypsiH7eqvmjk/qnffzvTcuY+HJdDixUYufeeyUZhq6w LC80oXqTiv4IlMEuuLFC7vxFkzpnHi20FGICYs8FBZejzF3bSQSALJ36+jLOj2vlgOiY sHHlY06uvvYcxERo9kj7gT7bHcjiIlLtFDIztDDhZoNIMuAmiRZJAvgGE78aqy0acesQ 0VCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YfbM8Kxd; 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 r20-20020a6560d4000000b0050c0305bcc3si7874837pgv.872.2023.05.08.04.05.57; Mon, 08 May 2023 04:06:10 -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=YfbM8Kxd; 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 S232876AbjEHJkj (ORCPT + 99 others); Mon, 8 May 2023 05:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233320AbjEHJkf (ORCPT ); Mon, 8 May 2023 05:40:35 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A81C1709; Mon, 8 May 2023 02:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683538834; x=1715074834; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sSDUjz0u29bzzq8v6TDWYjblxhEbQSlIDyH3SkiaiiY=; b=YfbM8KxdYdwjvwI7cGEVhXhmuI1L1JNoyYTHnDLkmMdlfwRzfvsl9tqT 4CaltOI815bTsjEcnZ26bEvul2MNlOmlisa8p6I4Ov4mMnFnPfRKUAcFq 3VBy/luVpPRs+D1Pkyt2kbaCJNDlqkYV/iC223uTwb/cU6pN+vm5wGJUG yJEHWjfv64Amp4cWTfuyvUk7V72/2Rs0Yho+RIZnKcGFL4xet45QaFfO2 DOi1Pw4bbhRruSPvWbbX+w5/WWTuoMwk78FRAgiYfo7qXeogjE4XPm3AN 6brXv9ZMDCCDW3g33WUXlnUwGpkELbQia3mCZ9emKELEvmMV3xeIt/CcN w==; X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="329223680" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="329223680" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 02:40:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="1028354989" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="1028354989" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.251.218.65]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 02:40: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 V2 1/2] perf test: test_intel_pt.sh: Test sample mode with event with PMU name Date: Mon, 8 May 2023 12:39:51 +0300 Message-Id: <20230508093952.27482-2-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230508093952.27482-1-adrian.hunter@intel.com> References: <20230508093952.27482-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_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE 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?1765323802894012797?= X-GMAIL-MSGID: =?utf-8?q?1765323802894012797?= br_misp_retired.all_branches is supported on processors that support Intel PT, so use it to test sample mode with an event that has been given a PMU name. Please note, the test fails prior to the fix "perf parse-events: Do not break up AUX event group". Signed-off-by: Adrian Hunter --- tools/perf/tests/shell/test_intel_pt.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index 4ddb17cb83c5..3a8b9bffa022 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -506,6 +506,13 @@ test_sample() echo "perf record failed with --aux-sample" return 1 fi + # Check with event with PMU name + if perf_record_no_decode -o "${perfdatafile}" -e br_misp_retired.all_branches:u uname ; then + if ! perf_record_no_decode -o "${perfdatafile}" -e '{intel_pt//,br_misp_retired.all_branches/aux-sample-size=8192/}:u' uname ; then + echo "perf record failed with --aux-sample-size" + return 1 + fi + fi echo OK return 0 } From patchwork Mon May 8 09:39:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 91062 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2067701vqo; Mon, 8 May 2023 04:08:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NwAkihG1PJbftHlz4vo0HGu+iCHPG+jWtf0gTBO3Mi97t+hnDkFQbvkIZ5UvDBUjy6xNF X-Received: by 2002:a17:902:d701:b0:19f:2328:beee with SMTP id w1-20020a170902d70100b0019f2328beeemr9774996ply.11.1683544098463; Mon, 08 May 2023 04:08:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683544098; cv=none; d=google.com; s=arc-20160816; b=PxzA1YdxKeEt+zV+jcWYOEJsiog1BZUY66vJeEJgZe9fsZFwsHWv7UbpjHfETr2l98 +CONQxt33E6dSNYDTcPUEM29xrWdZCk1Zg7Amv+I863bPzQJPBI3rMoetE/nIdW9/M7W Rb0XHaC9ThsAve9GIZZLSv5Xj7a5LWVR8Yj7lRNQwkcSbvAJeMZM0okeysk7TAu3zzOw uOdaSsSTqNaG8NQxiiS372BG6h3LjrZxn1f8J8cJCFB9pRDWJQ2GAo775uEuGCIuH3DQ OE0+qpTh5E/HGlBDMtVuWeM9Aj8PAGBlL1Tp9ibWWxbKHXObiaxg+cIO6V+OF1CmA+8r Jt5w== 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=yGgFvXIDDO2Y1O/Phy1eDU8WBHm/28tLbiZKhVMHafc=; b=wOEWIUtyRdl888urm+5axBj0gmsSJCSSjCBfKcuvTAMXLZFlGu+TSqrsXvORrW8j40 rNrPov3I0nt5/sEMYzCS494aZ+zUlogb7l0cmdh2TxS8nkbF10mDFoVItHpxy6Imt6zR RTqpumd+vQxIW6UZ6zjoX81ESVFzauZB1pYaP8picAzD2XEjSqUjNWj5dJyxzyNxqKtS mwy6MQNM/iW0Z4+27gGp1TfxAXbdkRpgEcrjBCGaQOiof4XXTAeDt1guVnomrH75klHY SGyE+z6esKuSS6aH/Rg4YK0tDvN9+nkZpLttNF5zXE+ep0JeEKygnZ9SKdtf8VMuGOPe 7Ghw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="jO//7Qyv"; 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 i17-20020a170902c95100b001ac893fa8dasi381610pla.144.2023.05.08.04.08.02; Mon, 08 May 2023 04:08:18 -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="jO//7Qyv"; 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 S232924AbjEHJko (ORCPT + 99 others); Mon, 8 May 2023 05:40:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233746AbjEHJkh (ORCPT ); Mon, 8 May 2023 05:40:37 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5E731709; Mon, 8 May 2023 02:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683538836; x=1715074836; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DRRzVfLR8FQOzqTHIuV3hywtd7FraWhxifJu1SEXR9Q=; b=jO//7Qyv70bBTcaS0XOvN8bffu3tVvAs90V4UOiwD3LdkNdHIL4Rn66r IguWLxGG7PuCVmuE/l/Ttc4sp44bWkIax/bZsheHfHPwF8THGvm762Pdl SRD8J91uzV4t6Kv4H91c0zaxeA3xAUSMhFrTlLN7Ken7rLOEB9lCZJjBK 62G3oDf0KWwi2ZV55tl0q2l/9iaGpGVr0whi4AAcF2ZO93yhOf4oOaP3p d2+BMGvn9m9OigDeLpqDChKBGChn/UcHCVN3GktYULMJ5BHSqPtJ1muV0 GOUefrfOPI6ukINP3TdLQiTFBmrYgfysqvR1C8zJyG/OwJ5HXlYNwpTde g==; X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="329223689" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="329223689" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 02:40:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="1028354993" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="1028354993" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.251.218.65]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 02:40:34 -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 V2 2/2] perf parse-events: Do not break up AUX event group Date: Mon, 8 May 2023 12:39:52 +0300 Message-Id: <20230508093952.27482-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230508093952.27482-1-adrian.hunter@intel.com> References: <20230508093952.27482-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_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE 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?1765323726781473756?= X-GMAIL-MSGID: =?utf-8?q?1765323936498512136?= Do not assume which events may have a PMU name, allowing the logic to keep an AUX event group together. Example: Before: $ perf record --no-bpf-event -c 10 -e '{intel_pt//,tlb_flush.stlb_any/aux-sample-size=8192/pp}:u' -- sleep 0.1 WARNING: events were regrouped to match PMUs Cannot add AUX area sampling to a group leader After: $ perf record --no-bpf-event -c 10 -e '{intel_pt//,tlb_flush.stlb_any/aux-sample-size=8192/pp}:u' -- sleep 0.1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.078 MB perf.data ] $ perf script -F-dso,+addr | grep -C5 tlb_flush.stlb_any | head -11 sleep 20444 [003] 7939.510243: 1 branches:uH: 7f5350cc82a2 dl_main+0x9a2 => 7f5350cb38f0 _dl_add_to_namespace_list+0x0 sleep 20444 [003] 7939.510243: 1 branches:uH: 7f5350cb3908 _dl_add_to_namespace_list+0x18 => 7f5350cbb080 rtld_mutex_dummy+0x0 sleep 20444 [003] 7939.510243: 1 branches:uH: 7f5350cc8350 dl_main+0xa50 => 0 [unknown] sleep 20444 [003] 7939.510244: 1 branches:uH: 7f5350cc83ca dl_main+0xaca => 7f5350caeb60 _dl_process_pt_gnu_property+0x0 sleep 20444 [003] 7939.510245: 1 branches:uH: 7f5350caeb60 _dl_process_pt_gnu_property+0x0 => 0 [unknown] sleep 20444 7939.510245: 10 tlb_flush.stlb_any/aux-sample-size=8192/pp: 0 7f5350caeb60 _dl_process_pt_gnu_property+0x0 sleep 20444 [003] 7939.510254: 1 branches:uH: 7f5350cc87fe dl_main+0xefe => 7f5350ccd240 strcmp+0x0 sleep 20444 [003] 7939.510254: 1 branches:uH: 7f5350cc8862 dl_main+0xf62 => 0 [unknown] sleep 20444 [003] 7939.510255: 1 branches:uH: 7f5350cc9cdc dl_main+0x23dc => 0 [unknown] sleep 20444 [003] 7939.510257: 1 branches:uH: 7f5350cc89f6 dl_main+0x10f6 => 7f5350cb9530 _dl_setup_hash+0x0 sleep 20444 [003] 7939.510257: 1 branches:uH: 7f5350cc8a2d dl_main+0x112d => 7f5350cb3990 _dl_new_object+0x0 Suggested-by: Ian Rogers Fixes: 347c2f0a0988 ("perf parse-events: Sort and group parsed events") Signed-off-by: Adrian Hunter Tested-by: Ian Rogers --- tools/perf/util/evsel.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e18752fd9245..9fdcde5471df 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -828,11 +828,9 @@ bool evsel__name_is(struct evsel *evsel, const char *name) const char *evsel__group_pmu_name(const struct evsel *evsel) { - struct evsel *leader, *pos; + struct evsel *leader = evsel__leader(evsel); + struct evsel *pos; - /* If the pmu_name is set use it. pmu_name isn't set for CPU and software events. */ - if (evsel->pmu_name) - return evsel->pmu_name; /* * Software events may be in a group with other uncore PMU events. Use * the pmu_name of the first non-software event to avoid breaking the @@ -841,7 +839,6 @@ const char *evsel__group_pmu_name(const struct evsel *evsel) * Aux event leaders, like intel_pt, expect a group with events from * other PMUs, so substitute the AUX event's PMU in this case. */ - leader = evsel__leader(evsel); if (evsel->core.attr.type == PERF_TYPE_SOFTWARE || evsel__is_aux_event(leader)) { /* Starting with the leader, find the first event with a named PMU. */ for_each_group_evsel(pos, leader) { @@ -850,7 +847,7 @@ const char *evsel__group_pmu_name(const struct evsel *evsel) } } - return "cpu"; + return evsel->pmu_name ?: "cpu"; } const char *evsel__metric_id(const struct evsel *evsel)