From owner-cvs-all@FreeBSD.ORG Mon Jun 14 20:08:27 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F0A5116A4D0; Mon, 14 Jun 2004 20:08:27 +0000 (GMT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 984F043D4C; Mon, 14 Jun 2004 20:08:27 +0000 (GMT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id i5EK8Kqb023876; Mon, 14 Jun 2004 16:08:20 -0400 (EDT) Date: Mon, 14 Jun 2004 16:08:20 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Alfred Perlstein In-Reply-To: <20040614194836.GJ61448@elvis.mu.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Maxime Henrion cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/amd64/conf GENERIC X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jun 2004 20:08:28 -0000 On Mon, 14 Jun 2004, Alfred Perlstein wrote: > * Maxime Henrion [040614 12:40] wrote: > > Alfred Perlstein wrote: > > > * John Baldwin [040614 11:57] wrote: > > > > > > > > I'm betting it is just triggering a race. When I first did the adaptive > > > > mutexes I stress tested it (-j buildworld loops) on an ultra60, an > > > > alpha ds20, and a quad pii-xeon w/o any lockups. > > > > > > Just a side note, I think it's the Berkeley DB's recent code that > > > will spin a number of times based on the number of CPUs present in > > > the system. Meaning, it might make sense to spin more on a quad > > > than on a dual proc machine. It might be worth checking this out. > > > > What do you mean by spinning more? As far as I know, with adaptive > > mutexes, if some thread tries to lock a blocking mutex that is already > > held by another thread currently running on another CPU, then it spins > > instead of blocking, assuming the other thread will soon release the > > mutex. Obviously, this has more chances to happen if there are more > > CPUs in the system but I don't get what you mean here. > > > DbEnv::set_tas_spins > > Specify that test-and-set mutexes should spin tas_spins times without > blocking. The value defaults to 1 on uniprocessor systems and to 50 > times the number of processors on multiprocessor systems. > > The database environment's test-and-set spin count may also be set > using the environment's DB_CONFIG file. The syntax of the entry in > that file is a single line with the string "set_tas_spins", one or > more whitespace characters, and the number of spins. Because the > DB_CONFIG file is read when the database environment is opened, it > will silently overrule configuration done before that time. I think you're missing his point. Adaptive mutexes _do_ spin. The optimization is that they spin for only as long as the current owner is running (on another CPU). If the owner is not running or stops running, the thread blocks. The kernel knows about its threads, which thread owns a mutex, and whether that thread is running. And since the desire is for mutexes to be held for short periods, it is better for the requesting thread to spin as long as the owning thread is running. And conversely, it doesn't make sense to spin if the owning thread isn't running. -- DE