socsvn commit: r238347 - in soc2012/gmiller/locking-head: . lib/libwitness

gmiller at FreeBSD.org gmiller at FreeBSD.org
Tue Jun 26 18:55:07 UTC 2012


Author: gmiller
Date: Tue Jun 26 18:55:06 2012
New Revision: 238347
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238347

Log:
   r238354 at FreeBSD-dev:  root | 2012-06-19 20:48:01 -0500
   Move per-thread lock list heads to TLS.

Modified:
  soc2012/gmiller/locking-head/   (props changed)
  soc2012/gmiller/locking-head/lib/libwitness/lists.c
  soc2012/gmiller/locking-head/lib/libwitness/lists.h

Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/lists.c	Tue Jun 26 18:54:54 2012	(r238346)
+++ soc2012/gmiller/locking-head/lib/libwitness/lists.c	Tue Jun 26 18:55:06 2012	(r238347)
@@ -31,31 +31,31 @@
 
 #include "lists.h"
 
-SLIST_HEAD(lock_lists_head, lock_lists_next) lock_lists_head =
-    SLIST_HEAD_INITIALIZER(lock_lists_head);
-
-static struct lock_list *
-get_lock_list(void)
-{
-	return NULL;
-}
+_Thread_local SLIST_HEAD(lock_head, lock_entry) lock_head =
+    SLIST_HEAD_INITIALIZER(lock_head);
 
 void
 add_lock(void *lock)
 {
-	struct lock_list *lock_list;
+	struct lock_entry *entry;
 
-	lock = lock;
+	entry = malloc(sizeof(*entry));
+	entry->lock = lock;
 
-	lock_list = get_lock_list();
+	SLIST_INSERT_HEAD(&lock_head, entry, lock_next);
 }
 
 void
 remove_lock(void *lock)
 {
-	struct lock_list *lock_list;
-
-	lock = lock;
+	struct lock_entry *entry;
+	struct lock_entry *temp;
 
-	lock_list = get_lock_list();
+	SLIST_FOREACH_SAFE(entry, &lock_head, lock_next, temp) {
+		if (entry->lock == lock) {
+			SLIST_REMOVE(&lock_head, entry, lock_entry, lock_next);
+			free(entry);
+			break;
+		}
+	}
 }

Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.h
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/lists.h	Tue Jun 26 18:54:54 2012	(r238346)
+++ soc2012/gmiller/locking-head/lib/libwitness/lists.h	Tue Jun 26 18:55:06 2012	(r238347)
@@ -25,7 +25,9 @@
  *
  */
 
-struct lock_list {
+struct lock_entry {
+	SLIST_ENTRY(lock_entry) lock_next;
+	void		*lock;
 };
 
 void	add_lock(void *lock);


More information about the svn-soc-all mailing list