Re: [tip:perfcounters/urgent] x86: atomic64: Fix unclean type usein atomic64_xchg()

From: Ingo Molnar
Date: Fri Jul 03 2009 - 14:01:30 EST



* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Fri, 3 Jul 2009, tip-bot for Ingo Molnar wrote:
> >
> > Fix atomic64_xchg() to use __atomic64_read() instead.
>
> Hmm. The whole __atomic64_read() thing should be dropped. Are
> there any users? None of them should be valid, as Eric's numbers
> showed. It's apparently better to start out with a random value
> rather than actually trying to read it.

ah, yes.

We still have this use:

u64 atomic64_xchg(atomic64_t *ptr, u64 new_val)
{
u64 old_val;

do {
old_val = __atomic64_read(ptr);
} while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);

return old_val;
}
EXPORT_SYMBOL(atomic64_xchg);

I'm testing the commit below which improves this loop and also
removes __atomic64_read().

Ingo

---------------->