From owner-svn-src-head@FreeBSD.ORG Wed Apr 29 19:01:27 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79D5210656BD; Wed, 29 Apr 2009 19:01:27 +0000 (UTC) (envelope-from andreast-list@fgznet.ch) Received: from smtp.fgznet.ch (mail.fgznet.ch [81.92.96.47]) by mx1.freebsd.org (Postfix) with ESMTP id 1227A8FC17; Wed, 29 Apr 2009 19:01:26 +0000 (UTC) (envelope-from andreast-list@fgznet.ch) Received: from wolfram.andreas.nets ([91.190.8.131]) by smtp.fgznet.ch (8.13.8/8.13.8/Submit_SMTPAUTH) with ESMTP id n3TJ1Nk0015236; Wed, 29 Apr 2009 21:01:23 +0200 (CEST) (envelope-from andreast-list@fgznet.ch) Message-ID: <49F8A403.6070209@fgznet.ch> Date: Wed, 29 Apr 2009 21:01:23 +0200 From: Andreas Tobler User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302) MIME-Version: 1.0 To: Kostik Belousov References: <200904290315.n3T3FiJW067558@svn.freebsd.org> <20090429165417.GG40751@deviant.kiev.zoral.com.ua> In-Reply-To: <20090429165417.GG40751@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.64 on 81.92.96.47 Cc: svn-src-head@freebsd.org, Jeff Roberson , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r191643 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Apr 2009 19:01:28 -0000 Kostik Belousov wrote: > On Wed, Apr 29, 2009 at 03:15:44AM +0000, Jeff Roberson wrote: >> Author: jeff >> Date: Wed Apr 29 03:15:43 2009 >> New Revision: 191643 >> URL: http://svn.freebsd.org/changeset/base/191643 >> >> Log: >> - Remove the bogus idle thread state code. This may have a race in it >> and it only optimized out an ipi or mwait in very few cases. >> - Skip the adaptive idle code when running on SMT or HTT cores. This >> just wastes cpu time that could be used on a busy thread on the same >> core. >> - Rename CG_FLAG_THREAD to CG_FLAG_SMT to be more descriptive. Re-use >> CG_FLAG_THREAD to mean SMT or HTT. >> >> Sponsored by: Nokia >> >> Modified: >> head/sys/kern/sched_ule.c >> head/sys/kern/subr_smp.c >> head/sys/sys/smp.h > > Now I see a reason why it is better #ifdef SMP the code that uses CG_FLAG_*. > Also, we should check for tdq_cg != NULL in one more place. > > See the patch below, instead of exposing CG_FLAG_* for !SMP configs. > > diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c > index 680572d..fe3a119 100644 > --- a/sys/kern/sched_ule.c > +++ b/sys/kern/sched_ule.c > @@ -891,6 +891,7 @@ tdq_move(struct tdq *from, struct tdq *to) > return (1); > } > > +#ifdef SMP > /* > * This tdq has idled. Try to steal a thread from another cpu and switch > * to it. > @@ -947,6 +948,7 @@ tdq_idled(struct tdq *tdq) > spinlock_exit(); > return (1); > } > +#endif > > /* > * Notify a remote cpu of new work. Sends an IPI if criteria are met. > @@ -2525,7 +2527,9 @@ sched_idletd(void *dummy) > struct thread *td; > struct tdq *tdq; > int switchcnt; > +#ifdef SMP > int i; > +#endif > > mtx_assert(&Giant, MA_NOTOWNED); > td = curthread; > @@ -2543,7 +2547,9 @@ sched_idletd(void *dummy) > * loops while on SMT machines as this simply steals > * cycles from cores doing useful work. > */ > - if ((tdq->tdq_cg->cg_flags & CG_FLAG_THREAD) == 0 && > +#ifdef SMP > + if (tdq->tdq_cg != NULL && > + (tdq->tdq_cg->cg_flags & CG_FLAG_THREAD) == 0 && > switchcnt > sched_idlespinthresh) { > for (i = 0; i < sched_idlespins; i++) { > if (tdq->tdq_load) > @@ -2551,6 +2557,7 @@ sched_idletd(void *dummy) > cpu_spinwait(); > } > } > +#endif > switchcnt = tdq->tdq_switchcnt + tdq->tdq_oldswitchcnt; > if (tdq->tdq_load == 0) > cpu_idle(switchcnt > 1); Fyi, with the above patch I can build amd64, sparc64 and powerpc kernel. Andreas