public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Russell King <rmk+lkml@arm.linux.org.uk>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@osdl.org>
Subject: Re: [patch 2/5] atomic: cmpxchg
Date: Sat, 05 Nov 2005 20:10:53 +1100	[thread overview]
Message-ID: <436C771D.8040703@yahoo.com.au> (raw)
In-Reply-To: <20051105090010.GA18926@flint.arm.linux.org.uk>

Russell King wrote:
> On Sat, Nov 05, 2005 at 06:57:28PM +1100, Nick Piggin wrote:
> 
>>Index: linux-2.6/include/asm-arm/atomic.h
>>===================================================================
>>--- linux-2.6.orig/include/asm-arm/atomic.h
>>+++ linux-2.6/include/asm-arm/atomic.h
>>@@ -80,6 +80,23 @@ static inline int atomic_sub_return(int 
>> 	return result;
>> }
>> 
>>+static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
>>+{
>>+	u32 oldval, res;
>>+
>>+	do {
>>+		__asm__ __volatile__("@ atomic_cmpxchg\n"
>>+		"ldrex	%1, [%2]\n"
>>+		"teq	%1, %3\n"
>>+		"strexeq %0, %4, [%2]\n"
>>+		    : "=&r" (res), "=&r" (oldval)
>>+		    : "r" (&ptr->counter), "r" (old), "r" (new)
>>+		    : "cc");
>>+	} while (res);
>>+
>>+	return oldval;
>>+}
>>+
>> static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
>> {
>> 	unsigned long tmp, tmp2;
>>@@ -131,6 +148,21 @@ static inline int atomic_sub_return(int 
>> 	return val;
>> }
>> 
>>+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
>>+{
>>+	int ret;
>>+	unsigned long flags;
>>+
>>+	local_irq_save(flags);
>>+	ret = v->counter;
>>+	if (likely(ret == old))
>>+		v->counter = new;
>>+	local_irq_restore(flags);
>>+
>>+	return ret;
>>+}
>>+
>>+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
>> static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
> 
> 
> This is obviously going to break ARM...
> 

Ah dang sorry. Must be a cut-n-paste-o.

While you're here, does the assembly code for the SMP version look
OK? You basically provided me with it but I don't think you saw its
final form.

-- 
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com 

  reply	other threads:[~2005-11-05  9:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-05  7:55 [patch 0/4] atomic primitives again Nick Piggin
2005-11-05  7:56 ` [patch 1/5] i386: generic cmpxchg Nick Piggin
2005-11-05  7:57   ` [patch 2/5] atomic: cmpxchg Nick Piggin
2005-11-05  7:58     ` [patch 3/5] atomic: inc_not_zero Nick Piggin
2005-11-05  7:58       ` [patch 4/5] rcu file: use atomic Nick Piggin
2005-11-05  7:59         ` [patch 5/5] atomic: dec_and_lock " Nick Piggin
2005-11-05  9:00     ` [patch 2/5] atomic: cmpxchg Russell King
2005-11-05  9:10       ` Nick Piggin [this message]
2005-11-05  9:13         ` Russell King
2005-11-05  9:21           ` 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=436C771D.8040703@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+lkml@arm.linux.org.uk \
    --cc=torvalds@osdl.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