Re: [PATCH 1/3] perf_event: fix race in perf_swevent_get_recursion_context()

From: Xiao Guangrong
Date: Tue Jan 19 2010 - 04:11:54 EST




Frederic Weisbecker wrote:

>
> I still don't understand the problem.
>
> It's not like a fight between different cpus, it's a local per cpu
> fight.
>
> NMIs can't nest other NMIs but hardirq can nest another hardirqs,
> we don't care much about these though.
> So let's imagine the following sequence, a fight between nested
> hardirqs:
>
> cpuctx->recursion[irq] initially = 0
>
> Interrupt (level 0):
>
> if (cpuctx->recursion[rctx]) {
> put_cpu_var(perf_cpu_context);
> return -1;
> }
>
> Interrupt (level 1):
>
>
> cpuctx->recursion[rctx]++; // = 1
>
> ...
> do something
> ...
> cpuctx->recursion[rctx]--; // = 0
>
> End Interrupt (level 1)
>
> cpuctx->recursion[rctx]++; // = 1
>
> ...
> do something
> ...
> cpuctx->recursion[rctx]--; // = 0
>
> End interrupt (level 0)
>
> Another sequence could be Interrupt level 0 has
> already incremented recursion and we are interrupted by
> irq level 1 which then won't be able to get the recursion
> context. But that's not a big deal I think.
>

Thanks Frederic, i forget this feature of nesting of hard-irq :-(

Sorry for disturb you all

- Xiao
--
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/