* Re: Why does ia64 not use fetchadd in atomic.h?
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
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Matthew Wilcox @ 2006-06-15 20:49 UTC (permalink / raw)
To: linux-ia64
On Thu, Jun 15, 2006 at 01:35:42PM -0700, Christoph Lameter wrote:
> Why not
>
> #define ia64_atomic_add(__i, __v) ia64_fetchadd(__i, &v->counter, acq)
Because ia64_fetchadd() only supports 8 different constants?
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: Why does ia64 not use fetchadd in atomic.h?
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
2006-06-15 21:28 ` Christoph Lameter
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Chen, Kenneth W @ 2006-06-15 20:50 UTC (permalink / raw)
To: linux-ia64
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
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Why does ia64 not use fetchadd in atomic.h?
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
@ 2006-06-15 21:28 ` Christoph Lameter
2006-06-15 21:39 ` Chen, Kenneth W
2006-06-15 21:48 ` Christoph Lameter
4 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2006-06-15 21:28 UTC (permalink / raw)
To: linux-ia64
On Thu, 15 Jun 2006, Matthew Wilcox wrote:
> On Thu, Jun 15, 2006 at 01:35:42PM -0700, Christoph Lameter wrote:
> > Why not
> >
> > #define ia64_atomic_add(__i, __v) ia64_fetchadd(__i, &v->counter, acq)
>
> Because ia64_fetchadd() only supports 8 different constants?
Right. I forgot about that. Only a call to atomic_add does the fetchadd
trickery. Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Why does ia64 not use fetchadd in atomic.h?
2006-06-15 20:35 Why does ia64 not use fetchadd in atomic.h? Christoph Lameter
` (2 preceding siblings ...)
2006-06-15 21:28 ` Christoph Lameter
@ 2006-06-15 21:39 ` Chen, Kenneth W
2006-06-15 21:48 ` Christoph Lameter
4 siblings, 0 replies; 6+ messages in thread
From: Chen, Kenneth W @ 2006-06-15 21:39 UTC (permalink / raw)
To: linux-ia64
Christoph Lameter wrote on Thursday, June 15, 2006 2:29 PM
> > On Thu, Jun 15, 2006 at 01:35:42PM -0700, Christoph Lameter wrote:
> > > Why not
> > >
> > > #define ia64_atomic_add(__i, __v) ia64_fetchadd(__i, &v->counter, acq)
> >
> > Because ia64_fetchadd() only supports 8 different constants?
>
> Right. I forgot about that. Only a call to atomic_add does the fetchadd
> trickery. Thanks.
I guess I got confused, are you complaining about ia64_atomic_add or
ia64_atomic64_add? If the former, there is not much can be done, but if
the latter, yeah, it can be optimized for certain constant.
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: Why does ia64 not use fetchadd in atomic.h?
2006-06-15 20:35 Why does ia64 not use fetchadd in atomic.h? Christoph Lameter
` (3 preceding siblings ...)
2006-06-15 21:39 ` Chen, Kenneth W
@ 2006-06-15 21:48 ` Christoph Lameter
4 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2006-06-15 21:48 UTC (permalink / raw)
To: linux-ia64
On Thu, 15 Jun 2006, Chen, Kenneth W wrote:
> I guess I got confused, are you complaining about ia64_atomic_add or
> ia64_atomic64_add? If the former, there is not much can be done, but if
> the latter, yeah, it can be optimized for certain constant.
No complaints. I was just looking for an explanation.
^ permalink raw reply [flat|nested] 6+ messages in thread