From owner-freebsd-hackers Sun Jun 23 20:40:19 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from sccrmhc03.attbi.com (sccrmhc03.attbi.com [204.127.202.63]) by hub.freebsd.org (Postfix) with ESMTP id ED48637B401 for ; Sun, 23 Jun 2002 20:40:11 -0700 (PDT) Received: from InterJet.elischer.org ([12.232.206.8]) by sccrmhc03.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020624034009.XVYZ20219.sccrmhc03.attbi.com@InterJet.elischer.org>; Mon, 24 Jun 2002 03:40:09 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id UAA49879; Sun, 23 Jun 2002 20:34:35 -0700 (PDT) Date: Sun, 23 Jun 2002 20:34:33 -0700 (PDT) From: Julian Elischer To: Jonathan Lemon Cc: dillon@apollo.backplane.com, hackers@freebsd.org Subject: Re: Bug in wakeup() (stable and current) ? In-Reply-To: <20020623213443.K91821@prism.flugsvamp.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG yep Matt added a similar patch to the KSE branch... the debug stuff I added to TAILQ adds (when compiled in) info on the last 2 places to to linkage operations.. it also initialises the pointers on elements to -1 it's great for helping find places that are screwing up linkages e.g. in the KSE run queues which are quite complicated :-) On Sun, 23 Jun 2002, Jonathan Lemon wrote: > On Sun, Jun 23, 2002 at 06:42:43PM -0700, Julian Elischer wrote: > > > > On Sun, 23 Jun 2002, Jonathan Lemon wrote: > > > The code works simply because it relies TAILQ_REMOVE() not changing > > > the tqe_next pointer. I suppose that this should either be documented, > > > or the loop changed back to use a temp variable: > > > > > > for (td = TAILQ_FIRST(qp); td != NULL; td = tdq) { > > > tdq = TAILQ_NEXT(td, td_slpq); > > > ... > > > } > > > > I just added debug code in the TAILQ code that sets the forward pointor > > to -1. Since Matt had this it's possible that this is what hit him? > > Most definitely. If you reset tqe_next, the code stops working. Try > the patch below. > -- > Jonathan > > > Index: kern_synch.c > =================================================================== > RCS file: /ncvs/src/sys/kern/kern_synch.c,v > retrieving revision 1.175 > diff -u -r1.175 kern_synch.c > --- kern_synch.c 7 Jun 2002 05:39:16 -0000 1.175 > +++ kern_synch.c 24 Jun 2002 02:42:40 -0000 > @@ -605,13 +605,14 @@ > register void *ident; > { > register struct slpquehead *qp; > - register struct thread *td; > + register struct thread *td, *tdn; > struct proc *p; > > mtx_lock_spin(&sched_lock); > qp = &slpque[LOOKUP(ident)]; > restart: > - TAILQ_FOREACH(td, qp, td_slpq) { > + for (td = TAILQ_FIRST(qp); td != NULL; td = tdn) { > + tdn = TAILQ_NEXT(td, td_slpq); > p = td->td_proc; > if (td->td_wchan == ident) { > TAILQ_REMOVE(qp, td, td_slpq); > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message