Re: Noticable Delays Since Beta 3 (possible cause)

From: Sam Lawrance <boris_at_brooknet.com.au>
Date: Mon, 11 Oct 2004 23:07:32 +1000
Folks,

On Mon, 2004-10-11 at 04:55 -0400, Robert Watson wrote:
> On Sat, 9 Oct 2004, Sam Lawrance wrote:
> 
> > I'm sorry, that patch was missing paths.. this one:
> > 
> > http://sam.stral.net/freebsd/wakeupdelay-patch
> > 
> > is much nicer. 
> 
> Are there plans to get this patch merged for 5.3?  I was chatting with
> Brian yesterday about the accept locking issue in sofree() and he was
> indicating that he was seeing symptoms very much like the ones described
> in this thread (long wakeup times for keypresses, etc).

I just noticed that the messages David sent to me and the list have yet
to make it through to the list. One was a patch which puts the wakeup in
the critical_exit where he suggested (but I didn't understand :). Here
it is:

Index: sys/proc.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/proc.h,v
retrieving revision 1.409
diff -u -r1.409 proc.h
--- sys/proc.h	6 Oct 2004 00:40:40 -0000	1.409
+++ sys/proc.h	9 Oct 2004 10:59:50 -0000
_at__at_ -369,7 +369,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 /* Wants 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 */
Index: kern/kern_switch.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_switch.c,v
retrieving revision 1.97
diff -u -r1.97 kern_switch.c
--- kern/kern_switch.c	5 Oct 2004 22:03:10 -0000	1.97
+++ kern/kern_switch.c	9 Oct 2004 10:59:50 -0000
_at__at_ -449,6 +449,10 _at__at_
 	KASSERT(td->td_critnest != 0,
 	    ("critical_exit: td_critnest == 0"));
 	if (td->td_critnest == 1) {
+		if (td->td_pflags & TDP_WAKEPROC0) {
+			td->td_pflags &= ~TDP_WAKEPROC0;
+			wakeup(&proc0);
+		}
 #ifdef PREEMPTION
 		mtx_assert(&sched_lock, MA_NOTOWNED);
 		if (td->td_pflags & TDP_OWEPREEMPT) {
Index: kern/kern_synch.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_synch.c,v
retrieving revision 1.262
diff -u -r1.262 kern_synch.c
--- kern/kern_synch.c	5 Oct 2004 18:51:11 -0000	1.262
+++ kern/kern_synch.c	9 Oct 2004 10:59:51 -0000
_at__at_ -390,13 +390,13 _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.
+			 * due to a LOR between sched_lock and
+			 * the sleepqueue chain locks, delay
+			 * wakeup proc0 until thread leaves
+			 * critical region.
 			 */
-			wakeup(&proc0);
-#endif
+			curthread->td_pflags |= TDP_WAKEPROC0;
 		}
 	} else
 		sched_wakeup(td);
Received on Mon Oct 11 2004 - 11:05:06 UTC

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