From owner-cvs-src@FreeBSD.ORG Sun Apr 6 20:08:51 2008 Return-Path: Delivered-To: cvs-src@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83CBC106566B; Sun, 6 Apr 2008 20:08:51 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 664E78FC19; Sun, 6 Apr 2008 20:08:51 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m36K8plH014345; Sun, 6 Apr 2008 20:08:51 GMT (envelope-from attilio@repoman.freebsd.org) Received: (from attilio@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m36K8prN014344; Sun, 6 Apr 2008 20:08:51 GMT (envelope-from attilio) Message-Id: <200804062008.m36K8prN014344@repoman.freebsd.org> From: Attilio Rao Date: Sun, 6 Apr 2008 20:08:51 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/sys/fs/unionfs union_subr.c src/sys/kern kern_lock.c src/sys/sys _lockmgr.h _stack.h lockmgr.h proc.h sleepqueue.h stack.h vnode.h src/sys/ufs/ffs ffs_softdep.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 06 Apr 2008 20:08:51 -0000 attilio 2008-04-06 20:08:51 UTC FreeBSD src repository Modified files: sys/fs/unionfs union_subr.c sys/kern kern_lock.c sys/sys lockmgr.h proc.h sleepqueue.h stack.h vnode.h sys/ufs/ffs ffs_softdep.c Added files: sys/sys _lockmgr.h _stack.h Log: Optimize lockmgr in order to get rid of the pool mutex interlock, of the state transitioning flags and of msleep(9) callings. Use, instead, an algorithm very similar to what sx(9) and rwlock(9) alredy do and direct accesses to the sleepqueue(9) primitive. In order to avoid writer starvation a mechanism very similar to what rwlock(9) uses now is implemented, with the correspective per-thread shared lockmgrs counter. This patch also adds 2 new functions to lockmgr KPI: lockmgr_rw() and lockmgr_args_rw(). These two are like the 2 "normal" versions, but they both accept a rwlock as interlock. In order to realize this, the general lockmgr manager function "__lockmgr_args()" has been implemented through the generic lock layer. It supports all the blocking primitives, but currently only these 2 mappers live. The patch drops the support for WITNESS atm, but it will be probabilly added soon. Also, there is a little race in the draining code which is also present in the current CVS stock implementation: if some sharers, once they wakeup, are in the runqueue they can contend the lock with the exclusive drainer. This is hard to be fixed but the now committed code mitigate this issue a lot better than the (past) CVS version. In addition assertive KA_HELD and KA_UNHELD have been made mute assertions because they are dangerous and they will be nomore supported soon. In order to avoid namespace pollution, stack.h is splitted into two parts: one which includes only the "struct stack" definition (_stack.h) and one defining the KPI. In this way, newly added _lockmgr.h can just include _stack.h. Kernel ABI results heavilly changed by this commit (the now committed version of "struct lock" is a lot smaller than the previous one) and KPI results broken by lockmgr_rw() / lockmgr_args_rw() introduction, so manpages and __FreeBSD_version will be updated accordingly. Tested by: kris, pho, jeff, danger Reviewed by: jeff Sponsored by: Google, Summer of Code program 2007 Revision Changes Path 1.100 +4 -5 src/sys/fs/unionfs/union_subr.c 1.128 +809 -627 src/sys/kern/kern_lock.c 1.1 +49 -0 src/sys/sys/_lockmgr.h (new) 1.1 +39 -0 src/sys/sys/_stack.h (new) 1.68 +137 -188 src/sys/sys/lockmgr.h 1.510 +2 -1 src/sys/sys/proc.h 1.14 +1 -0 src/sys/sys/sleepqueue.h 1.5 +1 -6 src/sys/sys/stack.h 1.335 +4 -2 src/sys/sys/vnode.h 1.223 +2 -2 src/sys/ufs/ffs/ffs_softdep.c