aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/_lockmgr.h
diff options
context:
space:
mode:
authorAttilio Rao <attilio@FreeBSD.org>2008-04-06 20:08:51 +0000
committerAttilio Rao <attilio@FreeBSD.org>2008-04-06 20:08:51 +0000
commit047dd67e96bdb9e64f9f61b42ffb72bb5d4387b9 (patch)
tree2d6f3d40588b2302cacf1c1cc30a8c323b74b5e9 /sys/sys/_lockmgr.h
parent44aab2c3de122eede973dcd0765e62959f741b98 (diff)
downloadsrc-047dd67e96bdb9e64f9f61b42ffb72bb5d4387b9.tar.gz
src-047dd67e96bdb9e64f9f61b42ffb72bb5d4387b9.zip
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
Notes
Notes: svn path=/head/; revision=177957
Diffstat (limited to 'sys/sys/_lockmgr.h')
-rw-r--r--sys/sys/_lockmgr.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/sys/sys/_lockmgr.h b/sys/sys/_lockmgr.h
new file mode 100644
index 000000000000..11ddac62931e
--- /dev/null
+++ b/sys/sys/_lockmgr.h
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2008 Attilio Rao <attilio@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice(s), this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified other than the possible
+ * addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice(s), this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS__LOCKMGR_H_
+#define _SYS__LOCKMGR_H_
+
+#ifdef DEBUG_LOCKS
+#include <sys/_stack.h>
+#endif
+
+struct lock {
+ struct lock_object lock_object;
+ volatile uintptr_t lk_lock;
+ volatile unsigned lk_recurse;
+ int lk_timo;
+ int lk_pri;
+#ifdef DEBUG_LOCKS
+ struct stack lk_stack;
+#endif
+};
+
+#endif