From owner-svn-src-all@FreeBSD.ORG Wed Apr 29 23:31:04 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 26973106566C; Wed, 29 Apr 2009 23:31:04 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.239]) by mx1.freebsd.org (Postfix) with ESMTP id D87508FC1E; Wed, 29 Apr 2009 23:31:03 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: by rv-out-0506.google.com with SMTP id k40so1205292rvb.43 for ; Wed, 29 Apr 2009 16:31:03 -0700 (PDT) Received: by 10.140.144.1 with SMTP id r1mr235619rvd.131.1241046338502; Wed, 29 Apr 2009 16:05:38 -0700 (PDT) Received: from ?10.0.1.198? (udp016664uds.hawaiiantel.net [72.235.41.117]) by mx.google.com with ESMTPS id f21sm3380529rvb.25.2009.04.29.16.05.35 (version=SSLv3 cipher=RC4-MD5); Wed, 29 Apr 2009 16:05:37 -0700 (PDT) Date: Wed, 29 Apr 2009 13:07:40 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: Kostik Belousov In-Reply-To: <20090429165417.GG40751@deviant.kiev.zoral.com.ua> Message-ID: References: <200904290315.n3T3FiJW067558@svn.freebsd.org> <20090429165417.GG40751@deviant.kiev.zoral.com.ua> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed 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-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Apr 2009 23:31:04 -0000 On Wed, 29 Apr 2009, 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. Thank you kan. I did something slightly different so we can retain the adaptive idling on UP. Thanks, Jeff > > 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); >