Skip to content

Commit a36fadb

Browse files
John Garryacmel
authored andcommitted
perf metricgroup: Support printing metric groups for system PMUs
Currently printing metricgroups for core- or uncore-based events matched by CPUID is supported. Extend this for system events. Signed-off-by: John Garry <john.garry@huawei.com> Acked-by: Kajol Jain <kjain@linux.ibm.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Joakim Zhang <qiangqing.zhang@nxp.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Kim Phillips <kim.phillips@amd.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Shaokun Zhang <zhangshaokun@hisilicon.com> Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Cc: linuxarm@huawei.com Link: http://lore.kernel.org/lkml/1607080216-36968-9-git-send-email-john.garry@huawei.com [ Reorder 'struct metricgroup_print_sys_idata' field to avoid alignment holes ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent f6fe1e4 commit a36fadb

File tree

1 file changed

+60
-4
lines changed

1 file changed

+60
-4
lines changed

tools/perf/util/metricgroup.c

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,49 @@ static int metricgroup__print_pmu_event(struct pmu_event *pe,
559559
return 0;
560560
}
561561

562+
struct metricgroup_print_sys_idata {
563+
struct strlist *metriclist;
564+
char *filter;
565+
struct rblist *groups;
566+
bool metricgroups;
567+
bool raw;
568+
bool details;
569+
};
570+
571+
typedef int (*metricgroup_sys_event_iter_fn)(struct pmu_event *pe, void *);
572+
573+
struct metricgroup_iter_data {
574+
metricgroup_sys_event_iter_fn fn;
575+
void *data;
576+
};
577+
578+
static int metricgroup__sys_event_iter(struct pmu_event *pe, void *data)
579+
{
580+
struct metricgroup_iter_data *d = data;
581+
struct perf_pmu *pmu = NULL;
582+
583+
if (!pe->metric_expr || !pe->compat)
584+
return 0;
585+
586+
while ((pmu = perf_pmu__scan(pmu))) {
587+
588+
if (!pmu->id || strcmp(pmu->id, pe->compat))
589+
continue;
590+
591+
return d->fn(pe, d->data);
592+
}
593+
594+
return 0;
595+
}
596+
597+
static int metricgroup__print_sys_event_iter(struct pmu_event *pe, void *data)
598+
{
599+
struct metricgroup_print_sys_idata *d = data;
600+
601+
return metricgroup__print_pmu_event(pe, d->metricgroups, d->filter, d->raw,
602+
d->details, d->groups, d->metriclist);
603+
}
604+
562605
void metricgroup__print(bool metrics, bool metricgroups, char *filter,
563606
bool raw, bool details)
564607
{
@@ -569,9 +612,6 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter,
569612
struct rb_node *node, *next;
570613
struct strlist *metriclist = NULL;
571614

572-
if (!map)
573-
return;
574-
575615
if (!metricgroups) {
576616
metriclist = strlist__new(NULL, NULL);
577617
if (!metriclist)
@@ -582,7 +622,7 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter,
582622
groups.node_new = mep_new;
583623
groups.node_cmp = mep_cmp;
584624
groups.node_delete = mep_delete;
585-
for (i = 0; ; i++) {
625+
for (i = 0; map; i++) {
586626
pe = &map->table[i];
587627

588628
if (!pe->name && !pe->metric_group && !pe->metric_name)
@@ -595,6 +635,22 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter,
595635
return;
596636
}
597637

638+
{
639+
struct metricgroup_iter_data data = {
640+
.fn = metricgroup__print_sys_event_iter,
641+
.data = (void *) &(struct metricgroup_print_sys_idata){
642+
.metriclist = metriclist,
643+
.metricgroups = metricgroups,
644+
.filter = filter,
645+
.raw = raw,
646+
.details = details,
647+
.groups = &groups,
648+
},
649+
};
650+
651+
pmu_for_each_sys_event(metricgroup__sys_event_iter, &data);
652+
}
653+
598654
if (!filter || !rblist__empty(&groups)) {
599655
if (metricgroups && !raw)
600656
printf("\nMetric Groups:\n\n");

0 commit comments

Comments
 (0)