linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* why isync in atomic icc and return and atomic dec and return for CONFIG_SMP
@ 2002-07-23 21:25 Kevin B. Hendricks
  2002-07-23 22:15 ` Kevin B. Hendricks
  2002-07-24  0:30 ` Anton Blanchard
  0 siblings, 2 replies; 7+ messages in thread
From: Kevin B. Hendricks @ 2002-07-23 21:25 UTC (permalink / raw)
  To: linuxppc-dev, yellowdog-devel


Hi,

Can anyone tell me the reason why we need to use an isync in the
atomic_add_return and atomic_sub_return (see kernel source in
asm/atomic.h) only for SMP machiens and only when a value is returned?

My understanding of an "isync" is that it forces all instruction issued
previous to the isync to be completed before any new instructions can be
fetched on that cpu (not on all cpus?).

Why is this needed only for SMP machines?

Why is it only needed when a value is actually returned (there are no isync
instructions on the non-returning versions)?

Can someone explain exactly what the isync does for us here?


#ifdef CONFIG_SMP
#define SMP_ISYNC       "\n\tisync"
#else
#define SMP_ISYNC
#endif

static __inline__ int atomic_add_return(int a, atomic_t *v)
{
        int t;

        __asm__ __volatile__(
"1:     lwarx   %0,0,%2         # atomic_add_return\n\
        add     %0,%1,%0\n\
        stwcx.  %0,0,%2\n\
        bne-    1b"
        SMP_ISYNC
        : "=&r" (t)
        : "r" (a), "r" (&v->counter)
        : "cc", "memory");

        return t;
}


static __inline__ int atomic_sub_return(int a, atomic_t *v)
{
        int t;

        __asm__ __volatile__(
"1:     lwarx   %0,0,%2         # atomic_sub_return\n\
        subf    %0,%1,%0\n\
        stwcx.  %0,0,%2\n\
        bne-    1b"
        SMP_ISYNC
        : "=&r" (t)
        : "r" (a), "r" (&v->counter)
        : "cc", "memory");

        return t;
}


Thanks,

Kevin


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-08-04 14:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-23 21:25 why isync in atomic icc and return and atomic dec and return for CONFIG_SMP Kevin B. Hendricks
2002-07-23 22:15 ` Kevin B. Hendricks
2002-07-24  0:30 ` Anton Blanchard
2002-07-24 12:04   ` Kevin B. Hendricks
2002-07-28  2:26     ` Anton Blanchard
2002-08-03 14:28       ` Kevin B. Hendricks
2002-08-04 14:26         ` Michael R. Zucca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).