Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Dec 2007 23:07:33 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 129914 for review
Message-ID:  <200712012307.lB1N7XkY091314@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=129914

Change 129914 by peter@peter_daintree on 2007/12/01 23:07:09

	move common code

Affected files ...

.. //depot/projects/bike_sched/sys/kern/sched_4bsd.c#10 edit
.. //depot/projects/bike_sched/sys/kern/sched_ule.c#9 edit
.. //depot/projects/bike_sched/sys/kern/subr_trap.c#5 edit

Differences ...

==== //depot/projects/bike_sched/sys/kern/sched_4bsd.c#10 (text+ko) ====

@@ -1237,28 +1237,6 @@
 }
 
 void
-sched_userret(struct thread *td)
-{
-	/*
-	 * XXX we cheat slightly on the locking here to avoid locking in
-	 * the usual case.  Setting td_priority here is essentially an
-	 * incomplete workaround for not setting it properly elsewhere.
-	 * Now that some interrupt handlers are threads, not setting it
-	 * properly elsewhere can clobber it in the window between setting
-	 * it here and returning to user mode, so don't waste time setting
-	 * it perfectly here.
-	 */
-	KASSERT((td->td_flags & TDF_BORROWING) == 0,
-	    ("thread with borrowed priority returning to userland"));
-	if (td->td_priority != td->td_user_pri) {
-		thread_lock(td);
-		td->td_priority = td->td_user_pri;
-		td->td_base_pri = td->td_user_pri;
-		thread_unlock(td);
-	}
-}
-
-void
 sched_bind(struct thread *td, int cpu)
 {
 	struct td_sched *ts;

==== //depot/projects/bike_sched/sys/kern/sched_ule.c#9 (text+ko) ====

@@ -2110,32 +2110,6 @@
 }
 
 /*
- * Fix priorities on return to user-space.  Priorities may be elevated due
- * to static priorities in msleep() or similar.
- */
-void
-sched_userret(struct thread *td)
-{
-	/*
-	 * XXX we cheat slightly on the locking here to avoid locking in  
-	 * the usual case.  Setting td_priority here is essentially an
-	 * incomplete workaround for not setting it properly elsewhere.
-	 * Now that some interrupt handlers are threads, not setting it
-	 * properly elsewhere can clobber it in the window between setting
-	 * it here and returning to user mode, so don't waste time setting
-	 * it perfectly here.
-	 */
-	KASSERT((td->td_flags & TDF_BORROWING) == 0,
-	    ("thread with borrowed priority returning to userland"));
-	if (td->td_priority != td->td_user_pri) {
-		thread_lock(td);
-		td->td_priority = td->td_user_pri;
-		td->td_base_pri = td->td_user_pri;
-		thread_unlock(td);
-        }
-}
-
-/*
  * Handle a stathz tick.  This is really only relevant for timeshare
  * threads.
  */

==== //depot/projects/bike_sched/sys/kern/subr_trap.c#5 (text+ko) ====

@@ -120,8 +120,26 @@
 	if (p->p_flag & P_PROFIL)
 		addupc_task(td, TRAPF_PC(frame), td->td_pticks * psratio);
 
+	/*
+	 * Fix priorities on return to user-space.  Priorities may be elevated due
+	 * to static priorities in msleep() or similar.
+	 *
+	 * XXX we cheat slightly on the locking here to avoid locking in
+	 * the usual case.  Setting td_priority here is essentially an
+	 * incomplete workaround for not setting it properly elsewhere.
+	 * Now that some interrupt handlers are threads, not setting it
+	 * properly elsewhere can clobber it in the window between setting
+	 * it here and returning to user mode, so don't waste time setting
+	 * it perfectly here.
+	 */
 	KASSERT((td->td_flags & TDF_BORROWING) == 0,
 	    ("userret: thread with borrowed priority returning to userland"));
+	if (td->td_priority != td->td_user_pri) {
+		thread_lock(td);
+		td->td_priority = td->td_user_pri;
+		td->td_base_pri = td->td_user_pri;
+		thread_unlock(td);
+	}
 	KASSERT(td->td_locks == 0,
 	    ("userret: Returning with %d locks held.", td->td_locks));
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712012307.lB1N7XkY091314>