From owner-freebsd-smp Mon Jun 26 20: 9:44 2000 Delivered-To: freebsd-smp@freebsd.org Received: from mailhost.iprg.nokia.com (mailhost.iprg.nokia.com [205.226.5.12]) by hub.freebsd.org (Postfix) with ESMTP id 0902237BDF4 for ; Mon, 26 Jun 2000 20:09:40 -0700 (PDT) (envelope-from jre@iprg.nokia.com) Received: from darkstar.iprg.nokia.com (darkstar.iprg.nokia.com [205.226.5.69]) by mailhost.iprg.nokia.com (8.9.3/8.9.3-GLGS) with ESMTP id UAA20838; Mon, 26 Jun 2000 20:09:31 -0700 (PDT) Received: (from root@localhost) by darkstar.iprg.nokia.com (8.9.3/8.9.3-VIRSCAN) id UAA09929; Mon, 26 Jun 2000 20:09:29 -0700 X-Virus-Scanned: Mon, 26 Jun 2000 20:09:29 -0700 Nokia Silicon Valley Email Exploit Scanner Received: from (radio.iprg.nokia.com [205.226.1.150]) by darkstar.iprg.nokia.com SMTP/WTS (12.69) xma009794; Mon, 26 Jun 00 20:09:24 -0700 Message-ID: <39581AE5.C157F592@iprg.nokia.com> Date: Mon, 26 Jun 2000 20:09:25 -0700 From: Joe Eykholt Organization: Nokia IPRG X-Mailer: Mozilla 4.7 [en] (X11; I; FreeBSD 2.2.6-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Luoqi Chen Cc: eischen@vigrid.com, smp@FreeBSD.ORG Subject: Re: SMP meeting summary References: <200006270214.e5R2Exu13573@lor.watermarkgroup.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Luoqi Chen wrote: > > > In regards to turnstiles, each kernel thread is born with its own > > turnstile. When it blocks on a mutex that doesn't have any waiters > > (no turnstile allocated to it), it uses the threads turnstile. If > > the mutex already has a turnstile (there are other waiters), then > > the threads turnstile is added to the system (per-CPU?) pool of > > turnstiles. When the thread wakes up and acquires the mutex, it > > takes a turnstile back from the turnstile pool. Turnstiles are > > also used for read/write locks. > > > > -- > > Dan Eischen > > > Does anyone know why a turnstile structure is used, instead of a sleep > queue embedded in the mutex structure? With cache line size of 16/32 > bytes, the latter seems to be more advantageous. Its basically for lock size, to keep the locks really small so each lock inside other structures wouldn't get too large. The cache line size doesn't matter so much as the size of the other structures that contain locks. But, if you make structures large (by including large locks in them) they won't fit in cache lines so well. In a fine-grained implementation, lots of small structures need locking. You only need turnstiles for the locks that are being waited on, but the turnstile can't be in the thread (or process) that's doing the waiting. There are a lot more mutexes and r/w locks than there are potential waiters, so its a big waste of space to have all the data per lock. The main thing is to not block on mutexes very frequently. The cost of blocking is secondary if the frequency is low enough. There are a lot of considerations and a lot of trial-and-error involved in getting a balanced (not perfect) implementation. Joe Eykholt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message