Re: TSCs are a no-no on i386

From: Petr Vandrovec (vandrove@vc.cvut.cz)
Date: Wed Jul 30 2003 - 16:50:32 EST


On Wed, Jul 30, 2003 at 10:28:22PM +0200, Jan-Benedict Glaw wrote:
> On Wed, 2003-07-30 20:45:29 +0200, Adrian Bunk <bunk@fs.tum.de>
> > When used on a 386, Linux can emulate 3 instructions from the 486 set.
> > This allows user space programs compiled for 486 to run on a 386
> > without crashing with a SIGILL. As any emulation, performance will be
> > very low, but since these instruction are not often used, this might
> > not hurt. The emulated instructions are:
> > - bswap (does the same as htonl())
> > - cmpxchg (used in multi-threading, mutex locking)
> > - xadd (rarely used)
>
> libstdc++ (and it's main user, apt-get) break at a LOCK insn.

There is no such instruction. Skip LOCK prefix and decode again,
you'll get either cmpxchg or xadd (or cmpxchg8b, but then it does
not work on i486 too).

And yes, it speeds some workloads a lot. Best to look at code,
with these instructions you can do couple of operations without
doing IPC to synchronize with other threads.

And as far as I know, userspace solution does not qualify: major user
is synchronization between threads, so with userspace solution you
will have to do very hard job to get it right (first implement your
own synchronization, if possible without busy waiting... and then
implement cmpxchg on the top of it), while kernel solution can do
that simple & correct for UP case.
                                Best regards,
                                        Petr Vandrovec
                                        vandrove@vc.cvut.cz
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jul 31 2003 - 22:00:47 EST