Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Mar 2008 02:56:25 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 137665 for review
Message-ID:  <200803140256.m2E2uPUo075018@repoman.freebsd.org>

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

Change 137665 by peter@peter_overcee on 2008/03/14 02:56:09

	Sigh. sched_userret() diverged.

Affected files ...

.. //depot/projects/bike_sched/sys/kern/sched_4bsd.c#21 edit
.. //depot/projects/bike_sched/sys/kern/sched_ule.c#21 edit
.. //depot/projects/bike_sched/sys/kern/subr_trap.c#8 edit

Differences ...

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

@@ -1246,7 +1246,6 @@
 	thread_unlock(td);
 }
 
-/* XXX removed */
 void
 sched_userret(struct thread *td)
 {

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

@@ -2023,9 +2023,28 @@
 	thread_unlock(td);
 }
 
-MISMERGE!
-p4 - you suck!
 /*
+ * 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;
 		tdq_setlowpri(TDQ_SELF(), td);
 		thread_unlock(td);
         }

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

@@ -124,26 +124,11 @@
 	 */
 	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.
+	 * Let the scheduler adjust our priority etc.
 	 */
-	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);
-	}
+	sched_userret(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?200803140256.m2E2uPUo075018>