Message ID | 20230505064452.9660-1-adrian.hunter@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp199141vqo; Fri, 5 May 2023 00:01:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GJU7veQeyKDc9TlIEB3TfsZWO7xJu7dm1NqZkDcCZX4xTpP59LyG21W/EMwXIakE1E6ls X-Received: by 2002:a17:90b:1804:b0:24e:2759:8dbe with SMTP id lw4-20020a17090b180400b0024e27598dbemr994616pjb.7.1683270099423; Fri, 05 May 2023 00:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683270099; cv=none; d=google.com; s=arc-20160816; b=szi8sZSwmZeJH9x8eUvIASFRNONF/6N+yuXsvPGybd2juxe4MIZc61Jgo+WgFnYP7H JZlLQsCsU6wV3ScXVitgVK6uNbxswGbxd2V9wsRC6uRKVLm3MQiBoHnBFGtDJqNVnd3g DWp+O5dWawsK6hroFzHZtredEMvTUvwBB8jLRAKhHhDdA0ensnzafJfgnTLKkVhE8lb4 gS7ozdHMmH7tPrGmbi08g75bGGl1RAlKAAenjR1iEBAn8AKmrjHPv3UEahzqJi8sBIKV iEMyTj9Z3URit14mgFmxn/CBBLOGOWxI5WMtsVH0ilozala540ZKq1eIA2rjAygb4t7M dEKw== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=icHD4pxN+yP0+4gnJi11sJ9MPIYxlu/OwpG+aZ5FfI4=; b=wdwrv02iE/ZK5dX0NsipoAg3O9z4G4JNIFQkFCp4xtrRXgZJERfw8jCUOHgjEOWC5J vKPKatDpmU+xZnZEIQ0quRyfy4l1e/HSsf3MUacFHBbqGcsCpc3ZxMRK2g/ozHOACeUI GpplcTjCyK1DH3TF+IM55JaCABzzxsnOCyct0fbSZ+a1yKHa75pmdN0p5fcHjFx6V+vw oPuuEW5I/rMbzWDSBaDFWPiEaAelf2PyNM8OCGSXzU4oz/u63ScvkTgTHsNgE8JH8dfK ozwCXrJX0NYhSytef24UkWibMZJhxjjrdFvyp7/BsxM5QJf7C6Z2VBvKkOwn/QgMVF2P BihA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FmJImMTK; 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 w30-20020a637b1e000000b005143d5f9ff0si1420559pgc.357.2023.05.05.00.01.25; Fri, 05 May 2023 00:01:39 -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=FmJImMTK; 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 S231172AbjEEGph (ORCPT <rfc822;b08248@gmail.com> + 99 others); Fri, 5 May 2023 02:45:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231157AbjEEGpe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 5 May 2023 02:45:34 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A7DB4C12; Thu, 4 May 2023 23:45: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=1683269130; x=1714805130; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4KhTQWYJpyZeeVVAqWxzuhhuJ24zjCNfiqa/E3D5Nws=; b=FmJImMTKul5Ft39vikBGwCRKF5XwuGnvuTr6fVxbBMap0t5GFKbfmql/ NanMN+JPDq8LWR43nVPH2nmAb5JB1qWyiXmRslKRRzKuDfEOOu59LdhJh cEUa7vWvyxb+PblKZd8D6eTVpoX19s9O9wvUffQjgU9dD8rhELVFVaXME 0T9VRvvNADU7/qFr7DtwULU/DzZK4uL6Bh6GQ2he0BwSNhMjhOWdFCv+k yt+qDtonxy9o4xCFnnf7EHKnAnh3vPUyDwIJ2ZBKWUOwpErtiPrbKeY3w 9kb/b76f1IT92ObYCUBg2Iy4BsSyPHPs2R2HoBmAxptRLRQz5SdFVWJRe g==; X-IronPort-AV: E=McAfee;i="6600,9927,10700"; a="333565129" X-IronPort-AV: E=Sophos;i="5.99,251,1677571200"; d="scan'208";a="333565129" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2023 23:45:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10700"; a="943714373" X-IronPort-AV: E=Sophos;i="5.99,251,1677571200"; d="scan'208";a="943714373" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.251.216.212]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2023 23:45:05 -0700 From: Adrian Hunter <adrian.hunter@intel.com> To: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH] perf parse-events: Do not break up AUX event group Date: Fri, 5 May 2023 09:44:52 +0300 Message-Id: <20230505064452.9660-1-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765036627277665939?= X-GMAIL-MSGID: =?utf-8?q?1765036627277665939?= |
Series |
perf parse-events: Do not break up AUX event group
|
|
Commit Message
Adrian Hunter
May 5, 2023, 6:44 a.m. UTC
Assume AUX event group is correct and not do break it up.
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
Fixes: 347c2f0a0988 ("perf parse-events: Sort and group parsed events")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/evsel.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
Comments
On Thu, May 4, 2023 at 11:45 PM Adrian Hunter <adrian.hunter@intel.com> wrote: > > Assume AUX event group is correct and not do break it up. > > 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 Could we add this, or similar, to the intel_pt tests? > 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 > > Fixes: 347c2f0a0988 ("perf parse-events: Sort and group parsed events") > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> These changes are related: https://lore.kernel.org/lkml/20230502223851.2234828-5-irogers@google.com/ https://lore.kernel.org/lkml/20230502223851.2234828-20-irogers@google.com/ > --- > tools/perf/util/evsel.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index 356c07f03be6..a34f61a5271d 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -828,7 +828,11 @@ bool evsel__name_is(struct evsel *evsel, const char *name) > > const char *evsel__group_pmu_name(const struct evsel *evsel) > { > - const struct evsel *leader; > + const struct evsel *leader = evsel__leader(evsel); > + > + /* Never break AUX event groups */ > + if (evsel__is_aux_event(leader)) > + return leader->pmu_name; > > /* If the pmu_name is set use it. pmu_name isn't set for CPU and software events. */ I think this comment isn't true, hence this patch. I think we should just move the check into the return, so: return evsel->pmu_name ?: "cpu"; Sorry for the breakage! Thanks, Ian > if (evsel->pmu_name) > @@ -837,15 +841,9 @@ const char *evsel__group_pmu_name(const struct evsel *evsel) > * Software events may be in a group with other uncore PMU events. Use > * the pmu_name of the group leader to avoid breaking the software event > * out of the group. > - * > - * 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)) && > - leader->pmu_name) { > + if (evsel->core.attr.type == PERF_TYPE_SOFTWARE && leader->pmu_name) > return leader->pmu_name; > - } > > return "cpu"; > } > -- > 2.34.1 >
On 5/05/23 16:02, Ian Rogers wrote: > On Thu, May 4, 2023 at 11:45 PM Adrian Hunter <adrian.hunter@intel.com> wrote: >> >> Assume AUX event group is correct and not do break it up. >> >> 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 > > Could we add this, or similar, to the intel_pt tests? Sure > >> 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 >> >> Fixes: 347c2f0a0988 ("perf parse-events: Sort and group parsed events") >> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> > > These changes are related: > https://lore.kernel.org/lkml/20230502223851.2234828-5-irogers@google.com/ > https://lore.kernel.org/lkml/20230502223851.2234828-20-irogers@google.com/ Ok but 347c2f0a0988 is queued for 6.4, so these fixes need to go to 6.4 as well > >> --- >> tools/perf/util/evsel.c | 14 ++++++-------- >> 1 file changed, 6 insertions(+), 8 deletions(-) >> >> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c >> index 356c07f03be6..a34f61a5271d 100644 >> --- a/tools/perf/util/evsel.c >> +++ b/tools/perf/util/evsel.c >> @@ -828,7 +828,11 @@ bool evsel__name_is(struct evsel *evsel, const char *name) >> >> const char *evsel__group_pmu_name(const struct evsel *evsel) >> { >> - const struct evsel *leader; >> + const struct evsel *leader = evsel__leader(evsel); >> + >> + /* Never break AUX event groups */ >> + if (evsel__is_aux_event(leader)) >> + return leader->pmu_name; >> >> /* If the pmu_name is set use it. pmu_name isn't set for CPU and software events. */ > > I think this comment isn't true, hence this patch. I think we should > just move the check into the return, so: > return evsel->pmu_name ?: "cpu"; Ok I will send a V2 > > Sorry for the breakage! No problem! > > Thanks, > Ian > >> if (evsel->pmu_name) >> @@ -837,15 +841,9 @@ const char *evsel__group_pmu_name(const struct evsel *evsel) >> * Software events may be in a group with other uncore PMU events. Use >> * the pmu_name of the group leader to avoid breaking the software event >> * out of the group. >> - * >> - * 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)) && >> - leader->pmu_name) { >> + if (evsel->core.attr.type == PERF_TYPE_SOFTWARE && leader->pmu_name) >> return leader->pmu_name; >> - } >> >> return "cpu"; >> } >> -- >> 2.34.1 >>
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 356c07f03be6..a34f61a5271d 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -828,7 +828,11 @@ bool evsel__name_is(struct evsel *evsel, const char *name) const char *evsel__group_pmu_name(const struct evsel *evsel) { - const struct evsel *leader; + const struct evsel *leader = evsel__leader(evsel); + + /* Never break AUX event groups */ + if (evsel__is_aux_event(leader)) + return leader->pmu_name; /* If the pmu_name is set use it. pmu_name isn't set for CPU and software events. */ if (evsel->pmu_name) @@ -837,15 +841,9 @@ const char *evsel__group_pmu_name(const struct evsel *evsel) * Software events may be in a group with other uncore PMU events. Use * the pmu_name of the group leader to avoid breaking the software event * out of the group. - * - * 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)) && - leader->pmu_name) { + if (evsel->core.attr.type == PERF_TYPE_SOFTWARE && leader->pmu_name) return leader->pmu_name; - } return "cpu"; }