Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Jun 2002 20:34:33 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        Jonathan Lemon <jlemon@flugsvamp.com>
Cc:        dillon@apollo.backplane.com, hackers@freebsd.org
Subject:   Re: Bug in wakeup() (stable and current) ?
Message-ID:  <Pine.BSF.4.21.0206232023540.44896-100000@InterJet.elischer.org>
In-Reply-To: <20020623213443.K91821@prism.flugsvamp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0206232023540.44896-100000>