]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.20.2/powerpc-fix-performance-monitor-exception.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.20.2 / powerpc-fix-performance-monitor-exception.patch
CommitLineData
1bbce966
GKH
1From stable-bounces@linux.kernel.org Wed Feb 21 21:14:47 2007
2From: Livio Soares <livio@eecg.toronto.edu>
3Date: Thu, 22 Feb 2007 16:13:17 +1100
4Subject: POWERPC: Fix performance monitor exception
5To: stable@kernel.org
6Message-ID: <17885.9837.44671.2038@cargo.ozlabs.ibm.com>
7
8
9From: Livio Soares <livio@eecg.toronto.edu>
10
11To the issue: some point during 2.6.20 development, Paul Mackerras
12introduced the "lazy IRQ disabling" patch (very cool work, BTW).
13In that patch, the performance monitor unit exception was marked as
14"maskable", in the sense that if interrupts were soft-disabled, that
15exception could be ignored. This broke my PowerPC profiling code.
16The symptom that I see is that a varying number of interrupts
17(from 0 to $n$, typically closer to 0) get delivered, when, in
18reality, it should always be very close to $n$.
19
20The issue stems from the way masking is being done. Masking in
21this fashion seems to work well with the decrementer and external
22interrupts, because they are raised again until "really" handled.
23For the PMU, however, this does not apply (at least on my Xserver
24machine with a 970FX processor). If the PMU exception is not handled,
25it will _not_ be re-raised (at least on my machine). The documentation
26states that the PMXE bit in MMCR0 is set to 0 when the PMU exception
27is raised. However, software must re-set the bit to re-enable PMU
28exceptions. If the exception is ignored (as currently) not only is
29that interrupt lost, but because software does not re-set PMXE, the
30PMU registers are "frozen" forever.
31
32[This patch means that performance monitor exceptions are taken and
33handled even if irqs are off, as long as some other interrupt hasn't
34come along and caused interrupts to be hard-disabled. In this sense
35the PMU exception becomes like an NMI. The oprofile code for most
36powerpc processors does nothing that is unsafe in an NMI context, but
37the Cell oprofile code does a spin_lock_irqsave. However, that turns
38out to be OK because Cell doesn't actually use the performance
39monitor exception; performance monitor interrupts come in as a
40regular interrupt on Cell, so will be disabled when irqs are off.
41 -- paulus.]
42
43From: Livio Soares <livio@eecg.toronto.edu>
44Signed-off-by: Paul Mackerras <paulus@samba.org>
45Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
46
47---
48 arch/powerpc/kernel/head_64.S | 2 +-
49 1 file changed, 1 insertion(+), 1 deletion(-)
50
51--- linux-2.6.20.1.orig/arch/powerpc/kernel/head_64.S
52+++ linux-2.6.20.1/arch/powerpc/kernel/head_64.S
53@@ -613,7 +613,7 @@ system_call_pSeries:
54 /*** pSeries interrupt support ***/
55
56 /* moved from 0xf00 */
57- MASKABLE_EXCEPTION_PSERIES(., performance_monitor)
58+ STD_EXCEPTION_PSERIES(., performance_monitor)
59
60 /*
61 * An interrupt came in while soft-disabled; clear EE in SRR1,