From owner-cvs-src@FreeBSD.ORG Tue Nov 11 14:07:31 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 715EA16A4CF; Tue, 11 Nov 2003 14:07:31 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9247C43FE1; Tue, 11 Nov 2003 14:07:30 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hABM7UXJ006145; Tue, 11 Nov 2003 14:07:30 -0800 (PST) (envelope-from jhb@repoman.freebsd.org) Received: (from jhb@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hABM7UAu006144; Tue, 11 Nov 2003 14:07:30 -0800 (PST) (envelope-from jhb) Message-Id: <200311112207.hABM7UAu006144@repoman.freebsd.org> From: John Baldwin Date: Tue, 11 Nov 2003 14:07:30 -0800 (PST) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/sys/conf files src/sys/kern kern_mutex.c kern_thread.c subr_turnstile.c subr_witness.c src/sys/sys _mutex.h filedesc.h proc.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Nov 2003 22:07:31 -0000 jhb 2003/11/11 14:07:30 PST FreeBSD src repository Modified files: sys/conf files sys/kern kern_mutex.c kern_thread.c subr_turnstile.c subr_witness.c sys/sys _mutex.h filedesc.h proc.h Log: Add an implementation of turnstiles and change the sleep mutex code to use turnstiles to implement blocking isntead of implementing a thread queue directly. These turnstiles are somewhat similar to those used in Solaris 7 as described in Solaris Internals but are also different. Turnstiles do not come out of a fixed-sized pool. Rather, each thread is assigned a turnstile when it is created that it frees when it is destroyed. When a thread blocks on a lock, it donates its turnstile to that lock to serve as queue of blocked threads. The queue associated with a given lock is found by a lookup in a simple hash table. The turnstile itself is protected by a lock associated with its entry in the hash table. This means that sched_lock is no longer needed to contest on a mutex. Instead, sched_lock is only used when manipulating run queues or thread priorities. Turnstiles also implement priority propagation inherently. Currently turnstiles only support mutexes. Eventually, however, turnstiles may grow two queue's to support a non-sleepable reader/writer lock implementation. For more details, see the comments in sys/turnstile.h and kern/subr_turnstile.c. The two primary advantages from the turnstile code include: 1) the size of struct mutex shrinks by four pointers as it no longer stores the thread queue linkages directly, and 2) less contention on sched_lock in SMP systems including the ability for multiple CPUs to contend on different locks simultaneously (not that this last detail is necessarily that much of a big win). Note that 1) means that this commit is a kernel ABI breaker, so don't mix old modules with a new kernel and vice versa. Tested on: i386 SMP, sparc64 SMP, alpha SMP Revision Changes Path 1.848 +1 -0 src/sys/conf/files 1.132 +39 -225 src/sys/kern/kern_mutex.c 1.162 +3 -0 src/sys/kern/kern_thread.c 1.132 +471 -758 src/sys/kern/subr_turnstile.c 1.162 +3 -3 src/sys/kern/subr_witness.c 1.10 +0 -2 src/sys/sys/_mutex.h 1.52 +2 -0 src/sys/sys/filedesc.h 1.357 +8 -4 src/sys/sys/proc.h