linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Kevin B. Hendricks" <kevin.hendricks@sympatico.ca>
To: yellowdog-devel@lists.terrasoftsolutions.com,
	linuxppc-dev@lists.linuxppc.org
Subject: Re: why isync in atomic icc and return and atomic dec and return for CONFIG_SMP
Date: Tue, 23 Jul 2002 18:15:05 -0400	[thread overview]
Message-ID: <200207231815.05841.kevin.hendricks@sympatico.ca> (raw)
In-Reply-To: <200207231725.30067.kevin.hendricks@sympatico.ca>


Hi,

"PowerPC Microprocessor Family: The Programming Environments" manual
(MPRPPCFPE-01, MPCFPE/AD from IBM Microelectronics and Motorola -dated
1994) on page 8-104 says the following about "isync" and I am quoting:

This instruction waits for all previous instructions to complete and then
discards any prefetched instructions, causing subsequent instructions to
be fetched (or refetched) from memory and to execute in the context
established by the previous instructions.  This instruction has NO EFFECT
on other processors or their caches.

So why should we be using this only for SMP systems?  If we are using the
atomic operations to create our own locks then I understand why the isync
but then it should be there for both smp and non-smp systems shouldn't it?

I must be missing something here?

Kevin



On July 23, 2002 05:25, Kevin B. Hendricks wrote:
> 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
>
> _______________________________________________
> yellowdog-devel mailing list
> yellowdog-devel@lists.terrasoftsolutions.com
> http://lists.terrasoftsolutions.com/mailman/listinfo/yellowdog-devel


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

  reply	other threads:[~2002-07-23 22:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=200207231815.05841.kevin.hendricks@sympatico.ca \
    --to=kevin.hendricks@sympatico.ca \
    --cc=linuxppc-dev@lists.linuxppc.org \
    --cc=yellowdog-devel@lists.terrasoftsolutions.com \
    /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;
as well as URLs for NNTP newsgroup(s).