From owner-freebsd-hackers Sun Jun 23 19:35:49 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from prism.flugsvamp.com (66-191-112-47.mad.wi.charter.com [66.191.112.47]) by hub.freebsd.org (Postfix) with ESMTP id 80F6A37B403 for ; Sun, 23 Jun 2002 19:35:44 -0700 (PDT) Received: (from jlemon@localhost) by prism.flugsvamp.com (8.11.6/8.11.6) id g5O2Yh657125; Sun, 23 Jun 2002 21:34:43 -0500 (CDT) (envelope-from jlemon) Date: Sun, 23 Jun 2002 21:34:43 -0500 From: Jonathan Lemon To: Julian Elischer Cc: Jonathan Lemon , dillon@apollo.backplane.com, hackers@freebsd.org Subject: Re: Bug in wakeup() (stable and current) ? Message-ID: <20020623213443.K91821@prism.flugsvamp.com> References: <200206232158.g5NLw9c49030@prism.flugsvamp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre2i In-Reply-To: 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 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