Re: Alpha tas() patch

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

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;
}

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-12-28 02:45:06 Re: [PATCHES] Re: Re: Tuple-valued datums on Alpha (was Re: 7.1 on DEC/Alpha)
Previous Message Adam Haberlach 2000-12-28 01:58:35 Re: [HACKERS] PHP and PostgreSQL

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2000-12-28 02:45:06 Re: [PATCHES] Re: Re: Tuple-valued datums on Alpha (was Re: 7.1 on DEC/Alpha)
Previous Message Tom Lane 2000-12-28 01:02:27 Re: Re: [HACKERS] Re: Tuple-valued datums on Alpha (was Re: 7.1 on DEC/Alpha)