Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@oss.sgi.com>
To: Florian Lohoff <flo@rfc822.org>
Cc: linux-mips@oss.sgi.com
Subject: Re: userspace spinlocks
Date: Tue, 31 Oct 2000 19:22:57 +0100	[thread overview]
Message-ID: <20001031192257.B28909@bacchus.dhis.org> (raw)
In-Reply-To: <20001030151736.C2687@paradigm.rfc822.org>; from flo@rfc822.org on Mon, Oct 30, 2000 at 03:17:36PM +0100

On Mon, Oct 30, 2000 at 03:17:36PM +0100, Florian Lohoff wrote:

> Hi,
> while compiling db2 i got the configure warning "spinlocks not implemented
> for this compiler/architecture" - I guess as we do not currently have
> SMP machines (except the ones ralf is working on) we dont have a problem,
> but how should the spinlocks be implemented ?

Think multithreadeding.  We do have the problem on every machine.

> I mean - normally "ll" and "sc" are needed - But those are not
> available on R3000 - And spinning in an ll/sc loop and emulating
> them with exceptions isnt that fast.

The assumption is that spinlocks have low contention so we don't loop.

Face it - the R3000 is completly idiotic processor to use in multiprocessor
systems.  Early R3000 SMP systems as built by SGI in the 80's did use
special external hardware to implement atomic operations.  Any atomic
operation was very expensive.  An old way to implement threadsafe atomic
operations is the sysmips(MIPS_ATOMIC_SET) interface, essentially a
syscall that implements atomic set-and-exchange functionality.  Something
that only continues to live as a compatibility relict.

We don't support R3000 SMP but multithreading turns out to be a similar
problem.  Computer science offers a number of algorithems which only
require atomic stores.  Their common problem is that they're aproximately
O(n^2) in the average or O(n) and have memory requirements proprortional
to n.  All in all it comes down to the fact that they're frighteningly
useless for realworld use.

For all this reasons I've choosen to simply implement userspace locking
by simply emulating ll/sc where not available.

If somebody really thinks the performance of this operations is a problem
well, our implementation is hardly optimal.

> OTOH - Where are they normally implemented ? libc ? macro ? Could
> there be a runtime linking thing with a cpu detection wether we 
> have ll/sc or not ?

Typical databases carry their own locking routines which are very well
tuned toward the behaviour of the database.

  Ralf

      parent reply	other threads:[~2000-10-31 21:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-30 14:17 userspace spinlocks Florian Lohoff
2000-10-30 17:51 ` Jun Sun
2000-10-31 20:14   ` Ralf Baechle
2000-10-31 22:01     ` Jun Sun
2000-11-01  6:50       ` Mike Klar
2000-11-01  6:50         ` Mike Klar
2000-11-01 13:36         ` Ralf Baechle
2000-11-01 16:40           ` Mike Klar
2000-11-01 16:40             ` Mike Klar
2000-11-01  9:09     ` Florian Lohoff
2000-10-31 18:22 ` Ralf Baechle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20001031192257.B28909@bacchus.dhis.org \
    --to=ralf@oss.sgi.com \
    --cc=flo@rfc822.org \
    --cc=linux-mips@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox