parlib: Use cpu_relax_vc() in parlib_run_once() (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 4 Apr 2017 18:06:22 +0000 (14:06 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 3 May 2017 16:13:02 +0000 (12:13 -0400)
When you spin wait in userspace, there's a chance that whoever you are
spinning on is preempted.  In these cases, use cpu_relax_vc() instead of
cpu_relax().  That'll periodically check to make sure the other vcores are
running.

Rebuild glibc.  The acrobatics with the weak symbol are needed since some
parts of glibc call parlib_run_once(), and glibc needs to be able to link
without parlib temporarily.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Versions
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/parlib-compat.c
user/parlib/include/parlib/parlib.h

index 10b3c31..3edee52 100644 (file)
@@ -99,3 +99,9 @@ void __spin_pdr_unlock(struct spin_pdr_lock *pdr_lock)
        pdr_lock->lock = SPINPDR_UNLOCKED;
 }
 weak_alias(__spin_pdr_unlock, spin_pdr_unlock)
+
+void __cpu_relax_vc(uint32_t vcoreid)
+{
+       cpu_relax();
+}
+weak_alias(__cpu_relax_vc, cpu_relax_vc)
index d968ffc..7649b97 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef __ASSEMBLER__
 
 #include <parlib/common.h>
+#include <parlib/vcore.h>
 #include <ros/memlayout.h>
 #include <ros/syscall.h>
 #include <ros/procinfo.h>
@@ -96,7 +97,7 @@ static inline void parlib_run_once(parlib_once_t *once_ctl,
                } else {
                        /* someone else won, wait til they are done to break out */
                        while (!once_ctl->ran_once)
-                               cpu_relax();
+                               cpu_relax_vc(vcore_id());
                }
        }
 }