Re: Noticable Delays Since Beta 3 (patch)

From: Sam Lawrance <boris_at_brooknet.com.au>
Date: Sat, 09 Oct 2004 16:37:44 +1000
On Sat, 2004-10-09 at 12:39 +0800, David Xu wrote:
> This can be done by set a flag in current threads td_pflags,
> for example, set TDP_WAKEPROC0, when the current thread
> leaves critical region, it can do wakeup(&proc0);

This is working for me against 5.3-BETA5.

Index: kern_synch.c
===================================================================
RCS file: /home/ncvs/FreeBSD/src/sys/kern/kern_synch.c,v
retrieving revision 1.257.2.3
diff -u -u -r1.257.2.3 kern_synch.c
--- kern_synch.c	18 Sep 2004 04:11:35 -0000	1.257.2.3
+++ kern_synch.c	9 Oct 2004 05:52:05 -0000
_at__at_ -249,8 +249,14 _at__at_
 wakeup(ident)
 	register void *ident;
 {
+	struct thread *td = curthread;
 
 	sleepq_broadcast(ident, SLEEPQ_MSLEEP, -1);
+	/* If swapped out processes were awakened bring them in */
+	if (td->td_pflags & TDP_WAKEPROC0) {
+		td->td_pflags &= ~TDP_WAKEPROC0;
+		sleepq_broadcast(&proc0, SLEEPQ_MSLEEP, -1);
+	}
 }
 
 /*
_at__at_ -360,6 +366,7 _at__at_
 setrunnable(struct thread *td)
 {
 	struct proc *p;
+	struct thread *ctd = curthread;
 
 	p = td->td_proc;
 	mtx_assert(&sched_lock, MA_OWNED);
_at__at_ -390,13 +397,7 _at__at_
 	if ((p->p_sflag & PS_INMEM) == 0) {
 		if ((p->p_sflag & PS_SWAPPINGIN) == 0) {
 			p->p_sflag |= PS_SWAPINREQ;
-#ifndef SMP
-			/*
-			 * XXX: Disabled on SMP due to a LOR between
-			 * sched_lock and the sleepqueue chain locks.
-			 */
-			wakeup(&proc0);
-#endif
+			ctd->td_pflags |= TDP_WAKEPROC0;
 		}
 	} else
 		sched_wakeup(td);
Index: proc.h
===================================================================
RCS file: /home/ncvs/FreeBSD/src/sys/sys/proc.h,v
retrieving revision 1.392.2.9
diff -u -u -r1.392.2.9 proc.h
--- proc.h	18 Sep 2004 04:11:35 -0000	1.392.2.9
+++ proc.h	9 Oct 2004 05:54:40 -0000
_at__at_ -370,7 +370,7 _at__at_
 #define	TDP_SA		0x00000080 /* A scheduler activation based thread. */
 #define	TDP_OWEPREEMPT	0x00000100 /* Thread has a pending preemption. */
 #define	TDP_OWEUPC	0x00000200 /* Call addupc() at next AST. */
-#define	TDP_UNUSED10	0x00000400 /* -- available-- */
+#define	TDP_WAKEPROC0	0x00000400 /* Want caller to wakeup(&proc0) */
 #define	TDP_CAN_UNBIND	0x00000800 /* Only temporarily bound. */
 #define	TDP_SCHED1	0x00001000 /* Reserved for scheduler private use */
 #define	TDP_SCHED2	0x00002000 /* Reserved for scheduler private use */
Received on Sat Oct 09 2004 - 04:35:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:16 UTC