From: Jason Wessel <jason.wessel@windriver.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kgdb-bugreport@lists.sourceforge.net, amitkale@linsyssoft.com,
linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
Mariusz Kozlowski <m.kozlowski@tuxland.pl>,
Paul Mackerras <paulus@samba.org>
Subject: Re: [Kgdb-bugreport] 2.6.23-rc3-mm1: kgdb build failure on powerpc
Date: Wed, 22 Aug 2007 17:44:12 -0500 [thread overview]
Message-ID: <46CCBC3C.7010307@windriver.com> (raw)
In-Reply-To: <20070822124743.fc316963.akpm@linux-foundation.org>
[-- Attachment #1: Type: text/plain, Size: 1897 bytes --]
Andrew Morton wrote:
> On Wed, 22 Aug 2007 21:04:28 +0200
> Mariusz Kozlowski <m.kozlowski@tuxland.pl> wrote:
>
>
>> Hello,
>>
>> Got that on imac g3.
>>
>> CC kernel/kgdb.o
>> kernel/kgdb.c: In function 'kgdb_handle_exception':
>> kernel/kgdb.c:940: error: invalid lvalue in unary '&'
>> kernel/kgdb.c:940: warning: type defaults to 'int' in declaration of '_o_'
>> kernel/kgdb.c:940: error: invalid lvalue in unary '&'
>> kernel/kgdb.c:940: warning: type defaults to 'int' in declaration of '_n_'
>> kernel/kgdb.c:940: error: invalid lvalue in unary '&'
>> kernel/kgdb.c:940: error: invalid lvalue in unary '&'
>> kernel/kgdb.c:940: error: invalid lvalue in unary '&'
>> kernel/kgdb.c:940: warning: type defaults to 'int' in declaration of 'type name'
>> make[1]: *** [kernel/kgdb.o] Blad 1
>> make: *** [kernel] Blad 2
>>
>>
>
>
Against the tip of the kernel + kgdb patches this config builds. I
wonder if is the compiler or the macros for atomic_read or cmpxchg have
changed for in the -mm tree. Perhaps it is not relevant though if you
read on.
> I'm not surprised.
>
> while (cmpxchg(&atomic_read(&debugger_active), 0, (procid + 1)) != 0) {
>
> a) cmpxchg isn't available on all architectures
>
>
It was available for all the archs that the kgdb had been implemented on
at the time.
> b) we can't just go and take the address of atomic_read()'s return value!
>
>
Perhaps yes, perhaps no I guess it depends on what actually gets
generated... In the past the intent of this was to guard for the race
to be the master processor and looked like some attempt to do it
atomically. This code had been in use for a number of years at this point.
> c) that's pretty ugly-looking stuff anyway.
>
>
Perhaps there is a cleaner way to do the same thing and avoid the
cmpxchg all together. I used the attached patch to eliminate the
cmpxchg operation.
Jason.
[-- Attachment #2: kgdb_enter_atomic.patch --]
[-- Type: text/plain, Size: 2028 bytes --]
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
kernel/kgdb.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
--- a/kernel/kgdb.c
+++ b/kernel/kgdb.c
@@ -121,6 +121,7 @@ struct task_struct *kgdb_usethread, *kgd
int debugger_step;
atomic_t debugger_active;
+static atomic_t kgdb_sync = ATOMIC_INIT(-1);
/* Our I/O buffers. */
static char remcom_in_buffer[BUFMAX];
@@ -638,8 +639,14 @@ static void kgdb_wait(struct pt_regs *re
kgdb_info[processor].task = current;
atomic_set(&procindebug[processor], 1);
+ /* The master processor must be active to enter here, but this is
+ * gaurd in case the master processor had not been selected if
+ * this was an entry via nmi.
+ */
+ while (!atomic_read(&debugger_active));
+
/* Wait till master processor goes completely into the debugger.
- * FIXME: this looks racy */
+ */
while (!atomic_read(&procindebug[atomic_read(&debugger_active) - 1])) {
int i = 10; /* an arbitrary number */
@@ -973,8 +980,13 @@ int kgdb_handle_exception(int ex_vector,
/* Hold debugger_active */
procid = raw_smp_processor_id();
- while (cmpxchg(&atomic_read(&debugger_active), 0, (procid + 1)) != 0) {
+ while (1) {
int i = 25; /* an arbitrary number */
+ if (atomic_read(&kgdb_sync) < 0 &&
+ atomic_inc_and_test(&kgdb_sync)) {
+ atomic_set(&debugger_active, procid + 1);
+ break;
+ }
while (--i)
cpu_relax();
@@ -991,6 +1003,7 @@ int kgdb_handle_exception(int ex_vector,
if (atomic_read(&cpu_doing_single_step) != -1 &&
atomic_read(&cpu_doing_single_step) != procid) {
atomic_set(&debugger_active, 0);
+ atomic_set(&kgdb_sync, -1);
clocksource_touch_watchdog();
kgdb_softlock_skip[procid] = 1;
local_irq_restore(flags);
@@ -1557,6 +1570,7 @@ int kgdb_handle_exception(int ex_vector,
kgdb_restore:
/* Free debugger_active */
atomic_set(&debugger_active, 0);
+ atomic_set(&kgdb_sync, -1);
clocksource_touch_watchdog();
kgdb_softlock_skip[processor] = 1;
local_irq_restore(flags);
next prev parent reply other threads:[~2007-08-23 1:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20070822020648.5ea3a612.akpm@linux-foundation.org>
2007-08-22 19:04 ` 2.6.23-rc3-mm1: kgdb build failure on powerpc Mariusz Kozlowski
2007-08-22 19:47 ` Andrew Morton
2007-08-22 22:44 ` Jason Wessel [this message]
2007-08-22 23:53 ` [Kgdb-bugreport] " Andrew Morton
2007-08-23 3:25 ` Jason Wessel
2007-08-29 23:43 ` Pete/Piet Delaney
2007-08-30 0:05 ` Pete/Piet Delaney
2007-08-30 1:19 ` Pete/Piet Delaney
2007-08-30 1:38 ` Randy Dunlap
2007-08-30 2:07 ` Jason Wessel
2007-08-30 2:13 ` Jason Wessel
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=46CCBC3C.7010307@windriver.com \
--to=jason.wessel@windriver.com \
--cc=akpm@linux-foundation.org \
--cc=amitkale@linsyssoft.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=m.kozlowski@tuxland.pl \
--cc=paulus@samba.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).