Merge branches 'work.misc' and 'work.dcache' of git://git.kernel.org/pub/scm/linux...
[sfrench/cifs-2.6.git] / tools / perf / util / metricgroup.c
index 1ddc3d1d0147e7e86dccbf4d522076b602c0c157..a28f9b5cc4ffed9c2a4a1a131e2d258b693284da 100644 (file)
@@ -326,8 +326,8 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter,
                                if (raw)
                                        s = (char *)pe->metric_name;
                                else {
-                                       if (asprintf(&s, "%s\n\t[%s]",
-                                                    pe->metric_name, pe->desc) < 0)
+                                       if (asprintf(&s, "%s\n%*s%s]",
+                                                    pe->metric_name, 8, "[", pe->desc) < 0)
                                                return;
                                }
 
@@ -490,3 +490,25 @@ out:
        metricgroup__free_egroups(&group_list);
        return ret;
 }
+
+bool metricgroup__has_metric(const char *metric)
+{
+       struct pmu_events_map *map = perf_pmu__find_map(NULL);
+       struct pmu_event *pe;
+       int i;
+
+       if (!map)
+               return false;
+
+       for (i = 0; ; i++) {
+               pe = &map->table[i];
+
+               if (!pe->name && !pe->metric_group && !pe->metric_name)
+                       break;
+               if (!pe->metric_expr)
+                       continue;
+               if (match_metric(pe->metric_name, metric))
+                       return true;
+       }
+       return false;
+}