Subject: perfmon2: Don't add a message to the Perfmon2 context until the context has been masked From: Kevin Corry If we add the "buffer-full" message first, there is a tiny window where user space may read the message and try to restart the context before we've actually masked the context. This will cause user-space to get an error about trying to restart an active context. Then when the context is eventually masked, it will be left in a masked state without a message to indicate to user-space that it needs to be read from and restarted. Fix this by masking the context first and then adding the "buffer-full" message. Signed-off-by: Kevin Corry Acked-by: Carl Love Signed-off-by: Arnd Bergmann Index: linux-2.6/arch/powerpc/perfmon/perfmon_cell_hw_smpl.c =================================================================== --- linux-2.6.orig/arch/powerpc/perfmon/perfmon_cell_hw_smpl.c +++ linux-2.6/arch/powerpc/perfmon/perfmon_cell_hw_smpl.c @@ -250,14 +250,14 @@ static int handle_full_buffer(struct pfm */ cbe_write_pm(cpu, pm_interval, set->pmcs[CELL_PMC_PM_INTERVAL]); - /* Add a message to the context's message queue. */ - pfm_cell_hw_smpl_add_msg(ctx); - /* Mask monitoring until a pfm_restart() occurs. */ pfm_mask_monitoring(ctx, set); ctx->state = PFM_CTX_MASKED; ctx->flags.can_restart = 1; + /* Add a message to the context's message queue. */ + pfm_cell_hw_smpl_add_msg(ctx); + return -ENOBUFS; }