PERFORCE change 126330 for review

Kip Macy kmacy at FreeBSD.org
Wed Sep 12 01:32:22 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=126330

Change 126330 by kmacy at kmacy_home:ethng on 2007/09/12 08:31:36

	convert radix node head and route locks from mutexes to rwlocks

Affected files ...

.. //depot/projects/ethng/src/sys/kern/vfs_export.c#2 edit
.. //depot/projects/ethng/src/sys/net/if_var.h#5 edit
.. //depot/projects/ethng/src/sys/net/radix.c#2 edit
.. //depot/projects/ethng/src/sys/net/radix.h#2 edit
.. //depot/projects/ethng/src/sys/net/route.c#2 edit
.. //depot/projects/ethng/src/sys/net/route.h#2 edit
.. //depot/projects/ethng/src/sys/netinet/if_ether.c#2 edit

Differences ...

==== //depot/projects/ethng/src/sys/kern/vfs_export.c#2 (text+ko) ====

@@ -45,7 +45,7 @@
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/mount.h>
-#include <sys/mutex.h>
+#include <sys/rwlock.h>
 #include <sys/refcount.h>
 #include <sys/socket.h>
 #include <sys/systm.h>

==== //depot/projects/ethng/src/sys/net/if_var.h#5 (text+ko) ====

@@ -79,7 +79,7 @@
 #include <sys/eventhandler.h>
 #endif /* _KERNEL */
 #include <sys/lock.h>		/* XXX */
-#include <sys/mutex.h>		/* XXX */
+#include <sys/rwlock.h>		/* XXX */
 #include <sys/event.h>		/* XXX */
 #include <sys/_task.h>
 

==== //depot/projects/ethng/src/sys/net/radix.c#2 (text+ko) ====

@@ -37,7 +37,7 @@
 #include <sys/param.h>
 #ifdef	_KERNEL
 #include <sys/lock.h>
-#include <sys/mutex.h>
+#include <sys/rwlock.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
 #include <sys/domain.h>

==== //depot/projects/ethng/src/sys/net/radix.h#2 (text+ko) ====

@@ -35,7 +35,7 @@
 
 #ifdef _KERNEL
 #include <sys/_lock.h>
-#include <sys/_mutex.h>
+#include <sys/_rwlock.h>
 #endif
 
 #ifdef MALLOC_DECLARE
@@ -131,7 +131,7 @@
 		(struct radix_node *rn, struct radix_node_head *head);
 	struct	radix_node rnh_nodes[3];	/* empty tree for common case */
 #ifdef _KERNEL
-	struct	mtx rnh_mtx;			/* locks entire radix tree */
+	struct	rwlock rnh_lock;			/* locks entire radix tree */
 #endif
 };
 
@@ -145,11 +145,13 @@
 #define Free(p) free((caddr_t)p, M_RTABLE);
 
 #define	RADIX_NODE_HEAD_LOCK_INIT(rnh)	\
-    mtx_init(&(rnh)->rnh_mtx, "radix node head", NULL, MTX_DEF | MTX_RECURSE)
-#define	RADIX_NODE_HEAD_LOCK(rnh)	mtx_lock(&(rnh)->rnh_mtx)
-#define	RADIX_NODE_HEAD_UNLOCK(rnh)	mtx_unlock(&(rnh)->rnh_mtx)
-#define	RADIX_NODE_HEAD_DESTROY(rnh)	mtx_destroy(&(rnh)->rnh_mtx)
-#define	RADIX_NODE_HEAD_LOCK_ASSERT(rnh) mtx_assert(&(rnh)->rnh_mtx, MA_OWNED)
+rw_init(&(rnh)->rnh_lock, "radix node head")
+#define	RADIX_NODE_HEAD_LOCK(rnh)	rw_wlock(&(rnh)->rnh_lock)
+#define	RADIX_NODE_HEAD_UNLOCK(rnh)	rw_wunlock(&(rnh)->rnh_lock)
+#define	RADIX_NODE_HEAD_LOCK_SHARED(rnh)	rw_wlock(&(rnh)->rnh_lock)
+#define	RADIX_NODE_HEAD_UNLOCK_SHARED(rnh)	rw_wunlock(&(rnh)->rnh_lock)
+#define	RADIX_NODE_HEAD_DESTROY(rnh)	rw_destroy(&(rnh)->rnh_lock)
+#define	RADIX_NODE_HEAD_LOCK_ASSERT(rnh) rw_assert(&(rnh)->rnh_lock, RA_LOCKED)
 #endif /* _KERNEL */
 
 void	 rn_init(void);

==== //depot/projects/ethng/src/sys/net/route.c#2 (text+ko) ====


==== //depot/projects/ethng/src/sys/net/route.h#2 (text+ko) ====

@@ -119,7 +119,7 @@
 	struct	rtentry *rt_parent; 	/* cloning parent of this route */
 #ifdef _KERNEL
 	/* XXX ugly, user apps use this definition but don't have a mtx def */
-	struct	mtx rt_mtx;		/* mutex for routing entry */
+	struct	rwlock rt_lock;		/* mutex for routing entry */
 #endif
 };
 
@@ -287,11 +287,11 @@
 #ifdef _KERNEL
 
 #define	RT_LOCK_INIT(_rt) \
-	mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK)
-#define	RT_LOCK(_rt)		mtx_lock(&(_rt)->rt_mtx)
-#define	RT_UNLOCK(_rt)		mtx_unlock(&(_rt)->rt_mtx)
-#define	RT_LOCK_DESTROY(_rt)	mtx_destroy(&(_rt)->rt_mtx)
-#define	RT_LOCK_ASSERT(_rt)	mtx_assert(&(_rt)->rt_mtx, MA_OWNED)
+	rw_init(&(_rt)->rt_lock, "rtentry")
+#define	RT_LOCK(_rt)		rw_wlock(&(_rt)->rt_lock)
+#define	RT_UNLOCK(_rt)		rw_wunlock(&(_rt)->rt_lock)
+#define	RT_LOCK_DESTROY(_rt)	rw_destroy(&(_rt)->rt_lock)
+#define	RT_LOCK_ASSERT(_rt)	rw_assert(&(_rt)->rt_lock, RA_LOCKED)
 
 #define	RT_ADDREF(_rt)	do {					\
 	RT_LOCK_ASSERT(_rt);					\

==== //depot/projects/ethng/src/sys/netinet/if_ether.c#2 (text+ko) ====

@@ -222,8 +222,8 @@
 		RT_ADDREF(rt);
 		la->la_rt = rt;
 		rt->rt_flags |= RTF_LLINFO;
-		callout_init_mtx(&la->la_timer, &rt->rt_mtx,
-		    CALLOUT_RETURNUNLOCKED);
+		callout_init_rwlock(&la->la_timer, &rt->rt_lock,
+		    CALLOUT_RETURNUNLOCKED_RW);
 
 #ifdef INET
 		/*


More information about the p4-projects mailing list