Author: jhibbits
Date: Tue Jan 31 03:40:13 2017
New Revision: 313007
URL: https://svnweb.freebsd.org/changeset/base/313007

Log:
  Don't retry a lost reservation in atomic_fcmpset()
  
  The desired behavior of atomic_fcmpset_() is to always exit on error.  Instead
  of retrying on lost reservation, leave the retry to the caller, and return
  error.
  
  Reported by:  kib

Modified:
  head/sys/powerpc/include/atomic.h

Modified: head/sys/powerpc/include/atomic.h
==============================================================================
--- head/sys/powerpc/include/atomic.h   Tue Jan 31 03:26:32 2017        
(r313006)
+++ head/sys/powerpc/include/atomic.h   Tue Jan 31 03:40:13 2017        
(r313007)
@@ -678,18 +678,18 @@ atomic_fcmpset_int(volatile u_int *p, u_
        int     ret;
 
        __asm __volatile (
-               "1:\tlwarx %0, 0, %3\n\t"       /* load old value */
+               "lwarx %0, 0, %3\n\t"   /* load old value */
                "cmplw %4, %0\n\t"              /* compare */
-               "bne 2f\n\t"                    /* exit if not equal */
+               "bne 1f\n\t"                    /* exit if not equal */
                "stwcx. %5, 0, %3\n\t"          /* attempt to store */
-               "bne- 1b\n\t"                   /* spin if failed */
+               "bne- 1f\n\t"                   /* exit if failed */
                "li %0, 1\n\t"                  /* success - retval = 1 */
-               "b 3f\n\t"                      /* we've succeeded */
-               "2:\n\t"
+               "b 2f\n\t"                      /* we've succeeded */
+               "1:\n\t"
                "stwcx. %0, 0, %3\n\t"          /* clear reservation (74xx) */
                "stwx %0, 0, %7\n\t"
                "li %0, 0\n\t"                  /* failure - retval = 0 */
-               "3:\n\t"
+               "2:\n\t"
                : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
                : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
                : "cr0", "memory");
@@ -703,20 +703,20 @@ atomic_fcmpset_long(volatile u_long *p, 
 
        __asm __volatile (
            #ifdef __powerpc64__
-               "1:\tldarx %0, 0, %3\n\t"       /* load old value */
+               "ldarx %0, 0, %3\n\t"   /* load old value */
                "cmpld %4, %0\n\t"              /* compare */
-               "bne 2f\n\t"                    /* exit if not equal */
+               "bne 1f\n\t"                    /* exit if not equal */
                "stdcx. %5, 0, %3\n\t"          /* attempt to store */
            #else
-               "1:\tlwarx %0, 0, %3\n\t"       /* load old value */
+               "lwarx %0, 0, %3\n\t"   /* load old value */
                "cmplw %4, %0\n\t"              /* compare */
-               "bne 2f\n\t"                    /* exit if not equal */
+               "bne 1f\n\t"                    /* exit if not equal */
                "stwcx. %5, 0, %3\n\t"          /* attempt to store */
            #endif
-               "bne- 1b\n\t"                   /* spin if failed */
+               "bne- 1f\n\t"                   /* exit if failed */
                "li %0, 1\n\t"                  /* success - retval = 1 */
-               "b 3f\n\t"                      /* we've succeeded */
-               "2:\n\t"
+               "b 2f\n\t"                      /* we've succeeded */
+               "1:\n\t"
            #ifdef __powerpc64__
                "stdcx. %0, 0, %3\n\t"          /* clear reservation (74xx) */
                "stdx %0, 0, %7\n\t"
@@ -725,7 +725,7 @@ atomic_fcmpset_long(volatile u_long *p, 
                "stwx %0, 0, %7\n\t"
            #endif
                "li %0, 0\n\t"                  /* failure - retval = 0 */
-               "3:\n\t"
+               "2:\n\t"
                : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
                : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
                : "cr0", "memory");
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to