From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>,
Linux Kernel Mailing List <Linux-Kernel@vger.kernel.org>,
Dipankar Sarma <dipankar@in.ibm.com>
Subject: Re: [PATCH 2/5] atomic: introduce atomic_inc_not_zero
Date: Wed, 14 Sep 2005 23:21:06 +0100 [thread overview]
Message-ID: <20050914232106.H30746@flint.arm.linux.org.uk> (raw)
In-Reply-To: <Pine.LNX.4.61.0509150010100.3728@scrub.home>; from zippel@linux-m68k.org on Thu, Sep 15, 2005 at 12:10:56AM +0200
On Thu, Sep 15, 2005 at 12:10:56AM +0200, Roman Zippel wrote:
> Hi,
>
> On Wed, 14 Sep 2005, Russell King wrote:
>
> > > do {
> > > old = atomic_load_locked(v);
> > > if (!old)
> > > break;
> > > new = old + 1;
> > > } while (!atomic_store_lock(v, old, new));
> >
> > How do you propose architectures which don't have locked loads implement
> > this, where the only atomic instruction is an unconditional atomic swap
> > between memory and CPU register?
>
> #define atomic_store_lock atomic_cmpxchg
No. "unconditional atomic swap" does not mean cmpxchg - it means that
atomic_cmpxchg itself would have to be open coded, which is inefficient.
What you're asking architectures to do is:
retry:
load
operation
save interrupts
load
compare
store if equal
restore interrupts
goto retry if not equal
whereas they could have done the far simpler version of:
save interrupts
load
operation
store
restore interrupts
which they do today.
The whole point about architecture specific includes is not to provide
a frenzied feeding ground for folk who like to "clean code up" but to
allow architectures to do things in the most efficient way for them
without polluting the kernel too much.
It seems that aspect is being lost sight of here.
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
next prev parent reply other threads:[~2005-09-14 22:21 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-14 14:48 [PATCH 1/5] atomic: introduce atomic_cmpxchg Nick Piggin
2005-09-14 14:49 ` [PATCH 2/5] atomic: introduce atomic_inc_not_zero Nick Piggin
2005-09-14 14:51 ` [PATCH 3/5] rcu file: use atomic primitives Nick Piggin
2005-09-14 14:55 ` [PATCH 4/5] atomic: dec_and_lock use cmpxchg Nick Piggin
2005-09-14 15:01 ` [PATCH 5/5] remove HAVE_ARCH_CMPXCHG Nick Piggin
2005-09-14 16:31 ` Roman Zippel
2005-09-14 16:49 ` Nick Piggin
2005-09-14 17:59 ` David S. Miller
2005-09-14 22:03 ` Russell King
2005-09-14 22:26 ` David S. Miller
2005-09-15 7:10 ` Russell King
2005-09-15 13:08 ` Alan Cox
2005-09-14 15:20 ` [PATCH 4/5] atomic: dec_and_lock use cmpxchg Nick Piggin
2005-09-14 16:24 ` David S. Miller
2005-09-14 16:52 ` Nick Piggin
2005-09-17 0:05 ` David S. Miller
2005-09-14 16:16 ` [PATCH 2/5] atomic: introduce atomic_inc_not_zero Roman Zippel
2005-09-14 16:44 ` Nick Piggin
2005-09-14 17:04 ` Nick Piggin
2005-09-14 17:18 ` Roman Zippel
2005-09-14 22:00 ` Russell King
2005-09-14 22:10 ` Roman Zippel
2005-09-14 22:21 ` Russell King [this message]
2005-09-15 1:51 ` Nick Piggin
2005-09-17 1:15 ` Roman Zippel
2005-09-17 6:36 ` Andrew Morton
2005-09-17 10:01 ` Roman Zippel
2005-09-17 7:19 ` David S. Miller
2005-09-17 7:34 ` Dipankar Sarma
2005-09-18 8:08 ` Nick Piggin
2005-09-17 0:59 ` Roman Zippel
2005-09-17 7:18 ` David S. Miller
2005-09-17 7:27 ` Russell King
2005-09-18 6:03 ` David S. Miller
2005-09-14 15:17 ` [PATCH 1/5] atomic: introduce atomic_cmpxchg Russell King
2005-09-14 15:22 ` Nick Piggin
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=20050914232106.H30746@flint.arm.linux.org.uk \
--to=rmk+lkml@arm.linux.org.uk \
--cc=Linux-Kernel@vger.kernel.org \
--cc=dipankar@in.ibm.com \
--cc=nickpiggin@yahoo.com.au \
--cc=zippel@linux-m68k.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