From: Linus Torvalds <torvalds@osdl.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Pavel Machek <pavel@suse.cz>,
vojtech@suse.cz, James Bottomley <James.Bottomley@SteelEye.com>,
Andrew Morton <akpm@osdl.org>, Paul Jackson <pj@sgi.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
PARISC list <parisc-linux@lists.parisc-linux.org>
Subject: Re: [parisc-linux] Re: [PATCH] Fix the cpumask rewrite
Date: Thu, 1 Jul 2004 09:15:01 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.58.0407010908260.11212@ppc970.osdl.org> (raw)
In-Reply-To: <1088690821.4621.11.camel@localhost.localdomain>
On Thu, 1 Jul 2004, Alan Cox wrote:
>
> On Iau, 2004-07-01 at 14:11, Pavel Machek wrote:
> > Heh, with vojtech we introduced locking into input layer
> > (there was none before)... using test_bit/set_bit.
> >
> > (I just hope set_bit etc implies memory barrier... or we'll have to do
> > it once more)
>
> It doesn't - the ppp layer got burned badly by this long ago. set_bit is
> not a memory barrier. OTOH you can just add an mb()
The "test_and_xxx()" things are memory barriers, but set_bit/clear_bit
aren't (since ther aren't really supposed to be usable for locking).
It _happens_ to be one on x86, so sadly it works on 99% of the machines
out there. And to avoid the extra (suprefluous) mb(), there are
smp_mb__before_clear_bit()
smp_mb__after_clear_bit()
that only works with "clear_bit()", on the assumption that the way you'd
do locking is:
lock:
while (test_and_set_bit(..)) /* This is a memory barrier */
while (test_bit(..))
cpu_relax();
.. protected region ..
unlock:
smp_mb__before_clear_bit();
clear_bit(..);
but the fact is, the above is broken too, for a totally _unrelated_
reason, namely preemption. And then you have the SMP case etc still.
The fact is, you shouldn't use the bitops for locking. You _will_ get it
wrong. Use a spinlock, and if you _really_ really need just a single bit,
use
bit_spin_lock(bitnum,addr)
..
bit_spin_unlock(bitnum,addr)
which should get all of this right, and if we ever chaneg the consistency
rules, we'll make sure the bitlocks still work.
So please..
Linus
next prev parent reply other threads:[~2004-07-01 16:15 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-26 16:08 James Bottomley
2004-06-26 16:32 ` Linus Torvalds
2004-06-26 16:44 ` Linus Torvalds
2004-06-26 16:46 ` James Bottomley
2004-06-26 16:54 ` Linus Torvalds
2004-06-26 17:18 ` James Bottomley
2004-06-26 18:01 ` Linus Torvalds
2004-06-26 18:28 ` Vojtech Pavlik
2004-06-26 18:54 ` Linus Torvalds
2004-06-26 19:02 ` James Bottomley
2004-06-26 19:13 ` Linus Torvalds
2004-06-26 19:13 ` Vojtech Pavlik
2004-06-26 18:59 ` James Bottomley
2004-06-26 19:11 ` Linus Torvalds
2004-06-26 19:33 ` James Bottomley
2004-06-28 23:16 ` Jonathan Lundell
2004-07-01 13:11 ` Pavel Machek
2004-07-01 14:07 ` [parisc-linux] " Alan Cox
2004-07-01 16:15 ` Linus Torvalds [this message]
2004-07-01 16:52 ` Jeff Garzik
2004-07-01 17:42 ` Linus Torvalds
2004-06-26 22:18 ` Chris Wedgwood
2004-06-26 22:48 ` Linus Torvalds
2004-06-26 22:54 ` [parisc-linux] " Alan Cox
2004-06-27 0:05 ` Chris Wedgwood
2004-06-27 12:00 ` Matthias Urlichs
2004-06-27 22:41 ` Chris Wedgwood
2004-06-28 1:24 ` Matthias Urlichs
2004-06-28 5:42 ` Chris Wedgwood
2004-06-28 6:55 ` Matthias Urlichs
2004-06-28 7:02 ` Chris Wedgwood
2004-06-28 7:19 ` Matthias Urlichs
2004-06-27 14:37 ` Alan Cox
2004-07-01 13:33 ` Pavel Machek
2004-07-01 17:43 ` Chris Wedgwood
2004-06-26 23:37 ` jiffies_64 Chris Wedgwood
2004-06-27 1:55 ` more (insane) jiffies ranting Chris Wedgwood
2004-06-27 17:39 ` Linus Torvalds
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.58.0407010908260.11212@ppc970.osdl.org \
--to=torvalds@osdl.org \
--cc=James.Bottomley@SteelEye.com \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=parisc-linux@lists.parisc-linux.org \
--cc=pavel@suse.cz \
--cc=pj@sgi.com \
--cc=vojtech@suse.cz \
/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
all inboxes | Powered by JetHome®