performance monitor exceptions

Werner Almesberger wa at
Tue Feb 12 09:37:30 EST 2002


I'm banging my head at a problem with exceptions. What I want to
do is to get the performance monitor to give me exceptions at
roughly 1 kHz, to drive the kernel profiler. The problem is that
my changes usually kill the system within a few minutes :-(

I'm quite new to the PPC, so I'll include a bit more details, in
case I made some trivial mistake. My kernel is 2.4.17, my CPU is a

First of all, I changed the vector to:

        . = 0xf00
        b       PerformanceMonitor

Then, I added a tiny little handler that does nothing but re-enable
the PE exception. For getting a register, I mimicked EXCEPTION_PROLOG:

        // 955 is SIAR
        mtspr   955,r20
        mfspr   r20,SPRN_MMCR0
        oris    r20,r20,MMCR0_PMXE at h
        mtspr   SPRN_MMCR0,r20
        mfspr   r20,955

And then I added of course a bit of code to enable all this:

int __init setup_perf_mon(void)
        unsigned long flags;

        /* ca. 3 kHz */
        mtspr(SPRN_MMCR0,(mfspr(SPRN_MMCR0) & ~MMCR0_TBSEL_MASK) |
        return 0;

It seems to work (I had a handler there that does something a little
more useful), but when I start kernel builds, I get a dead system
(rebooted by hardware watchdog) within a few minutes.

Instead of SIAR, I also tried SPRG0 and SPRG1, but got exactly the
same behaviour. Time to crash varies from one to ten minutes. The
time increases proportionally if I use TLB[19] (~200 Hz) instead.

Any ideas of what I could be trampling over (or be trampled over
by) ? This code seems rather bullet-proof to me, and I don't think
anything else is using SIAR, or could change it while I'm using it.

- Werner

 / Werner Almesberger, Lausanne, CH                    wa at /

** Sent via the linuxppc-dev mail list. See

More information about the Linuxppc-dev mailing list