All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wessel <jason.wessel@windriver.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: kgdb-bugreport@lists.sourceforge.net,
	Will Deacon <will.deacon@arm.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	linux-arm@vger.kernel.org
Subject: Re: [Kgdb-bugreport] [PATCH 4/5] kgdb: Use atomic operators whichuse barriers
Date: Fri, 02 Apr 2010 14:47:47 -0500	[thread overview]
Message-ID: <4BB649E3.5060606@windriver.com> (raw)
In-Reply-To: <4BB64762.6040806@windriver.com>


Here is the revised patch, which is going into the kgdb-fixes branch.

Thanks,
Jason.

--
From: Jason Wessel <jason.wessel@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@arm.com>
Signed-off-by: Jason Wessel <jason.wessel@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]);
 
 	/*
 	 * CPU will loop if it is a slave or request to become a kgdb
@@ -1400,7 +1399,7 @@ return_normal:
 			 */
 			if (arch_kgdb_ops.correct_hw_break)
 				arch_kgdb_ops.correct_hw_break();
-			atomic_set(&cpu_in_kgdb[cpu], 0);
+			atomic_dec(&cpu_in_kgdb[cpu]);
 			touch_softlockup_watchdog_sync();
 			clocksource_touch_watchdog();
 			local_irq_restore(flags);
@@ -1449,7 +1448,7 @@ return_normal:
 	 */
 	if (!kgdb_single_step) {
 		for (i = 0; i < NR_CPUS; i++)
-			atomic_set(&passive_cpu_wait[i], 1);
+			atomic_inc(&passive_cpu_wait[i]);
 	}
 
 #ifdef CONFIG_SMP
@@ -1483,11 +1482,11 @@ return_normal:
 	if (kgdb_io_ops->post_exception)
 		kgdb_io_ops->post_exception();
 
-	atomic_set(&cpu_in_kgdb[ks->cpu], 0);
+	atomic_dec(&cpu_in_kgdb[ks->cpu]);
 
 	if (!kgdb_single_step) {
 		for (i = NR_CPUS-1; i >= 0; i--)
-			atomic_set(&passive_cpu_wait[i], 0);
+			atomic_dec(&passive_cpu_wait[i]);
 		/*
 		 * Wait till all the CPUs have quit
 		 * from the debugger.
@@ -1736,11 +1735,11 @@ EXPORT_SYMBOL_GPL(kgdb_unregister_io_mod
  */
 void kgdb_breakpoint(void)
 {
-	atomic_set(&kgdb_setting_breakpoint, 1);
+	atomic_inc(&kgdb_setting_breakpoint);
 	wmb(); /* Sync point before breakpoint */
 	arch_kgdb_breakpoint();
 	wmb(); /* Sync point after breakpoint */
-	atomic_set(&kgdb_setting_breakpoint, 0);
+	atomic_dec(&kgdb_setting_breakpoint);
 }
 EXPORT_SYMBOL_GPL(kgdb_breakpoint);
 

  parent reply	other threads:[~2010-04-02 19:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-02 18:32 [GIT PULL] kgdb fixes for 2.6.34-rc3 Jason Wessel
2010-04-02 18:32 ` [PATCH 1/5] kgdb: have ebin2mem call probe_kernel_write once Jason Wessel
2010-04-02 18:32   ` [PATCH 2/5] kgdbts,sh: Add in breakpoint pc offset for superh Jason Wessel
2010-04-02 18:32     ` [PATCH 3/5] kgdb: eliminate kgdb_wait(), all cpus enter the same way Jason Wessel
2010-04-02 18:32       ` [PATCH 4/5] kgdb: Use atomic operators which use barriers Jason Wessel
2010-04-02 18:32         ` [PATCH 5/5] kgdb: Turn off tracing while in the debugger Jason Wessel
2010-04-02 19:12         ` [PATCH 4/5] kgdb: Use atomic operators which use barriers Linus Torvalds
2010-04-02 19:37           ` Jason Wessel
2010-04-02 19:43             ` Linus Torvalds
2010-04-02 19:46               ` Linus Torvalds
2010-04-02 20:07                 ` Linus Torvalds
2010-04-02 22:25               ` Russell King - ARM Linux
2010-04-02 23:24                 ` Linus Torvalds
2010-04-03 16:08                   ` Russell King - ARM Linux
2010-04-05  9:21               ` Pavel Machek
2010-04-05 14:56                 ` Linus Torvalds
2010-04-02 19:47             ` Jason Wessel [this message]
2010-04-02 19:47               ` [Kgdb-bugreport] [PATCH 4/5] kgdb: Use atomic operators whichuse barriers Linus Torvalds
2010-04-02 20:00                 ` Jason Wessel
2010-04-08 16:27                   ` Dmitry Adamushko
2010-04-19 15:21               ` Will Deacon
     [not found]           ` <000501cad70a$26ca7e10$745f7a30$@deacon@arm.com>
2010-04-08 14:55             ` [PATCH 4/5] kgdb: Use atomic operators which use barriers Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BB649E3.5060606@windriver.com \
    --to=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-arm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=torvalds@linux-foundation.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.