Re: Alpha tas() patch

From: Brent Verner <brent(at)rcfile(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Alpha tas() patch
Date: 2000-12-28 14:35:59
Message-ID: 20001228093559.A13865@rcfile.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On 27 Dec 2000 at 21:37 (-0500), Tom Lane wrote:
| Brent Verner <brent(at)rcfile(dot)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;
| }

another loop-free version of TAS that /seems/ to work as desired. WRT to your
seeing the shutdown lock failure, what are you doing to provoke this bug?,
because I have not seen it with either version of the TAS that I've used.

brent

#define TAS(lock) tas_dbv(lock)
#define S_UNLOCK(lock) do { __asm__("mb"); *(lock) = 0; } while (0)

static
__inline__
int
tas(volatile slock_t* __lock)
{
register slock_t __rv;
register slock_t __temp;

__asm__
__volatile__
(
"1: ldq_l %0, %1 \n" /* load (and lock) __lock */
" and %0, 1, %2 \n" /* if bit 1 is set, store 1 in __rv */
" bne %2, 2f \n" /* if __rv != 0, already locked. leave */
" xor %0, 1, %0 \n" /* set bit 1 in slock_t */
" stq_c %0, %1 \n" /* store __lock, only stores if we locked */
" mb \n" /* memory block (necessary?) */
" 2: nop \n" /* exit point */
: "=&r" (__temp),
"=m" (*__lock),
"=&r" (__rv)
: "m" (*__lock)
);

return (int) __rv;
}

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Adriaan Joubert 2000-12-28 15:03:26 Re: Re: Alpha tas() patch
Previous Message Vadim Mikheev 2000-12-28 13:51:10 New WAL version (CRC & data pages backup)

Browse pgsql-patches by date

  From Date Subject
Next Message Adriaan Joubert 2000-12-28 15:03:26 Re: Re: Alpha tas() patch
Previous Message Brent Verner 2000-12-28 05:05:42 Re: [PATCHES] Re: Re: Tuple-valued datums on Alpha (was Re: 7.1 on DEC/Alpha)