Subject: Lock Perfmon context before calling hardware-sampling handler From: Kevin Corry In handle_trace_buffer_interrupts(), we need to lock the context before calling the hardware-sampling handler to prevent another CPU from operating on the context. This has to be done here, instead of in the handler itself, because pfm_cell_disable_counters(), which also calls the handler, is always called with the context already locked. Signed-off-by: Kevin Corry Signed-off-by: Carl Love Signed-off-by: Arnd Bergmann Index: linux-2.6/arch/powerpc/perfmon/perfmon_cell.c =================================================================== --- linux-2.6.orig/arch/powerpc/perfmon/perfmon_cell.c +++ linux-2.6/arch/powerpc/perfmon/perfmon_cell.c @@ -479,8 +479,11 @@ static void handle_trace_buffer_interrup struct pfm_smpl_fmt *smpl_fmt; if (pm_status & CBE_PM_TRACE_BUFFER_FULL_INTR) { - /* The trace-buffer is full. Get the - * sampling-buffer address and call the handler. + /* The trace-buffer is full. Get the sampling-buffer address + * and call the handler. Need to lock the context here instead + * of in the handler, because the handler can also be called + * by the pfm_cell_disable_counters() routine, which is called + * with the context already locked. */ smpl_fmt = ctx->smpl_fmt; @@ -488,8 +491,10 @@ static void handle_trace_buffer_interrup !strcmp(smpl_fmt->fmt_name, PFM_CELL_HW_SMPL_NAME)) { ctx->ovfl_arg.ovfl_pmd = PFM_CELL_HW_SMPL_OVFL_PMD; ctx->ovfl_arg.active_set = ctx->active_set->id; + spin_lock(&ctx->lock); smpl_fmt->fmt_handler(ctx->smpl_addr, &ctx->ovfl_arg, iip, 0, regs); + spin_unlock(&ctx->lock); } }