linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf parse-events: Do not break up AUX event group
@ 2023-05-05  6:44 Adrian Hunter
  2023-05-05 13:02 ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Hunter @ 2023-05-05  6:44 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel, linux-perf-users

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(-)

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";
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf parse-events: Do not break up AUX event group
  2023-05-05  6:44 [PATCH] perf parse-events: Do not break up AUX event group Adrian Hunter
@ 2023-05-05 13:02 ` Ian Rogers
  2023-05-05 13:45   ` Adrian Hunter
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2023-05-05 13:02 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Namhyung Kim, linux-kernel,
	linux-perf-users

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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf parse-events: Do not break up AUX event group
  2023-05-05 13:02 ` Ian Rogers
@ 2023-05-05 13:45   ` Adrian Hunter
  0 siblings, 0 replies; 3+ messages in thread
From: Adrian Hunter @ 2023-05-05 13:45 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Namhyung Kim, linux-kernel,
	linux-perf-users

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
>>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-05 13:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-05  6:44 [PATCH] perf parse-events: Do not break up AUX event group Adrian Hunter
2023-05-05 13:02 ` Ian Rogers
2023-05-05 13:45   ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).