Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Feb 2009 20:43:29 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189014 - head/sys/vm
Message-ID:  <200902242043.n1OKhTLe075957@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Feb 24 20:43:29 2009
New Revision: 189014
URL: http://svn.freebsd.org/changeset/base/189014

Log:
  Add the assertion macros for the map locks. Use them in several map
  manipulation functions.
  
  Tested by:	pho
  Reviewed by:	alc

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==============================================================================
--- head/sys/vm/vm_map.c	Tue Feb 24 20:27:48 2009	(r189013)
+++ head/sys/vm/vm_map.c	Tue Feb 24 20:43:29 2009	(r189014)
@@ -573,6 +573,38 @@ vm_map_locked(vm_map_t map)
 		return (sx_xlocked(&map->lock));
 }
 
+#ifdef INVARIANTS
+static void
+_vm_map_assert_locked(vm_map_t map, const char *file, int line)
+{
+
+	if (map->system_map)
+		_mtx_assert(&map->system_mtx, MA_OWNED, file, line);
+	else
+		_sx_assert(&map->lock, SA_XLOCKED, file, line);
+}
+
+#if 0
+static void
+_vm_map_assert_locked_read(vm_map_t map, const char *file, int line)
+{
+
+	if (map->system_map)
+		_mtx_assert(&map->system_mtx, MA_OWNED, file, line);
+	else
+		_sx_assert(&map->lock, SA_SLOCKED, file, line);
+}
+#endif
+
+#define	VM_MAP_ASSERT_LOCKED(map) \
+    _vm_map_assert_locked(map, LOCK_FILE, LOCK_LINE)
+#define	VM_MAP_ASSERT_LOCKED_READ(map) \
+    _vm_map_assert_locked_read(map, LOCK_FILE, LOCK_LINE)
+#else
+#define	VM_MAP_ASSERT_LOCKED(map)
+#define	VM_MAP_ASSERT_LOCKED_READ(map)
+#endif
+
 /*
  *	vm_map_unlock_and_wait:
  */
@@ -846,6 +878,7 @@ vm_map_entry_link(vm_map_t map,
 	CTR4(KTR_VM,
 	    "vm_map_entry_link: map %p, nentries %d, entry %p, after %p", map,
 	    map->nentries, entry, after_where);
+	VM_MAP_ASSERT_LOCKED(map);
 	map->nentries++;
 	entry->prev = after_where;
 	entry->next = after_where->next;
@@ -876,6 +909,7 @@ vm_map_entry_unlink(vm_map_t map,
 {
 	vm_map_entry_t next, prev, root;
 
+	VM_MAP_ASSERT_LOCKED(map);
 	if (entry != map->root)
 		vm_map_entry_splay(entry->start, map->root);
 	if (entry->left == NULL)
@@ -1025,6 +1059,8 @@ vm_map_insert(vm_map_t map, vm_object_t 
 	vm_map_entry_t temp_entry;
 	vm_eflags_t protoeflags;
 
+	VM_MAP_ASSERT_LOCKED(map);
+
 	/*
 	 * Check that the start and end points are not bogus.
 	 */
@@ -1416,6 +1452,8 @@ _vm_map_clip_start(vm_map_t map, vm_map_
 {
 	vm_map_entry_t new_entry;
 
+	VM_MAP_ASSERT_LOCKED(map);
+
 	/*
 	 * Split off the front portion -- note that we must insert the new
 	 * entry BEFORE this one, so that this entry has the specified
@@ -1474,6 +1512,8 @@ _vm_map_clip_end(vm_map_t map, vm_map_en
 {
 	vm_map_entry_t new_entry;
 
+	VM_MAP_ASSERT_LOCKED(map);
+
 	/*
 	 * If there is no object backing this entry, we might as well create
 	 * one now.  If we defer it, an object can get created after the map
@@ -2461,6 +2501,8 @@ vm_map_delete(vm_map_t map, vm_offset_t 
 	vm_map_entry_t entry;
 	vm_map_entry_t first_entry;
 
+	VM_MAP_ASSERT_LOCKED(map);
+
 	/*
 	 * Find the start of the region, and clip it
 	 */
@@ -2621,6 +2663,8 @@ vm_map_copy_entry(
 {
 	vm_object_t src_object;
 
+	VM_MAP_ASSERT_LOCKED(dst_map);
+
 	if ((dst_entry->eflags|src_entry->eflags) & MAP_ENTRY_IS_SUB_MAP)
 		return;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902242043.n1OKhTLe075957>