public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: linux-ia64@vger.kernel.org
Subject: RE: Why does ia64 not use fetchadd in atomic.h?
Date: Thu, 15 Jun 2006 20:50:33 +0000	[thread overview]
Message-ID: <000001c690bd$58f41e10$e434030a@amr.corp.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0606151323380.10549@schroedinger.engr.sgi.com>

Christoph Lameter wrote on Thursday, June 15, 2006 1:36 PM
> I just looked at at the asm generated by some of the use of atomic for 
> statistics and saw that there were complicated compxchg constructs where I 
> would have expected a simple fetchadd. Why is this?
> 
> F.e.
> 
> static __inline__ int
> ia64_atomic_add (int i, atomic_t *v)
> {
>         __s32 old, new;
>         CMPXCHG_BUGCHECK_DECL
> 
>         do {
>                 CMPXCHG_BUGCHECK(v);
>                 old = atomic_read(v);
>                 new = old + i;
>         } while (ia64_cmpxchg(acq, v, old, new, sizeof(atomic_t)) != old);
>         return new;
> }
> 
> Why not
> 
> #define ia64_atomic_add(__i, __v) ia64_fetchadd(__i, &v->counter, acq)


The immediate operand of fetchadd only takes limited value, so it would have
to be a combination of fetchadd and cmpxchg.  If the constant is known at
compile time, it can be optimized for those constants that fetchadd can
operate on.

Back to your original question, I guess whoever implements ia64_atomic_add
didn't bother to optimize it like it's close cousin of atomic_add().

- Ken

  parent reply	other threads:[~2006-06-15 20:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-15 20:35 Why does ia64 not use fetchadd in atomic.h? Christoph Lameter
2006-06-15 20:49 ` Matthew Wilcox
2006-06-15 20:50 ` Chen, Kenneth W [this message]
2006-06-15 21:28 ` Christoph Lameter
2006-06-15 21:39 ` Chen, Kenneth W
2006-06-15 21:48 ` Christoph Lameter

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='000001c690bd$58f41e10$e434030a@amr.corp.intel.com' \
    --to=kenneth.w.chen@intel.com \
    --cc=linux-ia64@vger.kernel.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