diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-03-15 15:09:14 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-03-16 13:06:06 -0400 |
commit | 641cc938815dfd09f8fa1ec72deb814f0938ac33 (patch) | |
tree | 8ced57a6b2d427bd34dcc30d3aebba3e0af45bb3 /arch/x86 | |
parent | 4a3d2d9bfb3b594b6e1f2b7eabfaf4e820a18c0e (diff) |
perf: Adding sysfs group format attribute for pmu device
Adding sysfs group 'format' attribute for pmu device that
contains a syntax description on how to construct raw events.
The event configuration is described in following
struct pefr_event_attr attributes:
config
config1
config2
Each sysfs attribute within the format attribute group,
describes mapping of name and bitfield definition within
one of above attributes.
eg:
"/sys/...<dev>/format/event" contains "config:0-7"
"/sys/...<dev>/format/umask" contains "config:8-15"
"/sys/...<dev>/format/usr" contains "config:16"
the attribute value syntax is:
line: config ':' bits
config: 'config' | 'config1' | 'config2"
bits: bits ',' bit_term | bit_term
bit_term: VALUE '-' VALUE | VALUE
Adding format attribute definitions for x86 cpu pmus.
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/n/tip-vhdk5y2hyype9j63prymty36@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/perf_event.c | 7 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/perf_event.h | 1 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_amd.c | 18 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel.c | 36 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_p6.c | 19 |
5 files changed, 81 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 0a18d16cb58d..453ac9497574 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c | |||
@@ -1314,6 +1314,11 @@ static void __init pmu_check_apic(void) | |||
1314 | pr_info("no hardware sampling interrupt available.\n"); | 1314 | pr_info("no hardware sampling interrupt available.\n"); |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | static struct attribute_group x86_pmu_format_group = { | ||
1318 | .name = "format", | ||
1319 | .attrs = NULL, | ||
1320 | }; | ||
1321 | |||
1317 | static int __init init_hw_perf_events(void) | 1322 | static int __init init_hw_perf_events(void) |
1318 | { | 1323 | { |
1319 | struct x86_pmu_quirk *quirk; | 1324 | struct x86_pmu_quirk *quirk; |
@@ -1388,6 +1393,7 @@ static int __init init_hw_perf_events(void) | |||
1388 | } | 1393 | } |
1389 | 1394 | ||
1390 | x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */ | 1395 | x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */ |
1396 | x86_pmu_format_group.attrs = x86_pmu.format_attrs; | ||
1391 | 1397 | ||
1392 | pr_info("... version: %d\n", x86_pmu.version); | 1398 | pr_info("... version: %d\n", x86_pmu.version); |
1393 | pr_info("... bit width: %d\n", x86_pmu.cntval_bits); | 1399 | pr_info("... bit width: %d\n", x86_pmu.cntval_bits); |
@@ -1668,6 +1674,7 @@ static struct attribute_group x86_pmu_attr_group = { | |||
1668 | 1674 | ||
1669 | static const struct attribute_group *x86_pmu_attr_groups[] = { | 1675 | static const struct attribute_group *x86_pmu_attr_groups[] = { |
1670 | &x86_pmu_attr_group, | 1676 | &x86_pmu_attr_group, |
1677 | &x86_pmu_format_group, | ||
1671 | NULL, | 1678 | NULL, |
1672 | }; | 1679 | }; |
1673 | 1680 | ||
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h index 8484e77c211e..6638aaf54493 100644 --- a/arch/x86/kernel/cpu/perf_event.h +++ b/arch/x86/kernel/cpu/perf_event.h | |||
@@ -339,6 +339,7 @@ struct x86_pmu { | |||
339 | * sysfs attrs | 339 | * sysfs attrs |
340 | */ | 340 | */ |
341 | int attr_rdpmc; | 341 | int attr_rdpmc; |
342 | struct attribute **format_attrs; | ||
342 | 343 | ||
343 | /* | 344 | /* |
344 | * CPU Hotplug hooks | 345 | * CPU Hotplug hooks |
diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c index dd002faff7a6..95e7fe1c5f0b 100644 --- a/arch/x86/kernel/cpu/perf_event_amd.c +++ b/arch/x86/kernel/cpu/perf_event_amd.c | |||
@@ -404,6 +404,21 @@ static void amd_pmu_cpu_dead(int cpu) | |||
404 | } | 404 | } |
405 | } | 405 | } |
406 | 406 | ||
407 | PMU_FORMAT_ATTR(event, "config:0-7,32-35"); | ||
408 | PMU_FORMAT_ATTR(umask, "config:8-15" ); | ||
409 | PMU_FORMAT_ATTR(edge, "config:18" ); | ||
410 | PMU_FORMAT_ATTR(inv, "config:23" ); | ||
411 | PMU_FORMAT_ATTR(cmask, "config:24-31" ); | ||
412 | |||
413 | static struct attribute *amd_format_attr[] = { | ||
414 | &format_attr_event.attr, | ||
415 | &format_attr_umask.attr, | ||
416 | &format_attr_edge.attr, | ||
417 | &format_attr_inv.attr, | ||
418 | &format_attr_cmask.attr, | ||
419 | NULL, | ||
420 | }; | ||
421 | |||
407 | static __initconst const struct x86_pmu amd_pmu = { | 422 | static __initconst const struct x86_pmu amd_pmu = { |
408 | .name = "AMD", | 423 | .name = "AMD", |
409 | .handle_irq = x86_pmu_handle_irq, | 424 | .handle_irq = x86_pmu_handle_irq, |
@@ -426,6 +441,8 @@ static __initconst const struct x86_pmu amd_pmu = { | |||
426 | .get_event_constraints = amd_get_event_constraints, | 441 | .get_event_constraints = amd_get_event_constraints, |
427 | .put_event_constraints = amd_put_event_constraints, | 442 | .put_event_constraints = amd_put_event_constraints, |
428 | 443 | ||
444 | .format_attrs = amd_format_attr, | ||
445 | |||
429 | .cpu_prepare = amd_pmu_cpu_prepare, | 446 | .cpu_prepare = amd_pmu_cpu_prepare, |
430 | .cpu_starting = amd_pmu_cpu_starting, | 447 | .cpu_starting = amd_pmu_cpu_starting, |
431 | .cpu_dead = amd_pmu_cpu_dead, | 448 | .cpu_dead = amd_pmu_cpu_dead, |
@@ -596,6 +613,7 @@ static __initconst const struct x86_pmu amd_pmu_f15h = { | |||
596 | .cpu_dead = amd_pmu_cpu_dead, | 613 | .cpu_dead = amd_pmu_cpu_dead, |
597 | #endif | 614 | #endif |
598 | .cpu_starting = amd_pmu_cpu_starting, | 615 | .cpu_starting = amd_pmu_cpu_starting, |
616 | .format_attrs = amd_format_attr, | ||
599 | }; | 617 | }; |
600 | 618 | ||
601 | __init int amd_pmu_init(void) | 619 | __init int amd_pmu_init(void) |
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c index 6a84e7f28f05..26b3e2fef104 100644 --- a/arch/x86/kernel/cpu/perf_event_intel.c +++ b/arch/x86/kernel/cpu/perf_event_intel.c | |||
@@ -1431,6 +1431,24 @@ static void core_pmu_enable_all(int added) | |||
1431 | } | 1431 | } |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | PMU_FORMAT_ATTR(event, "config:0-7" ); | ||
1435 | PMU_FORMAT_ATTR(umask, "config:8-15" ); | ||
1436 | PMU_FORMAT_ATTR(edge, "config:18" ); | ||
1437 | PMU_FORMAT_ATTR(pc, "config:19" ); | ||
1438 | PMU_FORMAT_ATTR(any, "config:21" ); /* v3 + */ | ||
1439 | PMU_FORMAT_ATTR(inv, "config:23" ); | ||
1440 | PMU_FORMAT_ATTR(cmask, "config:24-31" ); | ||
1441 | |||
1442 | static struct attribute *intel_arch_formats_attr[] = { | ||
1443 | &format_attr_event.attr, | ||
1444 | &format_attr_umask.attr, | ||
1445 | &format_attr_edge.attr, | ||
1446 | &format_attr_pc.attr, | ||
1447 | &format_attr_inv.attr, | ||
1448 | &format_attr_cmask.attr, | ||
1449 | NULL, | ||
1450 | }; | ||
1451 | |||
1434 | static __initconst const struct x86_pmu core_pmu = { | 1452 | static __initconst const struct x86_pmu core_pmu = { |
1435 | .name = "core", | 1453 | .name = "core", |
1436 | .handle_irq = x86_pmu_handle_irq, | 1454 | .handle_irq = x86_pmu_handle_irq, |
@@ -1455,6 +1473,7 @@ static __initconst const struct x86_pmu core_pmu = { | |||
1455 | .put_event_constraints = intel_put_event_constraints, | 1473 | .put_event_constraints = intel_put_event_constraints, |
1456 | .event_constraints = intel_core_event_constraints, | 1474 | .event_constraints = intel_core_event_constraints, |
1457 | .guest_get_msrs = core_guest_get_msrs, | 1475 | .guest_get_msrs = core_guest_get_msrs, |
1476 | .format_attrs = intel_arch_formats_attr, | ||
1458 | }; | 1477 | }; |
1459 | 1478 | ||
1460 | struct intel_shared_regs *allocate_shared_regs(int cpu) | 1479 | struct intel_shared_regs *allocate_shared_regs(int cpu) |
@@ -1553,6 +1572,21 @@ static void intel_pmu_flush_branch_stack(void) | |||
1553 | intel_pmu_lbr_reset(); | 1572 | intel_pmu_lbr_reset(); |
1554 | } | 1573 | } |
1555 | 1574 | ||
1575 | PMU_FORMAT_ATTR(offcore_rsp, "config1:0-63"); | ||
1576 | |||
1577 | static struct attribute *intel_arch3_formats_attr[] = { | ||
1578 | &format_attr_event.attr, | ||
1579 | &format_attr_umask.attr, | ||
1580 | &format_attr_edge.attr, | ||
1581 | &format_attr_pc.attr, | ||
1582 | &format_attr_any.attr, | ||
1583 | &format_attr_inv.attr, | ||
1584 | &format_attr_cmask.attr, | ||
1585 | |||
1586 | &format_attr_offcore_rsp.attr, /* XXX do NHM/WSM + SNB breakout */ | ||
1587 | NULL, | ||
1588 | }; | ||
1589 | |||
1556 | static __initconst const struct x86_pmu intel_pmu = { | 1590 | static __initconst const struct x86_pmu intel_pmu = { |
1557 | .name = "Intel", | 1591 | .name = "Intel", |
1558 | .handle_irq = intel_pmu_handle_irq, | 1592 | .handle_irq = intel_pmu_handle_irq, |
@@ -1576,6 +1610,8 @@ static __initconst const struct x86_pmu intel_pmu = { | |||
1576 | .get_event_constraints = intel_get_event_constraints, | 1610 | .get_event_constraints = intel_get_event_constraints, |
1577 | .put_event_constraints = intel_put_event_constraints, | 1611 | .put_event_constraints = intel_put_event_constraints, |
1578 | 1612 | ||
1613 | .format_attrs = intel_arch3_formats_attr, | ||
1614 | |||
1579 | .cpu_prepare = intel_pmu_cpu_prepare, | 1615 | .cpu_prepare = intel_pmu_cpu_prepare, |
1580 | .cpu_starting = intel_pmu_cpu_starting, | 1616 | .cpu_starting = intel_pmu_cpu_starting, |
1581 | .cpu_dying = intel_pmu_cpu_dying, | 1617 | .cpu_dying = intel_pmu_cpu_dying, |
diff --git a/arch/x86/kernel/cpu/perf_event_p6.c b/arch/x86/kernel/cpu/perf_event_p6.c index c7181befecde..32bcfc7dd230 100644 --- a/arch/x86/kernel/cpu/perf_event_p6.c +++ b/arch/x86/kernel/cpu/perf_event_p6.c | |||
@@ -87,6 +87,23 @@ static void p6_pmu_enable_event(struct perf_event *event) | |||
87 | (void)checking_wrmsrl(hwc->config_base, val); | 87 | (void)checking_wrmsrl(hwc->config_base, val); |
88 | } | 88 | } |
89 | 89 | ||
90 | PMU_FORMAT_ATTR(event, "config:0-7" ); | ||
91 | PMU_FORMAT_ATTR(umask, "config:8-15" ); | ||
92 | PMU_FORMAT_ATTR(edge, "config:18" ); | ||
93 | PMU_FORMAT_ATTR(pc, "config:19" ); | ||
94 | PMU_FORMAT_ATTR(inv, "config:23" ); | ||
95 | PMU_FORMAT_ATTR(cmask, "config:24-31" ); | ||
96 | |||
97 | static struct attribute *intel_p6_formats_attr[] = { | ||
98 | &format_attr_event.attr, | ||
99 | &format_attr_umask.attr, | ||
100 | &format_attr_edge.attr, | ||
101 | &format_attr_pc.attr, | ||
102 | &format_attr_inv.attr, | ||
103 | &format_attr_cmask.attr, | ||
104 | NULL, | ||
105 | }; | ||
106 | |||
90 | static __initconst const struct x86_pmu p6_pmu = { | 107 | static __initconst const struct x86_pmu p6_pmu = { |
91 | .name = "p6", | 108 | .name = "p6", |
92 | .handle_irq = x86_pmu_handle_irq, | 109 | .handle_irq = x86_pmu_handle_irq, |
@@ -115,6 +132,8 @@ static __initconst const struct x86_pmu p6_pmu = { | |||
115 | .cntval_mask = (1ULL << 32) - 1, | 132 | .cntval_mask = (1ULL << 32) - 1, |
116 | .get_event_constraints = x86_get_event_constraints, | 133 | .get_event_constraints = x86_get_event_constraints, |
117 | .event_constraints = p6_event_constraints, | 134 | .event_constraints = p6_event_constraints, |
135 | |||
136 | .format_attrs = intel_p6_formats_attr, | ||
118 | }; | 137 | }; |
119 | 138 | ||
120 | __init int p6_pmu_init(void) | 139 | __init int p6_pmu_init(void) |