Date: Sun, 11 May 2008 23:10:51 -0700 From: Julian Elischer <julian@elischer.org> To: Elijah Buck <elijah.buck@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: 4bsd fuzzy runq Message-ID: <4827DF6B.6050101@elischer.org> In-Reply-To: <303eddcb0805111943t7c456c79l56f427c526d0b454@mail.gmail.com> References: <303eddcb0805111943t7c456c79l56f427c526d0b454@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Elijah Buck wrote: > Hi, > > I'm looking at the code for 4bsd fuzzy run queues in kern_switch.c > > The relevant bit: > > if (fuzz > 1) { > int count = fuzz; > int cpu = PCPU_GET(cpuid); > struct thread *td2; > td2 = td = TAILQ_FIRST(rqh); > while (count-- && td2) { > if (td->td_lastcpu == cpu) { this should be td2. The bug is mine.. and I wondered why the code commited never had the same result as that I tested in another tree. > td = td2; > break; > } > td2 = TAILQ_NEXT(td2, td_runq); > } > ...return(td) > The purpose of this code appears to be to look through the runq to a depth > defined by fuzz for a thread that was last run on the current cpu. > > Here are the cases I see: > 1.) if (td_lastcpu == cpu) on the first iteration then TAILQ_FIRST(rqh) is > the selected thread (because of the break). > 2.) if (td_lastcpu != cpu) on the first iteration then td is never set > again, and so (td_lastcpu != cpu) is always true. So, again, > TAILQ_FIRST(rqh) will be selected (because count will reach 0). > > Which doesn't seem right (since that's what the else clause does). What am I > missing here? > > Thanks, > Elijah > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4827DF6B.6050101>