Re: [PATCH,RFC] perf: panic due to inclied cpu context task_ctxvalue

From: Oleg Nesterov
Date: Fri Mar 25 2011 - 15:20:16 EST


On 03/24, Jiri Olsa wrote:
>
> - close is called on event on CPU 0:
> - the task is scheduled on CPU 0
> - __perf_event_task_sched_in is called
> - cpuctx->task_ctx is set
> - perf_sched_events jump label is decremented and == 0
> - __perf_event_task_sched_out is not called
> - cpuctx->task_ctx on CPU 0 stays set

I think you are right.

And this is already wrong afaics, even if we add the workaround into
free_ctx/etc.

For example, suppose that we attach another PERF_ATTACH_TASK counter
to this task later. perf_sched_events will be incremented again, but
perf_install_in_context() should hang retrying until this task runs
again, ->is_active == T.

Or, even if sys_perf_event_open() succeeds the next
perf_event_context_sched_in() will do nothing because it checks
cpuctx->task_ctx != ctx (unless another task has a counter and
schedules in on that CPU).

This should be fixed somehow, but so far I have no ideas.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/