lkml.org 
[lkml]   [2007]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [Kgdb-bugreport] 2.6.23-rc3-mm1: kgdb build failure on powerpc
    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.
    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);
    \
     
     \ /
      Last update: 2007-08-23 00:47    [W:4.088 / U:0.196 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site