From: Nick Piggin <nickpiggin@yahoo.com.au>
To: David Miller <davem@davemloft.net>
Cc: paulmck@linux.vnet.ibm.com, mingo@elte.hu, tglx@linutronix.de,
linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Subject: Re: BUG in 2.6.20-rt8
Date: Mon, 26 Feb 2007 15:19:03 +1100 [thread overview]
Message-ID: <45E25FB7.9020306@yahoo.com.au> (raw)
In-Reply-To: <20070225.180927.112620704.davem@davemloft.net>
David Miller wrote:
> From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> Date: Sun, 25 Feb 2007 17:52:30 -0800
>
>
>>Why doesn't the traditional hash table of locks work here? Use the
>>cache-line address as input to the hash function, take the corresponding
>>lock, do the compare-and-exchange by hand, and then release the lock.
>>What am I missing here? Address aliasing do to memory being mapped into
>>multiple locations or something? (In that case, use only the portion
>>of the address within the page, right?)
>
>
> It doesn't protect against pure stores.
Use atomic_cmpxchg (or atomic_long_cmpxchg). The atomic_t type ensures
that unprotected stores don't happen (unless you try to do something
stupid, but you can break all other atomic_ ops like that anyway).
> Even ignoring that you'll also need to disable interrupts, always,
> which therefore will always perform very poorly compared to an
> open-coded spinlock variant.
But on those architectures, the same argument could also be said about
a lot of atomic_ operations in the generic kernel code (ie. just use
spinlocks).
> There are zero gains to cmpxchg(), in my opinion, you dirty and
> grab exclusive access to a cacheline with cmpxchg() just the
> same as a spinlock, so the real cost is the same.
>
> There is zero justification for using this primitive in generic
> code.
IMO it is useful for when you are memory constrained (and bit locks
are no good because they require an atomic unlock). For example we
could actually cut down on a reasonable number of atomic ops by adding
a spinlock to struct page. However I suspect this wouldn't go down too
well.
With that said, our use of atomic operations in the kernel is probably
not an optimal balance for SMP sparc32 and parisc (ie. those platforms
might be a little faster with more spinlocks and less atomics). Does
it really matter, though?
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
next prev parent reply other threads:[~2007-02-26 4:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-25 5:02 BUG in 2.6.20-rt8 Paul E. McKenney
2007-02-25 6:25 ` Paul E. McKenney
2007-02-25 6:27 ` Ingo Molnar
2007-02-25 6:37 ` David Miller
2007-02-26 1:52 ` Paul E. McKenney
2007-02-26 2:09 ` David Miller
2007-02-26 4:19 ` Nick Piggin [this message]
2007-02-26 1:25 ` Paul E. McKenney
2007-06-07 15:47 ` Steven Rostedt
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=45E25FB7.9020306@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/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).