From owner-freebsd-hackers@FreeBSD.ORG Mon May 12 06:10:52 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A41591065674 for ; Mon, 12 May 2008 06:10:52 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outY.internet-mail-service.net (outy.internet-mail-service.net [216.240.47.248]) by mx1.freebsd.org (Postfix) with ESMTP id 8CC228FC43 for ; Mon, 12 May 2008 06:10:52 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Mon, 12 May 2008 12:44:40 -0700 Received: from julian-mac.elischer.org (localhost [127.0.0.1]) by idiom.com (Postfix) with ESMTP id A38CD2D600D; Sun, 11 May 2008 23:10:51 -0700 (PDT) Message-ID: <4827DF6B.6050101@elischer.org> Date: Sun, 11 May 2008 23:10:51 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 To: Elijah Buck References: <303eddcb0805111943t7c456c79l56f427c526d0b454@mail.gmail.com> In-Reply-To: <303eddcb0805111943t7c456c79l56f427c526d0b454@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: 4bsd fuzzy runq X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 May 2008 06:10:52 -0000 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"