aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-04-29 18:08:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-04-29 18:08:53 -0400
commit40a963502cd44765a0e0d45ff3409051986b5a39 (patch)
treed9894efb7db009b23a91b22adbde4105fe80899b /arch
parentfcc4dc715113999c6c7b5d3087fade3ee8d0f6eb (diff)
parent2bce5daca28346f19c190dbdb5542c9fe3e8c6e6 (diff)
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: perf, x86, nmi: Move LVT un-masking into irq handlers perf events, x86: Work around the Nehalem AAJ80 erratum perf, x86: Fix BTS condition ftrace: Build without frame pointers on Microblaze
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/cpu/perf_event.c16
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c29
-rw-r--r--arch/x86/kernel/cpu/perf_event_p4.c17
3 files changed, 52 insertions, 10 deletions
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 632e5dc9c9c0..e638689279d3 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -613,8 +613,8 @@ static int x86_setup_perfctr(struct perf_event *event)
613 /* 613 /*
614 * Branch tracing: 614 * Branch tracing:
615 */ 615 */
616 if ((attr->config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS) && 616 if (attr->config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS &&
617 (hwc->sample_period == 1)) { 617 !attr->freq && hwc->sample_period == 1) {
618 /* BTS is not supported by this architecture. */ 618 /* BTS is not supported by this architecture. */
619 if (!x86_pmu.bts_active) 619 if (!x86_pmu.bts_active)
620 return -EOPNOTSUPP; 620 return -EOPNOTSUPP;
@@ -1288,6 +1288,16 @@ static int x86_pmu_handle_irq(struct pt_regs *regs)
1288 1288
1289 cpuc = &__get_cpu_var(cpu_hw_events); 1289 cpuc = &__get_cpu_var(cpu_hw_events);
1290 1290
1291 /*
1292 * Some chipsets need to unmask the LVTPC in a particular spot
1293 * inside the nmi handler. As a result, the unmasking was pushed
1294 * into all the nmi handlers.
1295 *
1296 * This generic handler doesn't seem to have any issues where the
1297 * unmasking occurs so it was left at the top.
1298 */
1299 apic_write(APIC_LVTPC, APIC_DM_NMI);
1300
1291 for (idx = 0; idx < x86_pmu.num_counters; idx++) { 1301 for (idx = 0; idx < x86_pmu.num_counters; idx++) {
1292 if (!test_bit(idx, cpuc->active_mask)) { 1302 if (!test_bit(idx, cpuc->active_mask)) {
1293 /* 1303 /*
@@ -1374,8 +1384,6 @@ perf_event_nmi_handler(struct notifier_block *self,
1374 return NOTIFY_DONE; 1384 return NOTIFY_DONE;
1375 } 1385 }
1376 1386
1377 apic_write(APIC_LVTPC, APIC_DM_NMI);
1378
1379 handled = x86_pmu.handle_irq(args->regs); 1387 handled = x86_pmu.handle_irq(args->regs);
1380 if (!handled) 1388 if (!handled)
1381 return NOTIFY_DONE; 1389 return NOTIFY_DONE;
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 43fa20b13817..e61539b07d2c 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -25,7 +25,7 @@ struct intel_percore {
25/* 25/*
26 * Intel PerfMon, used on Core and later. 26 * Intel PerfMon, used on Core and later.
27 */ 27 */
28static const u64 intel_perfmon_event_map[] = 28static u64 intel_perfmon_event_map[PERF_COUNT_HW_MAX] __read_mostly =
29{ 29{
30 [PERF_COUNT_HW_CPU_CYCLES] = 0x003c, 30 [PERF_COUNT_HW_CPU_CYCLES] = 0x003c,
31 [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, 31 [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
@@ -933,6 +933,16 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
933 933
934 cpuc = &__get_cpu_var(cpu_hw_events); 934 cpuc = &__get_cpu_var(cpu_hw_events);
935 935
936 /*
937 * Some chipsets need to unmask the LVTPC in a particular spot
938 * inside the nmi handler. As a result, the unmasking was pushed
939 * into all the nmi handlers.
940 *
941 * This handler doesn't seem to have any issues with the unmasking
942 * so it was left at the top.
943 */
944 apic_write(APIC_LVTPC, APIC_DM_NMI);
945
936 intel_pmu_disable_all(); 946 intel_pmu_disable_all();
937 handled = intel_pmu_drain_bts_buffer(); 947 handled = intel_pmu_drain_bts_buffer();
938 status = intel_pmu_get_status(); 948 status = intel_pmu_get_status();
@@ -998,6 +1008,9 @@ intel_bts_constraints(struct perf_event *event)
998 struct hw_perf_event *hwc = &event->hw; 1008 struct hw_perf_event *hwc = &event->hw;
999 unsigned int hw_event, bts_event; 1009 unsigned int hw_event, bts_event;
1000 1010
1011 if (event->attr.freq)
1012 return NULL;
1013
1001 hw_event = hwc->config & INTEL_ARCH_EVENT_MASK; 1014 hw_event = hwc->config & INTEL_ARCH_EVENT_MASK;
1002 bts_event = x86_pmu.event_map(PERF_COUNT_HW_BRANCH_INSTRUCTIONS); 1015 bts_event = x86_pmu.event_map(PERF_COUNT_HW_BRANCH_INSTRUCTIONS);
1003 1016
@@ -1305,7 +1318,7 @@ static void intel_clovertown_quirks(void)
1305 * AJ106 could possibly be worked around by not allowing LBR 1318 * AJ106 could possibly be worked around by not allowing LBR
1306 * usage from PEBS, including the fixup. 1319 * usage from PEBS, including the fixup.
1307 * AJ68 could possibly be worked around by always programming 1320 * AJ68 could possibly be worked around by always programming
1308 * a pebs_event_reset[0] value and coping with the lost events. 1321 * a pebs_event_reset[0] value and coping with the lost events.
1309 * 1322 *
1310 * But taken together it might just make sense to not enable PEBS on 1323 * But taken together it might just make sense to not enable PEBS on
1311 * these chips. 1324 * these chips.
@@ -1409,6 +1422,18 @@ static __init int intel_pmu_init(void)
1409 x86_pmu.percore_constraints = intel_nehalem_percore_constraints; 1422 x86_pmu.percore_constraints = intel_nehalem_percore_constraints;
1410 x86_pmu.enable_all = intel_pmu_nhm_enable_all; 1423 x86_pmu.enable_all = intel_pmu_nhm_enable_all;
1411 x86_pmu.extra_regs = intel_nehalem_extra_regs; 1424 x86_pmu.extra_regs = intel_nehalem_extra_regs;
1425
1426 if (ebx & 0x40) {
1427 /*
1428 * Erratum AAJ80 detected, we work it around by using
1429 * the BR_MISP_EXEC.ANY event. This will over-count
1430 * branch-misses, but it's still much better than the
1431 * architectural event which is often completely bogus:
1432 */
1433 intel_perfmon_event_map[PERF_COUNT_HW_BRANCH_MISSES] = 0x7f89;
1434
1435 pr_cont("erratum AAJ80 worked around, ");
1436 }
1412 pr_cont("Nehalem events, "); 1437 pr_cont("Nehalem events, ");
1413 break; 1438 break;
1414 1439
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index d1f77e2934a1..e93fcd55fae1 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -950,11 +950,20 @@ static int p4_pmu_handle_irq(struct pt_regs *regs)
950 x86_pmu_stop(event, 0); 950 x86_pmu_stop(event, 0);
951 } 951 }
952 952
953 if (handled) { 953 if (handled)
954 /* p4 quirk: unmask it again */
955 apic_write(APIC_LVTPC, apic_read(APIC_LVTPC) & ~APIC_LVT_MASKED);
956 inc_irq_stat(apic_perf_irqs); 954 inc_irq_stat(apic_perf_irqs);
957 } 955
956 /*
957 * When dealing with the unmasking of the LVTPC on P4 perf hw, it has
958 * been observed that the OVF bit flag has to be cleared first _before_
959 * the LVTPC can be unmasked.
960 *
961 * The reason is the NMI line will continue to be asserted while the OVF
962 * bit is set. This causes a second NMI to generate if the LVTPC is
963 * unmasked before the OVF bit is cleared, leading to unknown NMI
964 * messages.
965 */
966 apic_write(APIC_LVTPC, APIC_DM_NMI);
958 967
959 return handled; 968 return handled;
960} 969}