Re: Alpha tas() patch - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Alpha tas() patch
Date
Msg-id 3833.977971044@sss.pgh.pa.us
Whole thread Raw
Responses Re: Alpha tas() patch  (Brent Verner <brent@rcfile.org>)
List pgsql-hackers
Brent Verner <brent@rcfile.org> writes:
>   This is a revised patch that I sent earlier to allow building
> pg-7.1 with gcc as well as DEC's cc. I've had good results with this
> applied. Could some other Alpha users try this out. Even better, could
> an Alpha asm guru look over the asm that I'm using (instead of the
> original asm in the file).

tas() is not supposed to contain a loop.  It can succeed or fail, but
it should not wait.

The code now in s_lock.h does seem rather gratuitously obscure about
the instructions it uses to load constants.  I'd suggest

static __inline__ int
tas(volatile slock_t *lock)
{register slock_t _res;

__asm__("     ldq   $0, %0           \n\             bne   $0, 2f           \n\             ldq_l $0, %0           \n\
          bne   $0, 2f           \n\             mov   1, $0            \n\             stq_c $0, %0           \n\
      beq   $0, 2f           \n\             mov   0, %1            \n\             mb                     \n\
  jmp   $31, 3f          \n\          2: mov   1, %1            \n\          3: nop      ": "=m"(*lock), "=r"(_res):
:"0");
   return (int) _res;
}

As you say, the first two instructions don't seem to be really
necessary.  I suppose the idea is to avoid setting the processor
lock address register unless there's a pretty good chance of
acquiring the lock ... but why bother?  Does LDQ_L take a long
time to execute?  Seems like avoiding the extra two instructions
would be a win most of the time.
           regards, tom lane


pgsql-hackers by date:

Previous
From: Adam Haberlach
Date:
Subject: Re: PHP and PostgreSQL
Next
From: Tom Lane
Date:
Subject: Re: [PATCHES] Re: Re: Tuple-valued datums on Alpha (was Re: 7.1 on DEC/Alpha)