提交 3a54aaa0 编写于 作者: S Stephane Eranian 提交者: Arnaldo Carvalho de Melo

perf/x86: Improve sysfs event mapping with event string

This patch extends Jiri's changes to make generic
events mapping visible via sysfs. The patch extends
the mechanism to non-generic events by allowing
the mappings to be hardcoded in strings.

This mechanism will be used by the PEBS-LL patch
later on.
Signed-off-by: NStephane Eranian <eranian@google.com>
Cc: peterz@infradead.org
Cc: ak@linux.intel.com
Cc: acme@redhat.com
Cc: jolsa@redhat.com
Cc: namhyung.kim@lge.com
Link: http://lkml.kernel.org/r/1359040242-8269-3-git-send-email-eranian@google.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
[ fixed up conflict with 2663960c "perf: Make EVENT_ATTR global" ]
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 1a6461b1
...@@ -1316,9 +1316,16 @@ static struct attribute_group x86_pmu_format_group = { ...@@ -1316,9 +1316,16 @@ static struct attribute_group x86_pmu_format_group = {
*/ */
static void __init filter_events(struct attribute **attrs) static void __init filter_events(struct attribute **attrs)
{ {
struct device_attribute *d;
struct perf_pmu_events_attr *pmu_attr;
int i, j; int i, j;
for (i = 0; attrs[i]; i++) { for (i = 0; attrs[i]; i++) {
d = (struct device_attribute *)attrs[i];
pmu_attr = container_of(d, struct perf_pmu_events_attr, attr);
/* str trumps id */
if (pmu_attr->event_str)
continue;
if (x86_pmu.event_map(i)) if (x86_pmu.event_map(i))
continue; continue;
...@@ -1361,17 +1368,14 @@ static ssize_t events_sysfs_show(struct device *dev, struct device_attribute *at ...@@ -1361,17 +1368,14 @@ static ssize_t events_sysfs_show(struct device *dev, struct device_attribute *at
{ {
struct perf_pmu_events_attr *pmu_attr = \ struct perf_pmu_events_attr *pmu_attr = \
container_of(attr, struct perf_pmu_events_attr, attr); container_of(attr, struct perf_pmu_events_attr, attr);
u64 config = x86_pmu.event_map(pmu_attr->id); u64 config = x86_pmu.event_map(pmu_attr->id);
return x86_pmu.events_sysfs_show(page, config);
}
#define EVENT_VAR(_id) event_attr_##_id /* string trumps id */
#define EVENT_PTR(_id) &event_attr_##_id.attr.attr if (pmu_attr->event_str)
return sprintf(page, "%s", pmu_attr->event_str);
#define EVENT_ATTR(_name, _id) \ return x86_pmu.events_sysfs_show(page, config);
PMU_EVENT_ATTR(_name, EVENT_VAR(_id), PERF_COUNT_HW_##_id, \ }
events_sysfs_show)
EVENT_ATTR(cpu-cycles, CPU_CYCLES ); EVENT_ATTR(cpu-cycles, CPU_CYCLES );
EVENT_ATTR(instructions, INSTRUCTIONS ); EVENT_ATTR(instructions, INSTRUCTIONS );
......
...@@ -422,6 +422,23 @@ do { \ ...@@ -422,6 +422,23 @@ do { \
#define ERF_NO_HT_SHARING 1 #define ERF_NO_HT_SHARING 1
#define ERF_HAS_RSP_1 2 #define ERF_HAS_RSP_1 2
#define EVENT_VAR(_id) event_attr_##_id
#define EVENT_PTR(_id) &event_attr_##_id.attr.attr
#define EVENT_ATTR(_name, _id) \
static struct perf_pmu_events_attr EVENT_VAR(_id) = { \
.attr = __ATTR(_name, 0444, events_sysfs_show, NULL), \
.id = PERF_COUNT_HW_##_id, \
.event_str = NULL, \
};
#define EVENT_ATTR_STR(_name, v, str) \
static struct perf_pmu_events_attr event_attr_##v = { \
.attr = __ATTR(_name, 0444, events_sysfs_show, NULL), \
.id = 0, \
.event_str = str, \
};
extern struct x86_pmu x86_pmu __read_mostly; extern struct x86_pmu x86_pmu __read_mostly;
DECLARE_PER_CPU(struct cpu_hw_events, cpu_hw_events); DECLARE_PER_CPU(struct cpu_hw_events, cpu_hw_events);
......
...@@ -809,6 +809,7 @@ do { \ ...@@ -809,6 +809,7 @@ do { \
struct perf_pmu_events_attr { struct perf_pmu_events_attr {
struct device_attribute attr; struct device_attribute attr;
u64 id; u64 id;
const char *event_str;
}; };
#define PMU_EVENT_ATTR(_name, _var, _id, _show) \ #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册