From: Will Deacon on
Hi Jason,

> Here is the revised patch, which is going into the kgdb-fixes branch.
>
> Thanks,
> Jason.
>
> --
> From: Jason Wessel <jason.wessel(a)windriver.com>
> Subject: [PATCH] kgdb: Use atomic operators which use barriers
>
> The cpu_relax() does not mandate that there is an smp memory barrier.
> As a result on the arm smp architecture the kernel debugger can hang
> on entry from time to time, as shown by the kgdb regression tests.
>
> The solution is simply to use the atomic operators which include a
> proper smp memory barrier, instead of using atomic_set().
>
> Tested-by: Will Deacon <will.deacon(a)arm.com>
> Signed-off-by: Jason Wessel <jason.wessel(a)windriver.com>
> ---
> kernel/kgdb.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> --- a/kernel/kgdb.c
> +++ b/kernel/kgdb.c
> @@ -1379,8 +1379,7 @@ acquirelock:
> * Make sure the above info reaches the primary CPU before
> * our cpu_in_kgdb[] flag setting does:
> */
> - smp_wmb();
> - atomic_set(&cpu_in_kgdb[cpu], 1);
> + atomic_inc(&cpu_in_kgdb[cpu]);

As Dmitry pointed out here:

http://lkml.org/lkml/2010/4/8/214

This bit of code looks broken, especially since the comment has been left
alone by the patch. I think commit ae6bf53e should be reverted because
semantically all it does is remove the smp_wmb() above.

Please let me know what you think,

Will



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