From owner-freebsd-current@FreeBSD.ORG Mon May 10 07:31:57 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B4A9A16A4CE for ; Mon, 10 May 2004 07:31:57 -0700 (PDT) Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id CDEBC43D49 for ; Mon, 10 May 2004 07:31:56 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86])i4AEVp5v017231; Tue, 11 May 2004 00:31:51 +1000 Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) i4AEVnI2006605; Tue, 11 May 2004 00:31:50 +1000 Date: Tue, 11 May 2004 00:31:49 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Julian Elischer In-Reply-To: Message-ID: <20040511001835.D2697@gamplex.bde.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: FreeBSD current users Subject: Re: RFC for small change to 4bsd scheduler.. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2004 14:31:57 -0000 On Sun, 9 May 2004, Julian Elischer wrote: > in the following code: > struct kse * > sched_choose(void) > { > struct kse *ke; > struct runq *rq; > > #ifdef SMP > struct kse *kecpu; > > rq = &runq; > ke = runq_choose(&runq); > kecpu = runq_choose(&runq_pcpu[PCPU_GET(cpuid)]); > > if (ke == NULL || > (kecpu != NULL && > **>>>> kecpu->ke_thread->td_priority < > ke->ke_thread->td_priority)) { > CTR2(KTR_4BSD, "choosing kse %p from pcpu runq %d", kecpu, > PCPU_GET(cpuid)); > ke = kecpu; > rq = &runq_pcpu[PCPU_GET(cpuid)]; > } else { > CTR1(KTR_4BSD, "choosing kse %p from main runq", ke); > } > > > > I think it would be better to have "<=" instead of "<" > > I think the current code will make processes of equal priority thrash > processors if one is on the pcpu list and teh other is on the general > queue. as it is the pcpu process will only ever run when there is > nothing of teh same priority to run.. This seems reasonable. Whether it is really better (or if the pcpu runq's do anything at all) can probably be tested easily. Maybe it matters more for more CPUs. I haven't seen any benchmark results for this. You might also want to compare priorities after dividing by RQ_PPQ (4) so that certain small differences in priorities have no effect, just like they would for a single runq. > maybe there should be code to give such a case a 50/50 chance or > something? Priority growth and decay should handle this OK, at least for non-short- lived processes. You wouldn't want a 50/50 chance on every call or anything close to that since it would be thrashing. Bruce