8.0 beta 1 on linux-mipsel R5900

Lists: pgsql-hackers
From: Chris <list(at)1006(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-24 00:21:40
Message-ID: 1093306900.7020.206.camel@dell
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I've compiled 8.0 beta 1 on a R5900 V3.1 (a playstation 2) running
Linux (PS2 Linux 1) for portability testing.

Here is what make check gave:

Without --disable-spinlocks
compilation *appears* to be fine, but the backends core dumps
on the spinlock assembly in s_lock.c (signal 4 -- illegal
instruction) on first run.

With --disable-spinlocks
all is well except the two floating point tests float4 and float8
out of 96 tests fail. This is likely due to the R5900 not being
fully IEEE-compliant(?) (regression.diffs attached).

--

I'm wondering: would it be hard to fix the assembly spinlock code
for the R5900?
If that's not worth the trouble, would it be a good idea to have
configure disable spinlocks automagically on unsupported platforms?
Or is it to hard to autodetect this?

Bye, Chris.

PS: I've compiled using gcc 2.95.2 and with CFLAGS -O0 -g.

Attachment Content-Type Size
regression.diffs text/x-patch 4.9 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris <list(at)1006(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-24 02:57:22
Message-ID: 27228.1093316242@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Chris <list(at)1006(dot)org> writes:
> I've compiled 8.0 beta 1 on a R5900 V3.1 (a playstation 2) running
> Linux (PS2 Linux 1) for portability testing.
> ...
> I'm wondering: would it be hard to fix the assembly spinlock code
> for the R5900?

According to the previous port report from Red Hat, the PS2 chip simply
doesn't have any user-space TAS instruction, so you're pretty much stuck.
If you can find something that works, let us know.

> If that's not worth the trouble, would it be a good idea to have
> configure disable spinlocks automagically on unsupported platforms?

It used to do that. We deliberately changed this in 8.0 so that people
would be aware that they were losing performance, and would be motivated
to look into possible solutions.

regards, tom lane


From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-24 05:36:52
Message-ID: 87eklx2j2j.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Chris <list(at)1006(dot)org> writes:
> > I've compiled 8.0 beta 1 on a R5900 V3.1 (a playstation 2) running
> > Linux (PS2 Linux 1) for portability testing.
> > ...
> > I'm wondering: would it be hard to fix the assembly spinlock code
> > for the R5900?
>
> According to the previous port report from Red Hat, the PS2 chip simply
> doesn't have any user-space TAS instruction, so you're pretty much stuck.
> If you can find something that works, let us know.

Out of curiosity. If it lacks a tas instruction, is there really any smp
implementation that runs on it? Why would postgres want spinlocks at all with
only one processor?

--
greg


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-24 06:00:10
Message-ID: 29107.1093327210@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)edu> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>> According to the previous port report from Red Hat, the PS2 chip simply
>> doesn't have any user-space TAS instruction, so you're pretty much stuck.

> Out of curiosity. If it lacks a tas instruction, is there really any smp
> implementation that runs on it?

My recollection is that it has TAS capability but the designers made it
a privileged instruction (in a fit of brain death :-()

> Why would postgres want spinlocks at all with only one processor?

Think harder... one processor != one process...

regards, tom lane


From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-24 06:09:17
Message-ID: Pine.LNX.4.58.0408241539420.27701@linuxworld.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 24 Aug 2004, Greg Stark wrote:

>
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>
> > Chris <list(at)1006(dot)org> writes:
> > > I've compiled 8.0 beta 1 on a R5900 V3.1 (a playstation 2) running
> > > Linux (PS2 Linux 1) for portability testing.
> > > ...
> > > I'm wondering: would it be hard to fix the assembly spinlock code
> > > for the R5900?
> >
> > According to the previous port report from Red Hat, the PS2 chip simply
> > doesn't have any user-space TAS instruction, so you're pretty much stuck.
> > If you can find something that works, let us know.
>
> Out of curiosity. If it lacks a tas instruction, is there really any smp
> implementation that runs on it? Why would postgres want spinlocks at all with
> only one processor?

Errm. Even if we have only one CPU it doesn't mean instructions which
read/write to shared resources in a *multiprocess* environment will be
serialized in the way we want. In fact, its highly unlikely that they
will. If you want to test, make TAS() a noop and see how quickly
things are corrupted in shared memory :-)

Gavin


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Chris <list(at)1006(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-24 06:18:10
Message-ID: 200408240818.10313.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> > If that's not worth the trouble, would it be a good idea to have
> > configure disable spinlocks automagically on unsupported platforms?
>
> It used to do that. We deliberately changed this in 8.0 so that
> people would be aware that they were losing performance, and would be
> motivated to look into possible solutions.

Actually, the previous port report for 7.4 already required explicit
disabling:

needs new config.guess, --disable-spinlocks

(We fixed that first point anyway.)

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Chris <list(at)1006(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-24 06:27:22
Message-ID: 29340.1093328842@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Actually, the previous port report for 7.4 already required explicit
> disabling:
> needs new config.guess, --disable-spinlocks

Yeah, because *normal* ARM processors have a TAS instruction,
and configure only recognizes that you have an ARM.

Apparently Sony bought the 10-cents-off-special without TAS ...

regards, tom lane


From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-24 06:38:32
Message-ID: 87zn4l11nb.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Greg Stark <gsstark(at)mit(dot)edu> writes:
> > Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> >> According to the previous port report from Red Hat, the PS2 chip simply
> >> doesn't have any user-space TAS instruction, so you're pretty much stuck.
>
> > Out of curiosity. If it lacks a tas instruction, is there really any smp
> > implementation that runs on it?

Ah, that would be poor.

> My recollection is that it has TAS capability but the designers made it
> a privileged instruction (in a fit of brain death :-()
>
> > Why would postgres want spinlocks at all with only one processor?
>
> Think harder... one processor != one process...

Well sure, but you don't want a spinlock in that case. You may as well yield
immediately rather than spinning waiting for the inevitable context switch.
Your tas is never going to succeed until the context switch happens anyways.

But I think I'm on the wrong track. Without tas, you don't even get to handle
the common case of an uncontested lock without some sort of kernel call to
block context switches, so you still get a performance hit.

--
greg


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-24 07:18:36
Message-ID: 29793.1093331916@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)edu> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>> Think harder... one processor != one process...

> Well sure, but you don't want a spinlock in that case.

Actually you do, when the normal case is that you don't have to block.
You want it to fall through as quickly as possible in the success case
(the blocking case is going to suck no matter what). Given the present
set of available/portable technologies, spinlocks win.

If you've got a better alternative, educate us ...

regards, tom lane


From: Chris Mair <list(at)1006(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0 beta 1 on linux-mipsel R5900
Date: 2004-08-30 19:38:52
Message-ID: 1093894732.5317.35.camel@dell
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> > I've compiled 8.0 beta 1 on a R5900 V3.1 (a playstation 2) running
> > Linux (PS2 Linux 1) for portability testing.
> > ...
> > I'm wondering: would it be hard to fix the assembly spinlock code
> > for the R5900?
>
> According to the previous port report from Red Hat, the PS2 chip simply
> doesn't have any user-space TAS instruction, so you're pretty much stuck.
> If you can find something that works, let us know.

I've asked about this issue on the ps2 linux forums and somebody
came up with this document:
http://lc.linux.or.jp/lc2001/papers/tas-ps2-paper.pdf

See also this releated thread on the linux-mips list:
http://www.linux-mips.org/archives/linux-mips/2002-01/msg00278.html

I'm not fluent in Japanese or MIPS assembly, so I won't comment
on these. Just posting the links :)

Bye, Chris.