From owner-p4-projects@FreeBSD.ORG Tue Jun 27 15:56:08 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E061916A55E; Tue, 27 Jun 2006 15:56:07 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BC0E616A53D; Tue, 27 Jun 2006 15:56:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9523D446D7; Tue, 27 Jun 2006 15:27:18 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k5RFRHwn008756; Tue, 27 Jun 2006 11:27:17 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Kip Macy Date: Tue, 27 Jun 2006 11:27:12 -0400 User-Agent: KMail/1.9.1 References: <200606270742.k5R7gCfT001310@repoman.freebsd.org> In-Reply-To: <200606270742.k5R7gCfT001310@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200606271127.13228.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Tue, 27 Jun 2006 11:27:17 -0400 (EDT) X-Virus-Scanned: ClamAV 0.87.1/1564/Mon Jun 26 10:55:16 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: kris@freebsd.org, Perforce Change Reviews Subject: Re: PERFORCE change 100121 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jun 2006 15:56:08 -0000 On Tuesday 27 June 2006 03:42, Kip Macy wrote: > http://perforce.freebsd.org/chv.cgi?CH=100121 > > Change 100121 by kmacy@kmacy_storage:sun4v_work_sleepq on 2006/06/27 07:41:14 > > avoid pointless turnstile contention if mutex owner is running Yes, I did this already in jhb_lock for both mutexes and rwlocks at BSDCan. Kris said my patch panic'd for him at BSDCan but I don't have an SMP machine I can test it on now to debug it. :( > > Affected files ... > > .. //depot/projects/kmacy_sun4v/src/sys/kern/kern_mutex.c#20 edit > > Differences ... > > ==== //depot/projects/kmacy_sun4v/src/sys/kern/kern_mutex.c#20 (text+ko) ==== > > @@ -176,7 +176,7 @@ > static int mutex_prof_maxrecords = MPROF_HASH_SIZE; > SYSCTL_INT(_debug_mutex_prof, OID_AUTO, maxrecords, CTLFLAG_RD, > &mutex_prof_maxrecords, 0, "Maximum number of profiling records"); > -int mutex_prof_rejected; > +int mutex_prof_rejected = 0; > SYSCTL_INT(_debug_mutex_prof, OID_AUTO, rejected, CTLFLAG_RD, > &mutex_prof_rejected, 0, "Number of rejected profiling records"); > static int mutex_prof_hashsize = MPROF_HASH_SIZE; > @@ -418,6 +418,16 @@ > > while (!_obtain_lock(m, tid)) { > lock_profile_obtain_lock_failed(&m->mtx_object, &contested); > +#if defined(SMP) && !defined(NO_ADAPTIVE_MUTEXES) > + /* > + * If the current owner of the lock is executing on another > + * CPU, spin instead of blocking. > + */ > + for (owner = mtx_owner(m); owner && TD_IS_RUNNING(owner); owner = mtx_owner(m)) > + cpu_spinwait(); > + if (mtx_unowned(m)) > + continue; > +#endif /* SMP && !NO_ADAPTIVE_MUTEXES */ > turnstile_lock(&m->mtx_object); > v = m->mtx_lock; > > @@ -425,7 +435,7 @@ > * Check if the lock has been released while spinning for > * the turnstile chain lock. > */ > - if (v == MTX_UNOWNED) { > + if (mtx_unowned(m)) { > turnstile_release(&m->mtx_object); > cpu_spinwait(); > continue; > @@ -837,6 +847,8 @@ > mtx_validate(m); > #endif > > + > + > /* Determine lock class and lock flags. */ > if (opts & MTX_SPIN) > class = &lock_class_mtx_spin; > -- John Baldwin