Author: nwhitehorn
Date: Tue Feb 10 00:55:42 2015
New Revision: 278481
URL: https://svnweb.freebsd.org/changeset/base/278481

Log:
  Set thread priorities on multithreaded CPUs so that threads holding a
  spinlock are high-priority and threads waiting for a spinlock are set to
  low priority.

Modified:
  head/sys/powerpc/aim/machdep.c
  head/sys/powerpc/include/cpu.h

Modified: head/sys/powerpc/aim/machdep.c
==============================================================================
--- head/sys/powerpc/aim/machdep.c      Tue Feb 10 00:48:51 2015        
(r278480)
+++ head/sys/powerpc/aim/machdep.c      Tue Feb 10 00:55:42 2015        
(r278481)
@@ -750,6 +750,7 @@ spinlock_enter(void)
 
        td = curthread;
        if (td->td_md.md_spinlock_count == 0) {
+               __asm __volatile("or 2,2,2"); /* Set high thread priority */
                msr = intr_disable();
                td->td_md.md_spinlock_count = 1;
                td->td_md.md_saved_msr = msr;
@@ -768,8 +769,10 @@ spinlock_exit(void)
        critical_exit();
        msr = td->td_md.md_saved_msr;
        td->td_md.md_spinlock_count--;
-       if (td->td_md.md_spinlock_count == 0)
+       if (td->td_md.md_spinlock_count == 0) {
                intr_restore(msr);
+               __asm __volatile("or 6,6,6"); /* Set normal thread priority */
+       }
 }
 
 int db_trap_glue(struct trapframe *);          /* Called from trap_subr.S */

Modified: head/sys/powerpc/include/cpu.h
==============================================================================
--- head/sys/powerpc/include/cpu.h      Tue Feb 10 00:48:51 2015        
(r278480)
+++ head/sys/powerpc/include/cpu.h      Tue Feb 10 00:55:42 2015        
(r278481)
@@ -88,7 +88,7 @@ get_cyclecount(void)
 }
 
 #define        cpu_getstack(td)        ((td)->td_frame->fixreg[1])
-#define        cpu_spinwait()          /* nothing */
+#define        cpu_spinwait()          __asm __volatile("or 27,27,27") /* 
yield */
 
 extern char btext[];
 extern char etext[];
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to