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

gmiller at FreeBSD.org gmiller at FreeBSD.org
Thu Jun 28 20:02:01 UTC 2012


Author: gmiller
Date: Thu Jun 28 20:01:59 2012
New Revision: 238505
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238505

Log:
   r238486 at FreeBSD-dev:  root | 2012-06-20 04:45:15 -0500
   Maintain a lock order graph and add checks (but no error messages or
   recording of the LoR data yet).

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

Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/graph.c	Thu Jun 28 20:01:47 2012	(r238504)
+++ soc2012/gmiller/locking-head/lib/libwitness/graph.c	Thu Jun 28 20:01:59 2012	(r238505)
@@ -52,23 +52,10 @@
 	return (NULL);
 }
 
-static struct graph_node *
-get_node(void *lock)
-{
-	if (root != NULL) {
-		return (scan_graph(root, lock));
-	}
-
-	return (NULL);
-}
-
-int
+/* XXX: produces suboptimal graph, fix this before the end of the project */
+static int
 insert_edge(struct graph_node *from, struct graph_node *to)
 {
-#if 1
-  // suppress warning
-  get_node(from->lock);
-#endif
 	if (from == to) {
 		return (0);
 	}
@@ -77,8 +64,30 @@
 		return (-1);
 	}
 
-	/* XXX */
+	to->sibling = from->child;
+	from->child = to;
 
 	return (0);
 }
 
+static struct graph_node *
+lookup_node(void *lock)
+{
+	struct graph_node *node;
+
+	node = scan_graph(root, lock);
+	if (node == NULL) {
+		node = malloc(sizeof(struct graph_node));
+		node->lock = lock;
+		node->child = NULL;
+		node->sibling = NULL;
+	}
+
+	return (node);
+}
+
+int
+insert_lock(void *new_lock, void *previous)
+{
+	return (insert_edge(lookup_node(previous), lookup_node(new_lock)));
+}

Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/lists.c	Thu Jun 28 20:01:47 2012	(r238504)
+++ soc2012/gmiller/locking-head/lib/libwitness/lists.c	Thu Jun 28 20:01:59 2012	(r238505)
@@ -47,12 +47,19 @@
 add_lock(void *lock)
 {
 	struct lock_entry *entry;
+	struct lock_entry *next;
+
+	next = SLIST_FIRST(&lock_head);
 
 	entry = malloc(sizeof(*entry));
 	entry->lock = lock;
 
 	SLIST_INSERT_HEAD(&lock_head, entry, lock_next);
 
+	if (insert_lock(entry, next) < 0) {
+	  /* XXX: LoR */
+	}
+
 	printf("inserted lock %p\n", lock);
 	dump_locks();
 }

Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/witness.h	Thu Jun 28 20:01:47 2012	(r238504)
+++ soc2012/gmiller/locking-head/lib/libwitness/witness.h	Thu Jun 28 20:01:59 2012	(r238505)
@@ -47,4 +47,4 @@
 void	add_lock(void *lock);
 void	remove_lock(void *lock);
 
-int	insert_edge(struct graph_node *from, struct graph_node *to);
+int	insert_lock(void *new_lock, void *previous);


More information about the svn-soc-all mailing list