diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2011-07-21 12:06:25 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-07-21 14:41:54 -0400 |
commit | f53173e47dee5f7514d264796bec58d43ed0f67f (patch) | |
tree | 43ff4034a1abffc334927ce9ed7893900a3b3328 | |
parent | baf040a0d1ac6319725c0fe400503683ac016580 (diff) |
x86, perf: P4 PMU - Fix typos in comments and style cleanup
This patch:
- fixes typos in comments and clarifies the text
- renames obscure p4_event_alias::original and ::alter members to
::original and ::alternative as appropriate
- drops parenthesis from the return of p4_get_alias_event()
No functional changes.
Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Link: http://lkml.kernel.org/r/20110721160625.GX7492@sun
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/include/asm/perf_event_p4.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_p4.c | 66 |
2 files changed, 31 insertions, 37 deletions
diff --git a/arch/x86/include/asm/perf_event_p4.h b/arch/x86/include/asm/perf_event_p4.h index 4d86c86178f2..4f7e67e2345e 100644 --- a/arch/x86/include/asm/perf_event_p4.h +++ b/arch/x86/include/asm/perf_event_p4.h | |||
@@ -133,7 +133,7 @@ | |||
133 | 133 | ||
134 | /* | 134 | /* |
135 | * In case of event aliasing we need to preserve some | 135 | * In case of event aliasing we need to preserve some |
136 | * caller bits otherwise the mapping won't be complete. | 136 | * caller bits, otherwise the mapping won't be complete. |
137 | */ | 137 | */ |
138 | #define P4_CONFIG_EVENT_ALIAS_MASK \ | 138 | #define P4_CONFIG_EVENT_ALIAS_MASK \ |
139 | (p4_config_pack_escr(P4_CONFIG_MASK_ESCR) | \ | 139 | (p4_config_pack_escr(P4_CONFIG_MASK_ESCR) | \ |
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c index 8b7a0c306784..7809d2bcb209 100644 --- a/arch/x86/kernel/cpu/perf_event_p4.c +++ b/arch/x86/kernel/cpu/perf_event_p4.c | |||
@@ -571,35 +571,34 @@ static __initconst const u64 p4_hw_cache_event_ids | |||
571 | }; | 571 | }; |
572 | 572 | ||
573 | /* | 573 | /* |
574 | * Because of Netburst being quite restricted in now | 574 | * Because of Netburst being quite restricted in how many |
575 | * many same events can run simultaneously, we use | 575 | * identical events may run simultaneously, we introduce event aliases, |
576 | * event aliases, ie different events which have the | 576 | * ie the different events which have the same functionality but |
577 | * same functionallity but use non-intersected resources | 577 | * utilize non-intersected resources (ESCR/CCCR/counter registers). |
578 | * (ESCR/CCCR/couter registers). This allow us to run | ||
579 | * two or more semi-same events together. It is done | ||
580 | * transparently to a user space. | ||
581 | * | 578 | * |
582 | * Never set any cusom internal bits such as P4_CONFIG_HT, | 579 | * This allow us to relax restrictions a bit and run two or more |
583 | * P4_CONFIG_ALIASABLE or bits for P4_PEBS_METRIC, they are | 580 | * identical events together. |
584 | * either up-to-dated automatically either not appliable | ||
585 | * at all. | ||
586 | * | 581 | * |
587 | * And be really carefull choosing aliases! | 582 | * Never set any custom internal bits such as P4_CONFIG_HT, |
583 | * P4_CONFIG_ALIASABLE or bits for P4_PEBS_METRIC, they are | ||
584 | * either up to date automatically or not applicable at all. | ||
588 | */ | 585 | */ |
589 | struct p4_event_alias { | 586 | struct p4_event_alias { |
590 | u64 orig; | 587 | u64 original; |
591 | u64 alter; | 588 | u64 alternative; |
592 | } p4_event_aliases[] = { | 589 | } p4_event_aliases[] = { |
593 | { | 590 | { |
594 | /* | 591 | /* |
595 | * Non-halted cycles can be substituted with | 592 | * Non-halted cycles can be substituted with non-sleeping cycles (see |
596 | * non-sleeping cycles (see Intel SDM Vol3b for | 593 | * Intel SDM Vol3b for details). We need this alias to be able |
597 | * details). | 594 | * to run nmi-watchdog and 'perf top' (or any other user space tool |
595 | * which is interested in running PERF_COUNT_HW_CPU_CYCLES) | ||
596 | * simultaneously. | ||
598 | */ | 597 | */ |
599 | .orig = | 598 | .original = |
600 | p4_config_pack_escr(P4_ESCR_EVENT(P4_EVENT_GLOBAL_POWER_EVENTS) | | 599 | p4_config_pack_escr(P4_ESCR_EVENT(P4_EVENT_GLOBAL_POWER_EVENTS) | |
601 | P4_ESCR_EMASK_BIT(P4_EVENT_GLOBAL_POWER_EVENTS, RUNNING)), | 600 | P4_ESCR_EMASK_BIT(P4_EVENT_GLOBAL_POWER_EVENTS, RUNNING)), |
602 | .alter = | 601 | .alternative = |
603 | p4_config_pack_escr(P4_ESCR_EVENT(P4_EVENT_EXECUTION_EVENT) | | 602 | p4_config_pack_escr(P4_ESCR_EVENT(P4_EVENT_EXECUTION_EVENT) | |
604 | P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, NBOGUS0)| | 603 | P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, NBOGUS0)| |
605 | P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, NBOGUS1)| | 604 | P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, NBOGUS1)| |
@@ -620,25 +619,21 @@ static u64 p4_get_alias_event(u64 config) | |||
620 | int i; | 619 | int i; |
621 | 620 | ||
622 | /* | 621 | /* |
623 | * Probably we're lucky and don't have to do | 622 | * Only event with special mark is allowed, |
624 | * matching over all config bits. | 623 | * we're to be sure it didn't come as malformed |
624 | * RAW event. | ||
625 | */ | 625 | */ |
626 | if (!(config & P4_CONFIG_ALIASABLE)) | 626 | if (!(config & P4_CONFIG_ALIASABLE)) |
627 | return 0; | 627 | return 0; |
628 | 628 | ||
629 | config_match = config & P4_CONFIG_EVENT_ALIAS_MASK; | 629 | config_match = config & P4_CONFIG_EVENT_ALIAS_MASK; |
630 | 630 | ||
631 | /* | ||
632 | * If an event was previously swapped to the alter config | ||
633 | * we should swap it back otherwise contnention on registers | ||
634 | * will return back. | ||
635 | */ | ||
636 | for (i = 0; i < ARRAY_SIZE(p4_event_aliases); i++) { | 631 | for (i = 0; i < ARRAY_SIZE(p4_event_aliases); i++) { |
637 | if (config_match == p4_event_aliases[i].orig) { | 632 | if (config_match == p4_event_aliases[i].original) { |
638 | config_match = p4_event_aliases[i].alter; | 633 | config_match = p4_event_aliases[i].alternative; |
639 | break; | 634 | break; |
640 | } else if (config_match == p4_event_aliases[i].alter) { | 635 | } else if (config_match == p4_event_aliases[i].alternative) { |
641 | config_match = p4_event_aliases[i].orig; | 636 | config_match = p4_event_aliases[i].original; |
642 | break; | 637 | break; |
643 | } | 638 | } |
644 | } | 639 | } |
@@ -646,8 +641,7 @@ static u64 p4_get_alias_event(u64 config) | |||
646 | if (i >= ARRAY_SIZE(p4_event_aliases)) | 641 | if (i >= ARRAY_SIZE(p4_event_aliases)) |
647 | return 0; | 642 | return 0; |
648 | 643 | ||
649 | return config_match | | 644 | return config_match | (config & P4_CONFIG_EVENT_ALIAS_IMMUTABLE_BITS); |
650 | (config & P4_CONFIG_EVENT_ALIAS_IMMUTABLE_BITS); | ||
651 | } | 645 | } |
652 | 646 | ||
653 | static u64 p4_general_events[PERF_COUNT_HW_MAX] = { | 647 | static u64 p4_general_events[PERF_COUNT_HW_MAX] = { |
@@ -1229,9 +1223,9 @@ static int p4_pmu_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign | |||
1229 | 1223 | ||
1230 | again: | 1224 | again: |
1231 | /* | 1225 | /* |
1232 | * Aliases are swappable so we may hit circular | 1226 | * It's possible to hit a circular lock |
1233 | * lock if both original config and alias need | 1227 | * between original and alternative events |
1234 | * resources (MSR registers) which already busy. | 1228 | * if both are scheduled already. |
1235 | */ | 1229 | */ |
1236 | if (pass > 2) | 1230 | if (pass > 2) |
1237 | goto done; | 1231 | goto done; |
@@ -1251,7 +1245,7 @@ again: | |||
1251 | cntr_idx = p4_next_cntr(thread, used_mask, bind); | 1245 | cntr_idx = p4_next_cntr(thread, used_mask, bind); |
1252 | if (cntr_idx == -1 || test_bit(escr_idx, escr_mask)) { | 1246 | if (cntr_idx == -1 || test_bit(escr_idx, escr_mask)) { |
1253 | /* | 1247 | /* |
1254 | * Probably an event alias is still available. | 1248 | * Check whether an event alias is still available. |
1255 | */ | 1249 | */ |
1256 | config_alias = p4_get_alias_event(hwc->config); | 1250 | config_alias = p4_get_alias_event(hwc->config); |
1257 | if (!config_alias) | 1251 | if (!config_alias) |