linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Jamie Lokier <jamie@shareable.org>
Cc: Willy Tarreau <willy@w.ods.org>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: TSCs are a no-no on i386
Date: Thu, 31 Jul 2003 11:50:27 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.53.0307311126530.770@chaos> (raw)
In-Reply-To: <20030731150758.GE6410@mail.jlokier.co.uk>

On Thu, 31 Jul 2003, Jamie Lokier wrote:

> Willy Tarreau wrote:
> > The other problem lies with the lock :
> > When a 486 executes "LOCK ; CMPXCHG", it locks the bus during the whole cmpxchg
> > instruction. If a 386 executes the same code, it will get an exception which
> > will be caught by the emulator. I don't see how we can do such an atomic
> > operation while holding a lock. At best, we would think about a global memory
> > based shared lock during the operation (eg: int bus_lock;), but it's not
> > implemented at the moment, and will only be compatible with processors sharing
> > the same code. Add-on processors, such as co-processors, transputer cards, or
> > DSPs, will know nothing about such a lock emulation. And it would result in
> > even poorer performance of course !
>
> Of course this is not a problem when "lock;cmpxchg" is used only for thread
> synchronisation on uniprocessor 386s...  The lock prefix is irrelevant then.
>
> Perhaps the emulation should refuse to pretend to work on an SMP 386 :)
>
> -- Jamie
> -

You can use the lock instruction ahead of any 386 instruction
without creating an exception. When relevent, it locks the whole
bus. When not, it's just a no-op. The trap on the lock instruction
came with the '486. With the '486, if the instruction doesn't
modify memory, then the lock prefix is invalid and will generate
an invalid-opcode exception.

It is not correct to use a lock instruction in front of every
op-code of course, and it might not have been tested for all
corner cases, but generally it's harmless on a '386.

The bad op-code for the i386 is cmpxchg. This is what triggers
the trap. This can be emulated, although the emulation is
not SMP compatible. You worry about this when somebody makes
a dual '386 machine ;^).  Also, the best performing emulation
for any op-codes should be done within the kernel. That way,
the invalid-opcode trap works just like the math emulator. You
don't need the overhead of calling a user-mode handler. If
this is emulation is implimented, then one should also emulate
BSWAP and XADD. This makes '486 code compatible with '386
machines.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.


  parent reply	other threads:[~2003-07-31 15:55 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-30 13:56 TSCs are a no-no on i386 Jan-Benedict Glaw
2003-07-30 14:18 ` Maciej W. Rozycki
2003-07-30 14:44   ` Jan-Benedict Glaw
2003-07-30 16:58 ` Matthew Garrett
2003-07-30 17:19   ` Alan Cox
2003-07-30 18:10 ` Adrian Bunk
2003-07-30 18:30   ` Mike Fedyk
2003-07-30 18:45     ` Adrian Bunk
2003-07-30 20:01       ` Alan Cox
2003-07-30 20:33         ` Jan-Benedict Glaw
2003-07-30 22:19           ` J.A. Magallon
2003-07-31  6:11             ` Jan-Benedict Glaw
2003-07-30 23:05           ` Alan Cox
2003-07-31 11:11             ` Richard B. Johnson
2003-07-31 11:26               ` Emulating i486+ insn on i386 (was: TSCs are a no-no on i386) Jan-Benedict Glaw
2003-07-31 11:41             ` TSCs are a no-no on i386 Jan-Benedict Glaw
2003-07-31  0:22           ` Adrian Bunk
2003-07-31  6:22             ` Jan-Benedict Glaw
2003-07-31  7:17               ` Willy Tarreau
2003-07-31 11:38                 ` Emulating i486 on i386 (was: TSCs are a no-no on i386) Jan-Benedict Glaw
2003-07-31 11:51                   ` Alan Cox
2003-07-31 12:14                     ` Jan-Benedict Glaw
2003-07-31 13:01                       ` Jan-Benedict Glaw
2003-07-31 15:09                         ` Martin Schlemmer
2003-07-31 15:33                           ` Jan-Benedict Glaw
2003-08-01  5:37                             ` Martin Schlemmer
2003-07-31 15:12                     ` Jamie Lokier
2003-07-31 15:32                       ` Jan-Benedict Glaw
2003-07-31 15:07                 ` TSCs are a no-no on i386 Jamie Lokier
2003-07-31 15:23                   ` Willy Tarreau
2003-07-31 15:50                   ` Richard B. Johnson [this message]
2003-07-31 16:24                     ` Jan-Benedict Glaw
2003-08-06 11:08         ` Pavel Machek
2003-08-06 14:33           ` Maciej W. Rozycki
2003-07-30 20:28       ` Jan-Benedict Glaw
2003-07-30 21:50         ` Petr Vandrovec
2003-07-30 23:10           ` Alan Cox
2003-07-31 15:10             ` Jamie Lokier
2003-07-31 16:01               ` Alan Cox
2003-07-31 18:37                 ` Jamie Lokier
2003-07-31 19:10                   ` Alan Cox
2003-07-31  6:29           ` Jan-Benedict Glaw
2003-07-30 20:27   ` Jan-Benedict Glaw
2003-08-06 16:41 James Bottomley
2003-08-06 16:45 James Bottomley

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=Pine.LNX.4.53.0307311126530.770@chaos \
    --to=root@chaos.analogic.com \
    --cc=jamie@shareable.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=willy@w.ods.org \
    /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;
as well as URLs for NNTP newsgroup(s).