Commit 1a6461b1 authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo

perf/x86: Support CPU specific sysfs events

Add a way for the CPU initialization code to register additional
events, and merge them into the events attribute directory. Used
in the next patch.
Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Signed-off-by: default avatarStephane Eranian <eranian@google.com>
Cc: peterz@infradead.org
Cc: acme@redhat.com
Cc: jolsa@redhat.com
Cc: namhyung.kim@lge.com
Link: http://lkml.kernel.org/r/1359040242-8269-2-git-send-email-eranian@google.com
[ small cleanups ]
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
[ merge_attr returns a **, not just * ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 328ccdac
...@@ -1330,6 +1330,32 @@ static void __init filter_events(struct attribute **attrs) ...@@ -1330,6 +1330,32 @@ static void __init filter_events(struct attribute **attrs)
} }
} }
/* Merge two pointer arrays */
static __init struct attribute **merge_attr(struct attribute **a, struct attribute **b)
{
struct attribute **new;
int j, i;
for (j = 0; a[j]; j++)
;
for (i = 0; b[i]; i++)
j++;
j++;
new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
if (!new)
return NULL;
j = 0;
for (i = 0; a[i]; i++)
new[j++] = a[i];
for (i = 0; b[i]; i++)
new[j++] = b[i];
new[j] = NULL;
return new;
}
static ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr, static ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr,
char *page) char *page)
{ {
...@@ -1469,6 +1495,14 @@ static int __init init_hw_perf_events(void) ...@@ -1469,6 +1495,14 @@ static int __init init_hw_perf_events(void)
else else
filter_events(x86_pmu_events_group.attrs); filter_events(x86_pmu_events_group.attrs);
if (x86_pmu.cpu_events) {
struct attribute **tmp;
tmp = merge_attr(x86_pmu_events_group.attrs, x86_pmu.cpu_events);
if (!WARN_ON(!tmp))
x86_pmu_events_group.attrs = tmp;
}
pr_info("... version: %d\n", x86_pmu.version); pr_info("... version: %d\n", x86_pmu.version);
pr_info("... bit width: %d\n", x86_pmu.cntval_bits); pr_info("... bit width: %d\n", x86_pmu.cntval_bits);
pr_info("... generic registers: %d\n", x86_pmu.num_counters); pr_info("... generic registers: %d\n", x86_pmu.num_counters);
......
...@@ -357,6 +357,7 @@ struct x86_pmu { ...@@ -357,6 +357,7 @@ struct x86_pmu {
struct attribute **format_attrs; struct attribute **format_attrs;
ssize_t (*events_sysfs_show)(char *page, u64 config); ssize_t (*events_sysfs_show)(char *page, u64 config);
struct attribute **cpu_events;
/* /*
* CPU Hotplug hooks * CPU Hotplug hooks
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment