aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_rapl.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
index 673f930c700f..6e434f8e5fc8 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
@@ -103,6 +103,13 @@ static struct kobj_attribute format_attr_##_var = \
103 103
104#define RAPL_CNTR_WIDTH 32 /* 32-bit rapl counters */ 104#define RAPL_CNTR_WIDTH 32 /* 32-bit rapl counters */
105 105
106#define RAPL_EVENT_ATTR_STR(_name, v, str) \
107static struct perf_pmu_events_attr event_attr_##v = { \
108 .attr = __ATTR(_name, 0444, rapl_sysfs_show, NULL), \
109 .id = 0, \
110 .event_str = str, \
111};
112
106struct rapl_pmu { 113struct rapl_pmu {
107 spinlock_t lock; 114 spinlock_t lock;
108 int hw_unit; /* 1/2^hw_unit Joule */ 115 int hw_unit; /* 1/2^hw_unit Joule */
@@ -379,23 +386,36 @@ static struct attribute_group rapl_pmu_attr_group = {
379 .attrs = rapl_pmu_attrs, 386 .attrs = rapl_pmu_attrs,
380}; 387};
381 388
382EVENT_ATTR_STR(energy-cores, rapl_cores, "event=0x01"); 389static ssize_t rapl_sysfs_show(struct device *dev,
383EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=0x02"); 390 struct device_attribute *attr,
384EVENT_ATTR_STR(energy-ram , rapl_ram, "event=0x03"); 391 char *page)
385EVENT_ATTR_STR(energy-gpu , rapl_gpu, "event=0x04"); 392{
393 struct perf_pmu_events_attr *pmu_attr = \
394 container_of(attr, struct perf_pmu_events_attr, attr);
395
396 if (pmu_attr->event_str)
397 return sprintf(page, "%s", pmu_attr->event_str);
398
399 return 0;
400}
401
402RAPL_EVENT_ATTR_STR(energy-cores, rapl_cores, "event=0x01");
403RAPL_EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=0x02");
404RAPL_EVENT_ATTR_STR(energy-ram , rapl_ram, "event=0x03");
405RAPL_EVENT_ATTR_STR(energy-gpu , rapl_gpu, "event=0x04");
386 406
387EVENT_ATTR_STR(energy-cores.unit, rapl_cores_unit, "Joules"); 407RAPL_EVENT_ATTR_STR(energy-cores.unit, rapl_cores_unit, "Joules");
388EVENT_ATTR_STR(energy-pkg.unit , rapl_pkg_unit, "Joules"); 408RAPL_EVENT_ATTR_STR(energy-pkg.unit , rapl_pkg_unit, "Joules");
389EVENT_ATTR_STR(energy-ram.unit , rapl_ram_unit, "Joules"); 409RAPL_EVENT_ATTR_STR(energy-ram.unit , rapl_ram_unit, "Joules");
390EVENT_ATTR_STR(energy-gpu.unit , rapl_gpu_unit, "Joules"); 410RAPL_EVENT_ATTR_STR(energy-gpu.unit , rapl_gpu_unit, "Joules");
391 411
392/* 412/*
393 * we compute in 0.23 nJ increments regardless of MSR 413 * we compute in 0.23 nJ increments regardless of MSR
394 */ 414 */
395EVENT_ATTR_STR(energy-cores.scale, rapl_cores_scale, "2.3283064365386962890625e-10"); 415RAPL_EVENT_ATTR_STR(energy-cores.scale, rapl_cores_scale, "2.3283064365386962890625e-10");
396EVENT_ATTR_STR(energy-pkg.scale, rapl_pkg_scale, "2.3283064365386962890625e-10"); 416RAPL_EVENT_ATTR_STR(energy-pkg.scale, rapl_pkg_scale, "2.3283064365386962890625e-10");
397EVENT_ATTR_STR(energy-ram.scale, rapl_ram_scale, "2.3283064365386962890625e-10"); 417RAPL_EVENT_ATTR_STR(energy-ram.scale, rapl_ram_scale, "2.3283064365386962890625e-10");
398EVENT_ATTR_STR(energy-gpu.scale, rapl_gpu_scale, "2.3283064365386962890625e-10"); 418RAPL_EVENT_ATTR_STR(energy-gpu.scale, rapl_gpu_scale, "2.3283064365386962890625e-10");
399 419
400static struct attribute *rapl_events_srv_attr[] = { 420static struct attribute *rapl_events_srv_attr[] = {
401 EVENT_PTR(rapl_cores), 421 EVENT_PTR(rapl_cores),