Re: [PATCH] kmemcheck: SMP support

From: Vegard Nossum
Date: Fri May 23 2008 - 13:11:16 EST


On Fri, May 23, 2008 at 6:09 PM, Johannes Weiner <hannes@xxxxxxxxxxxx> wrote:
> Hi Vegard,
>
> Vegard Nossum <vegard.nossum@xxxxxxxxx> writes:
>
>> +static void
>> +resume(void)
>> +{
>> +#ifdef CONFIG_SMP
>> + int cpus;
>> +
>> + cpus = num_online_cpus() - 1;
>> +
>> + atomic_set(&nmi_resume, 1);
>> +
>> + while (atomic_read(&finished) != cpus)
>> + cpu_relax();
>> +#endif
>> +}
>
> How about merging finished and started into one? I.e. `paused'.
>
> The notifiers increases `paused' before the waiting-loop and decreases
> it again afterwards.
>
> pause_allbutself() sends the IPIs and waits until `paused' reached the
> number of CPUS.
>
> resume() justs waits until `paused' reaches zero.
>
> Would this work? Will the NMI handler finish even when the CPU is
> removed while the handler runs?

Yup, that works perfectly. No CPU will be removed or added, since the
IPI is broadcast to all CPUs and the only CPU running anything besides
the NMI handler itself is waiting for the other CPUs... (At least I
think this is the case. It won't change the way the code currently
works I think...)

Thanks for the tip! :-)

Vegard

--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
--
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/