From b2da17ea5434831807bdf102dfd91e1e507f3326 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Tue, 15 Oct 2013 14:52:44 +0000 Subject: [PATCH] Move the PMC handling to the first level interrupt handler where it belongs. Also add the pmc_hook use, to handle callchain tracing. MFC after: 1 week --- sys/powerpc/aim/interrupt.c | 16 ++++++++++++++++ sys/powerpc/aim/trap.c | 14 +------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/sys/powerpc/aim/interrupt.c b/sys/powerpc/aim/interrupt.c index d1e36551458f..4d1c22e26dd3 100644 --- a/sys/powerpc/aim/interrupt.c +++ b/sys/powerpc/aim/interrupt.c @@ -31,6 +31,8 @@ * Interrupts are dispatched to here from locore asm */ +#include "opt_hwpmc_hooks.h" + #include /* RCS ID & Copyright macro defns */ #include @@ -43,6 +45,9 @@ #include #include #include +#ifdef HWPMC_HOOKS +#include +#endif #include #include #include @@ -96,6 +101,17 @@ powerpc_interrupt(struct trapframe *framep) atomic_subtract_int(&td->td_intr_nesting_level, 1); critical_exit(); break; + case EXC_PERF: + critical_enter(); + KASSERT(pmc_intr != NULL, ("Performance exception, but no handler!")); + (*pmc_intr)(PCPU_GET(cpuid), framep); + critical_enter(); +#ifdef HWPMC_HOOKS + if (pmc_hook && (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN)) + pmc_hook(PCPU_GET(curthread), PMC_FN_USER_CALLCHAIN, framep); +#endif + critical_exit(); + break; default: /* Re-enable interrupts if applicable. */ diff --git a/sys/powerpc/aim/trap.c b/sys/powerpc/aim/trap.c index 2edbbfa7e3fe..d31e47b209ff 100644 --- a/sys/powerpc/aim/trap.c +++ b/sys/powerpc/aim/trap.c @@ -34,7 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_hwpmc_hooks.h" #include "opt_kdtrace.h" #include @@ -52,9 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef HWPMC_HOOKS -#include -#endif #include @@ -195,14 +191,6 @@ trap(struct trapframe *frame) CTR3(KTR_TRAP, "trap: %s type=%s (%s)", td->td_name, trapname(type), user ? "user" : "kernel"); -#ifdef HWPMC_HOOKS - if (type == EXC_PERF && (pmc_intr != NULL)) { - (*pmc_intr)(PCPU_GET(cpuid), frame); - if (user) - userret(td, frame); - return; - } -#endif #ifdef KDTRACE_HOOKS /* * A trap can occur while DTrace executes a probe. Before @@ -292,7 +280,7 @@ trap(struct trapframe *frame) case EXC_PGM: /* Identify the trap reason */ if (frame->srr1 & EXC_PGM_TRAP) - sig = SIGTRAP; + sig = SIGTRAP; else if (ppc_instr_emulate(frame) == 0) frame->srr0 += 4; else