[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090703191709.GA17057@elte.hu>
Date: Fri, 3 Jul 2009 21:17:09 +0200
From: Ingo Molnar <mingo@...e.hu>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Eric Dumazet <eric.dumazet@...il.com>, mingo@...hat.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH -tip] x86: atomic64: inline atomic64_read()
* Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> On Fri, 3 Jul 2009, Ingo Molnar wrote:
> > > +
> > > + asm volatile(
> > > + "mov %%ebx, %%eax\n\t"
> > > + "mov %%ecx, %%edx\n\t"
> > > + LOCK_PREFIX "cmpxchg8b %1\n"
> > > + : "=&A" (res)
> > > + : "m" (*ptr)
> > > + );
> >
> > That clobbers or affects eax, ebx, ecx, edx. The only registers
> > it does not clobber is esi, edi and rbp.
>
> No, it only clobbers eax/edx. Yes, it touches ebx/ecx, but that's
> kind of incidental, and read-only, and doesn't matter.
>
> > Linus, what's your preference in this case?
>
> I think it's kind of subtle to do that thing, but it _is_ very
> much a special case. It's odd to use a cmpxchg8b to just do a read
> in the first place, so the fact that we then play other games with
> it is kind of immaterial.
>
> Adding a comment about the magic "we don't care about the initial
> values in eax/edx and ebx/ecx, but they have to match in case we
> end up doing a writeback" might be a good idea.
Ok - i've applied it and added a comment as well about the reasons
an subtleties.
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists