From owner-freebsd-arch Sun Jan 26 12:46: 2 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 005C637B405; Sun, 26 Jan 2003 12:45:58 -0800 (PST) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 29B5243E4A; Sun, 26 Jan 2003 12:45:58 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.12.6/8.12.6) with ESMTP id h0QKjt0i067309; Sun, 26 Jan 2003 12:45:55 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.6/8.12.6/Submit) id h0QKjsVc067308; Sun, 26 Jan 2003 12:45:54 -0800 (PST) Date: Sun, 26 Jan 2003 12:45:54 -0800 (PST) From: Matthew Dillon Message-Id: <200301262045.h0QKjsVc067308@apollo.backplane.com> To: Jeff Roberson Cc: Julian Elischer , Steve Kargl , Robert Watson , Gary Jennejohn , Subject: Re: New scheduler - ULE performance w/ cpu stealing References: <20030126040154.A64928-100000@mail.chesapeake.net> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I added cpu-stealing code to ULE and it seems to have made a huge difference. Perhaps you missed something in your local patch set. Here are the results: /usr/bin/time make -j 8 buildworld 4BSD - Original scheduler 2414.84 real 2648.92 user 758.28 sys 2399.05 real 2647.84 user 757.78 sys ULE - 3435.42 real 2500.73 user 581.20 sys 3343.95 real 2501.86 user 581.67 sys ULE - With cpu stealing code 2489.76 real 2610.33 user 659.74 sys <<<<<<<<<<<<<<<<<< Next I am going to try removing sched_pickcpu(), but I don't expect it to improve things (nor do I expect the removal to make things worse). -Matt Index: sched_ule.c =================================================================== RCS file: /home/ncvs/src/sys/kern/sched_ule.c,v retrieving revision 1.1 diff -u -r1.1 sched_ule.c --- sched_ule.c 26 Jan 2003 05:23:15 -0000 1.1 +++ sched_ule.c 26 Jan 2003 20:42:47 -0000 @@ -53,6 +53,9 @@ /* XXX This is bogus compatability crap for ps */ static fixpt_t ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */ SYSCTL_INT(_kern, OID_AUTO, ccpu, CTLFLAG_RD, &ccpu, 0, ""); +static int sched_stealcpu = 1; +SYSCTL_INT(_kern, OID_AUTO, sched_stealcpu, CTLFLAG_RW, &sched_stealcpu, 0, + "Ok to steal KSEs from another cpu (0=disabled, 1=normal)"); static void sched_setup(void *dummy); SYSINIT(sched_setup, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, sched_setup, NULL) @@ -554,9 +557,26 @@ cpu = PCPU_GET(cpuid); kseq = &kseq_cpu[cpu]; - if (runq_check(kseq->ksq_curr) == 0) - return (runq_check(kseq->ksq_next)); - return (1); + if (runq_check(kseq->ksq_curr)) + return(1); + if (runq_check(kseq->ksq_next)) + return(1); + +#ifdef SMP + /* + * Check other cpus for runnable tasks + */ + if (sched_stealcpu) { + for (cpu = 0; cpu < mp_ncpus; ++cpu) { + kseq = &kseq_cpu[cpu]; + if (runq_check(kseq->ksq_curr)) + return(1); + if (runq_check(kseq->ksq_next)) + return(1); + } + } +#endif + return (0); } void @@ -573,30 +593,53 @@ } } +static __inline struct kse * -sched_choose(void) +sched_choose_kseq(struct kseq *kseq) { - struct kseq *kseq; struct kse *ke; struct runq *swap; - int cpu; - cpu = PCPU_GET(cpuid); - kseq = &kseq_cpu[cpu]; - if ((ke = runq_choose(kseq->ksq_curr)) == NULL) { swap = kseq->ksq_curr; kseq->ksq_curr = kseq->ksq_next; kseq->ksq_next = swap; ke = runq_choose(kseq->ksq_curr); } + return(ke); +} + +struct kse * +sched_choose(void) +{ + struct kseq *kseq; + struct kse *ke; + int cpu, i; + + cpu = PCPU_GET(cpuid); + kseq = &kseq_cpu[cpu]; + + ke = sched_choose_kseq(kseq); if (ke) { runq_remove(ke->ke_runq, ke); ke->ke_state = KES_THREAD; } - - return (ke); +#ifdef SMP + else if (sched_stealcpu) { + for (i = mp_ncpus - 1; ke == NULL && i; --i) { + cpu = (cpu + 1) % mp_ncpus; + kseq = &kseq_cpu[cpu]; + ke = sched_choose_kseq(kseq); + } + if (ke) { + runq_remove(ke->ke_runq, ke); + ke->ke_state = KES_THREAD; + } + } +#endif + return(ke); } + void sched_add(struct kse *ke) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message