From: compudj@krystal.dyndns.org (Mathieu Desnoyers)
Subject: [ltt-dev] [PATCH 1/2] use generic-size operations for common implementation of atomic ops
Date: Fri, 12 Nov 2010 07:04:11 -0500 [thread overview]
Message-ID: <20101112120410.GA27929@Krystal> (raw)
In-Reply-To: <1289552247-18130-2-git-send-email-pbonzini@redhat.com>
* Paolo Bonzini (pbonzini at redhat.com) wrote:
> The definition of _uatomic_cmpxchg is different in x86 and other architectures.
> For x86 it is a 4-argument macro, for other architectures it is a 3-argument
> function. The next patch will use uatomic_cmpxchg in uatomic_generic.h
> even on x86: adjust existing uses of the underscore-prefixed variant for
> consistency.
Nope. See
#if ((BITS_PER_LONG != 64) && defined(CONFIG_RCU_COMPAT_ARCH))
#else
path in uatomic_arch_x86.h
to see why we use this trick.
We remove a dynamic test on these architectures where compatibility mode
is present.
Thanks,
Mathieu
>
> Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
> ---
> urcu/uatomic_generic.h | 24 ++++++++++++++++--------
> 1 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/urcu/uatomic_generic.h b/urcu/uatomic_generic.h
> index f65b398..383ddfa 100644
> --- a/urcu/uatomic_generic.h
> +++ b/urcu/uatomic_generic.h
> @@ -201,7 +201,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
> oldt = uatomic_read((unsigned char *)addr);
> do {
> old = oldt;
> - oldt = _uatomic_cmpxchg(addr, old, old + val, 1);
> + oldt = uatomic_cmpxchg((unsigned char *)addr,
> + old, old + val);
> } while (oldt != old);
>
> return old + val;
> @@ -215,7 +216,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
> oldt = uatomic_read((unsigned short *)addr);
> do {
> old = oldt;
> - oldt = _uatomic_cmpxchg(addr, old, old + val, 2);
> + oldt = uatomic_cmpxchg((unsigned short *)addr,
> + old, old + val);
> } while (oldt != old);
>
> return old + val;
> @@ -228,7 +230,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
> oldt = uatomic_read((unsigned int *)addr);
> do {
> old = oldt;
> - oldt = _uatomic_cmpxchg(addr, old, old + val, 4);
> + oldt = uatomic_cmpxchg((unsigned int *)addr,
> + old, old + val);
> } while (oldt != old);
>
> return old + val;
> @@ -241,7 +244,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
> oldt = uatomic_read((unsigned long *)addr);
> do {
> old = oldt;
> - oldt = _uatomic_cmpxchg(addr, old, old + val, 8);
> + oldt = uatomic_cmpxchg((unsigned long *)addr,
> + old, old + val);
> } while (oldt != old);
>
> return old + val;
> @@ -273,7 +277,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
> oldt = uatomic_read((unsigned char *)addr);
> do {
> old = oldt;
> - oldt = _uatomic_cmpxchg(addr, old, val, 1);
> + oldt = uatomic_cmpxchg((unsigned char *)addr,
> + old, val);
> } while (oldt != old);
>
> return old;
> @@ -287,7 +292,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
> oldt = uatomic_read((unsigned short *)addr);
> do {
> old = oldt;
> - oldt = _uatomic_cmpxchg(addr, old, val, 2);
> + oldt = uatomic_cmpxchg((unsigned short *)addr,
> + old, val);
> } while (oldt != old);
>
> return old;
> @@ -300,7 +306,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
> oldt = uatomic_read((unsigned int *)addr);
> do {
> old = oldt;
> - oldt = _uatomic_cmpxchg(addr, old, val, 4);
> + oldt = uatomic_cmpxchg((unsigned int *)addr,
> + old, val);
> } while (oldt != old);
>
> return old;
> @@ -313,7 +320,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
> oldt = uatomic_read((unsigned long *)addr);
> do {
> old = oldt;
> - oldt = _uatomic_cmpxchg(addr, old, val, 8);
> + oldt = uatomic_cmpxchg((unsigned long *)addr,
> + old, val);
> } while (oldt != old);
>
> return old;
> --
> 1.7.3.2
>
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2010-11-12 12:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-12 8:57 [ltt-dev] [PATCH 0/2] Add uatomic_and and uatomic_or to uatomic library Paolo Bonzini
2010-11-12 8:57 ` [ltt-dev] [PATCH 1/2] use generic-size operations for common implementation of atomic ops Paolo Bonzini
2010-11-12 12:04 ` Mathieu Desnoyers [this message]
2010-11-12 8:57 ` [ltt-dev] [PATCH 2/2] introduce uatomic_and and uatomic_or Paolo Bonzini
2010-11-12 12:08 ` Mathieu Desnoyers
2010-11-12 12:13 ` Paolo Bonzini
2010-11-12 12:19 ` Mathieu Desnoyers
2010-11-12 12:24 ` Paolo Bonzini
2010-11-12 12:27 ` Paolo Bonzini
2010-11-12 12:30 ` Mathieu Desnoyers
2010-11-12 12:38 ` Mathieu Desnoyers
2010-11-12 14:39 ` Paolo Bonzini
2010-11-12 12:29 ` Mathieu Desnoyers
2010-11-12 14:39 ` Paolo Bonzini
2010-11-12 12:15 ` Mathieu Desnoyers
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=20101112120410.GA27929@Krystal \
--to=compudj@krystal.dyndns.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