socsvn commit: r240553 - in soc2012/gmiller/locking-head: . include
lib/libthr/thread lib/libwitness
gmiller at FreeBSD.org
gmiller at FreeBSD.org
Mon Aug 20 06:33:39 UTC 2012
Author: gmiller
Date: Mon Aug 20 06:33:36 2012
New Revision: 240553
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240553
Log:
r240631 at FreeBSD-dev: root | 2012-08-17 22:11:19 -0500
Apply various style(9) fixes.
Modified:
soc2012/gmiller/locking-head/ (props changed)
soc2012/gmiller/locking-head/include/pthread_np.h
soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h
soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c
soc2012/gmiller/locking-head/lib/libwitness/api.c
soc2012/gmiller/locking-head/lib/libwitness/graph.c
soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c
soc2012/gmiller/locking-head/lib/libwitness/locklist.c
soc2012/gmiller/locking-head/lib/libwitness/unwind.c
soc2012/gmiller/locking-head/lib/libwitness/witness.h
soc2012/gmiller/locking-head/lib/libwitness/xml.c
Modified: soc2012/gmiller/locking-head/include/pthread_np.h
==============================================================================
--- soc2012/gmiller/locking-head/include/pthread_np.h Mon Aug 20 05:47:07 2012 (r240552)
+++ soc2012/gmiller/locking-head/include/pthread_np.h Mon Aug 20 06:33:36 2012 (r240553)
@@ -108,28 +108,28 @@
int pthread_switch_add_np(pthread_switch_routine_t);
int pthread_switch_delete_np(pthread_switch_routine_t);
int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
-int pthread_lor_begin_np(struct pthread_lor_np *);
-int pthread_lor_next_np(struct pthread_lor_np *);
-void pthread_lor_end_np(struct pthread_lor_np *);
-void pthread_lor_clear_np(void);
-int pthread_lockorder_bless_np(void *, void *);
-int pthread_lockorder_set_np(void *first, void *second);
-void pthread_lockorder_reset_np(void);
-int pthread_lockorder_begin_np(struct pthread_lockorder_np *);
-int pthread_lockorder_next_np(struct pthread_lockorder_np *);
-void pthread_lockorder_end_np(struct pthread_lockorder_np *);
-int pthread_mutex_setname_np(pthread_mutex_t *, const char *);
-int pthread_rwlock_setname_np(pthread_rwlock_t *, const char *);
-int pthread_spin_setname_np(pthread_spinlock_t *, const char *);
+int pthread_lor_begin_np(struct pthread_lor_np *);
+int pthread_lor_next_np(struct pthread_lor_np *);
+void pthread_lor_end_np(struct pthread_lor_np *);
+void pthread_lor_clear_np(void);
+int pthread_lockorder_bless_np(void *, void *);
+int pthread_lockorder_set_np(void *, void *);
+void pthread_lockorder_reset_np(void);
+int pthread_lockorder_begin_np(struct pthread_lockorder_np *);
+int pthread_lockorder_next_np(struct pthread_lockorder_np *);
+void pthread_lockorder_end_np(struct pthread_lockorder_np *);
+int pthread_mutex_setname_np(pthread_mutex_t *, const char *);
+int pthread_rwlock_setname_np(pthread_rwlock_t *, const char *);
+int pthread_spin_setname_np(pthread_spinlock_t *, const char *);
#ifdef LOCK_PROFILING
-void pthread_statistics_begin_np(struct pthread_statistics_np *);
-int pthread_statistics_next_np(struct pthread_statistics_np *);
-void pthread_statistics_end_np(struct pthread_statistics_np *);
-void pthread_statistics_reset_np(void);
-void pthread_statistics_enable_np(void);
-void pthread_statistics_disable_np(void);
+void pthread_statistics_begin_np(struct pthread_statistics_np *);
+int pthread_statistics_next_np(struct pthread_statistics_np *);
+void pthread_statistics_end_np(struct pthread_statistics_np *);
+void pthread_statistics_reset_np(void);
+void pthread_statistics_enable_np(void);
+void pthread_statistics_disable_np(void);
#endif
Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h
==============================================================================
--- soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h Mon Aug 20 05:47:07 2012 (r240552)
+++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h Mon Aug 20 06:33:36 2012 (r240553)
@@ -728,15 +728,15 @@
extern struct umutex _thr_event_lock __hidden;
/*
- Macros used to pass file and line parameters if and only if lock profiling
- is enabled.
-*/
+ * Macros used to pass file and line parameters if and only if lock profiling
+ * is enabled.
+ */
#ifdef LOCK_PROFILING
-#define _PROFILE_PARMS , const char *file, int line
-#define _PROFILE_PASS , file, line
+#define _PROFILE_PARMS , const char *file, int line
+#define _PROFILE_PASS , file, line
#else
-#define _PROFILE_PARMS /* */
-#define _PROFILE_PASS /* */
+#define _PROFILE_PARMS /* */
+#define _PROFILE_PASS /* */
#endif
/*
@@ -812,13 +812,14 @@
#ifdef LOCK_PROFILING
-#define INIT_LOCK_PROFILING() \
- _lock_profile_init()
-#define LOCK_PROFILE_OBTAIN_SUCCESS(l, ts) \
- _lock_profile_obtain_success(l, ts, file, line)
-#define LOCK_PROFILE_OBTAIN_FAILED(ts) \
- _lock_profile_obtain_failed(ts, file)
-#define LOCK_PROFILE_RELEASE(l) _lock_profile_release(l, file)
+#define INIT_LOCK_PROFILING() \
+ _lock_profile_init()
+#define LOCK_PROFILE_OBTAIN_SUCCESS(l, ts) \
+ _lock_profile_obtain_success(l, ts, file, line)
+#define LOCK_PROFILE_OBTAIN_FAILED(ts) \
+ _lock_profile_obtain_failed(ts, file)
+#define LOCK_PROFILE_RELEASE(l) \
+ _lock_profile_release(l, file)
void _lock_profile_init(void) __hidden;
void _lock_profile_obtain_failed(struct timespec *, const char *) __hidden;
@@ -828,10 +829,10 @@
#else
-#define INIT_LOCK_PROFILING() do { } while (0)
-#define LOCK_PROFILE_OBTAIN_SUCCESS(l, ts) do { } while (0)
-#define LOCK_PROFILE_OBTAIN_FAILED(ts) do { } while (0)
-#define LOCK_PROFILE_RELEASE(l) do { } while (0)
+#define INIT_LOCK_PROFILING() do { } while (0)
+#define LOCK_PROFILE_OBTAIN_SUCCESS(l, ts) do { } while (0)
+#define LOCK_PROFILE_OBTAIN_FAILED(ts) do { } while (0)
+#define LOCK_PROFILE_RELEASE(l) do { } while (0)
#endif
Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Mon Aug 20 05:47:07 2012 (r240552)
+++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Mon Aug 20 06:33:36 2012 (r240553)
@@ -35,12 +35,12 @@
#include "thr_private.h"
-#define LOCK_PROF_HASH_SIZE (4096)
+#define LOCK_PROF_HASH_SIZE 4096
/*
- The acquisition_point structure is used to record data about each point in
- the program that acquires a lock.
-*/
+ * The acquisition_point structure is used to record data about each point in
+ * the program that acquires a lock.
+ */
struct acquisition_point {
SLIST_ENTRY(acquisition_point) acq_point_next;
const char *file;
@@ -56,9 +56,9 @@
SLIST_HEAD(acq_point_head, acquisition_point);
/*
- The acquisition struct is used to store data about a single acquisition of
- a lock until the lock is released.
-*/
+ * The acquisition struct is used to store data about a single acquisition of
+ * a lock until the lock is released.
+ */
struct acquisition {
LIST_ENTRY(acquisition) acq_next;
void *lock;
@@ -85,14 +85,14 @@
static FILE *xml_file;
/*
- The following functions are used to write out an XML file containing the
- profiling data on exit.
-*/
+ * The following functions are used to write out an XML file containing the
+ * profiling data on exit.
+ */
static void
indent(void)
{
- int i;
+ int i;
for (i = 0; i < xml_indent; i++) {
fputc(' ', xml_file);
@@ -227,20 +227,22 @@
}
/*
- This function is called when a lock is successfully acquired. It creates an
- acquisition structure if one doesn't already exist and records the wait time.
-*/
+ * This function is called when a lock is successfully acquired. It creates an
+ * acquisition structure if one doesn't already exist and records the wait
+ * time.
+ */
void
_lock_profile_obtain_success(void *lock, struct timespec *wait_time,
const char *file, int line)
{
- struct pthread *curthread = _get_curthread();
+ struct pthread *curthread;
struct acquisition *acq;
if (file == NULL || !lockprof_enabled) {
return;
}
+ curthread = _get_curthread();
THR_CRITICAL_ENTER(curthread);
acq = lookup_acq(lock, file, line);
@@ -265,10 +267,10 @@
}
/*
- This function is called when a lock attempt fails. If this is the first
- attempt to acquire the lock, the time is recorded. This time will be used
- by _lock_profile_obtain_success() to calculate the wait time.
-*/
+ * This function is called when a lock attempt fails. If this is the first
+ * attempt to acquire the lock, the time is recorded. This time will be used
+ * by _lock_profile_obtain_success() to calculate the wait time.
+ */
void
_lock_profile_obtain_failed(struct timespec *wait_time, const char *file)
{
@@ -282,13 +284,13 @@
}
/*
- This function is called when a lock is released to free the acquisition
- and update the acquisition_point.
-*/
+ * This function is called when a lock is released to free the acquisition
+ * and update the acquisition_point.
+ */
void
_lock_profile_release(void *lock, const char *file)
{
- struct pthread *curthread = _get_curthread();
+ struct pthread *curthread;
struct acquisition *acq;
struct acquisition_point *acq_point;
struct timespec current_time;
@@ -298,6 +300,7 @@
return;
}
+ curthread = _get_curthread();
THR_CRITICAL_ENTER(curthread);
LIST_FOREACH(acq, &acq_head, acq_next) {
@@ -350,18 +353,19 @@
}
/*
- The following functions are used to acquire profile statistics. The
- pthread_statistics_begin_np() function is called in order to initialize
- a pthread_statistics_np structure, pthread_statistics_next_np() is called
- to retrieve the statistics for each acquisition point (ending when it
- returns 0), and then pthread_statistics_end_np() is called to free working
- data.
-*/
+ * The following functions are used to acquire profile statistics. The
+ * pthread_statistics_begin_np() function is called in order to initialize
+ * a pthread_statistics_np structure, pthread_statistics_next_np() is called
+ * to retrieve the statistics for each acquisition point (ending when it
+ * returns 0), and then pthread_statistics_end_np() is called to free working
+ * data.
+ */
static int
find_next_record(struct pthread_statistics_np *stats)
{
- struct pthread *curthread = _get_curthread();
+ struct pthread *curthread;
+ curthread = _get_curthread();
THR_CRITICAL_ENTER(curthread);
for (;;) {
@@ -426,11 +430,12 @@
void
pthread_statistics_reset_np()
{
- struct pthread *curthread = _get_curthread();
+ struct pthread *curthread;
u_int hash;
struct acquisition_point *acq_point;
struct acquisition *acq;
+ curthread = _get_curthread();
THR_CRITICAL_ENTER(curthread);
for (hash = 0; hash < LOCK_PROF_HASH_SIZE; hash++) {
@@ -462,4 +467,4 @@
lockprof_enabled = 0;
}
-#endif /* LOCK_PROFILING */
+#endif /* LOCK_PROFILING */
Modified: soc2012/gmiller/locking-head/lib/libwitness/api.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/api.c Mon Aug 20 05:47:07 2012 (r240552)
+++ soc2012/gmiller/locking-head/lib/libwitness/api.c Mon Aug 20 06:33:36 2012 (r240553)
@@ -49,14 +49,14 @@
int _pthread_spin_destroy(pthread_spinlock_t *spin);
/*
- Keep witness from including any lock usage that occurs as a result of
- witness itself.
+ * Keep witness from including any lock usage that occurs as a result of
+ * witness itself.
- All API functions should call enter_witness() before doing anything that
- could acquire a lock or using shared data that may experience race
- conditions. Before returning, every function that calls enter_witness()
- should call leave_witness().
-*/
+ * All API functions should call enter_witness() before doing anything that
+ * could acquire a lock or using shared data that may experience race
+ * conditions. Before returning, every function that calls enter_witness()
+ * should call leave_witness().
+ */
pthread_mutex_t witness_mtx = PTHREAD_MUTEX_INITIALIZER;
@@ -84,15 +84,15 @@
}
/*
- Each of these wrapper functions ensures that the default lock name has been
- set and calls add_lock() or remove_lock() to update the thread-local list
- of locks that are currently held adjust the lock order graph and LoR logs.
-*/
+ * Each of these wrapper functions ensures that the default lock name has been
+ * set and calls add_lock() or remove_lock() to update the thread-local list
+ * of locks that are currently held adjust the lock order graph and LoR logs.
+ */
int
pthread_mutex_lock(pthread_mutex_t *mutex)
{
- int ret;
+ int ret;
enter_witness();
@@ -111,7 +111,7 @@
int
pthread_mutex_trylock(pthread_mutex_t *mutex)
{
- int ret;
+ int ret;
enter_witness();
@@ -130,7 +130,7 @@
int
pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *ts)
{
- int ret;
+ int ret;
enter_witness();
@@ -149,7 +149,7 @@
int
pthread_mutex_unlock(pthread_mutex_t *mutex)
{
- int ret;
+ int ret;
enter_witness();
@@ -166,7 +166,7 @@
int
pthread_mutex_destroy(pthread_mutex_t *mutex)
{
- int ret;
+ int ret;
enter_witness();
@@ -181,7 +181,7 @@
int
pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
{
- int ret;
+ int ret;
enter_witness();
@@ -200,7 +200,7 @@
int
pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
{
- int ret;
+ int ret;
enter_witness();
@@ -219,7 +219,7 @@
int
pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *ts)
{
- int ret;
+ int ret;
enter_witness();
@@ -238,7 +238,7 @@
int
pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
{
- int ret;
+ int ret;
enter_witness();
@@ -257,7 +257,7 @@
int
pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
{
- int ret;
+ int ret;
enter_witness();
@@ -276,7 +276,7 @@
int
pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *ts)
{
- int ret;
+ int ret;
enter_witness();
@@ -295,7 +295,7 @@
int
pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
{
- int ret;
+ int ret;
enter_witness();
@@ -312,7 +312,7 @@
int
pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
{
- int ret;
+ int ret;
enter_witness();
@@ -327,7 +327,7 @@
int
pthread_spin_lock(pthread_spinlock_t *spin)
{
- int ret;
+ int ret;
enter_witness();
@@ -346,7 +346,7 @@
int
pthread_spin_trylock(pthread_spinlock_t *spin)
{
- int ret;
+ int ret;
enter_witness();
@@ -365,7 +365,7 @@
int
pthread_spin_unlock(pthread_spinlock_t *spin)
{
- int ret;
+ int ret;
enter_witness();
@@ -382,7 +382,7 @@
int
pthread_spin_destroy(pthread_spinlock_t *spin)
{
- int ret;
+ int ret;
enter_witness();
@@ -395,16 +395,17 @@
}
/*
- The pthread_lockorder_set_np() function attempts to insert the specified
- pair into the lock order graph.
-*/
+ * The pthread_lockorder_set_np() function attempts to insert the specified
+ * pair into the lock order graph.
+ */
int
pthread_lockorder_set_np(void *first, void *second)
{
- int ret = 0;
+ int ret;
enter_witness();
+ ret = 0;
if (insert_lock(get_lock_info(lookup_lock(first)),
get_lock_info(lookup_lock(second))) < 0) {
ret = EINVAL;
@@ -416,19 +417,19 @@
}
/*
- The pthread_lockorder_bless_np() function prevents LoRs from being generated
- for the given pair of locks.
-*/
+ * The pthread_lockorder_bless_np() function prevents LoRs from being generated
+ * for the given pair of locks.
+ */
int
pthread_lockorder_bless_np(void *first_addr, void *second_addr)
{
- struct lock_info *first;
- struct lock_info *second;
struct lock_instance *first_inst;
struct lock_instance *second_inst;
- struct blessing *first_bless = NULL;
- struct blessing *second_bless = NULL;
- int ret = 0;
+ struct lock_info *first;
+ struct lock_info *second;
+ struct blessing *first_bless;
+ struct blessing *second_bless;
+ int ret;
enter_witness();
@@ -441,6 +442,7 @@
first_bless = malloc(sizeof(struct blessing));
second_bless = malloc(sizeof(struct blessing));
+ ret = 0;
if (first == NULL || second == NULL || first_bless == NULL ||
second_bless == NULL) {
ret = ENOMEM;
@@ -463,8 +465,8 @@
}
/*
- pthread_lockorder_reset_np() resets all lock order information.
-*/
+ * pthread_lockorder_reset_np() resets all lock order information.
+ */
void
pthread_lockorder_reset_np(void)
{
@@ -478,14 +480,14 @@
}
/*
- The pthread_*_setname_np() functions set lock names and ensure that all
- locks with the same name are treated as the same lock.
-*/
+ * The pthread_*_setname_np() functions set lock names and ensure that all
+ * locks with the same name are treated as the same lock.
+ */
int
pthread_mutex_setname_np(pthread_mutex_t *mutex, const char *name)
{
- int ret;
+ int ret;
enter_witness();
@@ -499,7 +501,7 @@
int
pthread_rwlock_setname_np(pthread_rwlock_t *rwlock, const char *name)
{
- int ret;
+ int ret;
enter_witness();
@@ -513,7 +515,7 @@
int
pthread_spin_setname_np(pthread_spinlock_t *spin, const char *name)
{
- int ret;
+ int ret;
enter_witness();
@@ -525,22 +527,22 @@
}
/*
- The pthread_lor_*_np() functions retrieve LoR log information.
-
- pthread_lor_begin_np() must be called first to initialize the
- pthread_lor_np structure.
-
- pthread_lor_next_np() is used to retrieve one LoR entry per call.
- Returns 0 if no LoR records remain.
-
- pthread_lor_end_np() should be called after the final call to
- pthread_lor_next_np().
-*/
+ * The pthread_lor_*_np() functions retrieve LoR log information.
+ *
+ * pthread_lor_begin_np() must be called first to initialize the
+ * pthread_lor_np structure.
+ *
+ * pthread_lor_next_np() is used to retrieve one LoR entry per call.
+ * Returns 0 if no LoR records remain.
+ *
+ * pthread_lor_end_np() should be called after the final call to
+ * pthread_lor_next_np().
+ */
int
pthread_lor_begin_np(struct pthread_lor_np *lor)
{
- int ret = 0;
+ int ret;
lor->name_first = NULL;
lor->first_trace = NULL;
@@ -549,6 +551,7 @@
enter_witness();
+ ret = 0;
lor->_pvt = malloc(sizeof(struct _pthread_lor_private));
if (lor->_pvt == NULL) {
ret = ENOMEM;
@@ -564,7 +567,7 @@
int
pthread_lor_next_np(struct pthread_lor_np *lor)
{
- int res = 0;
+ int ret;
enter_witness();
@@ -575,6 +578,7 @@
STAILQ_NEXT(lor->_pvt->last_record, lor_next);
}
+ ret = 0;
if (lor->_pvt->last_record != NULL) {
lor->name_first =
strdup(get_lock_name(lor->_pvt->last_record->lock_first));
@@ -585,12 +589,12 @@
lor->second_trace =
strdup(lor->_pvt->last_record->second_trace);
- res = 1;
+ ret = 1;
}
leave_witness();
- return (res);
+ return (ret);
}
void
@@ -644,22 +648,23 @@
}
/*
- The pthread_lockorder_*_np() functions are used to retrieve the contents
- of the lock order graph.
+ * The pthread_lockorder_*_np() functions are used to retrieve the contents
+ * of the lock order graph.
- pthread_lockorder_begin_np() is called to initialize the
- pthread_lockorder_np structure, pthread_lockorder_next_np() is then called
- until it returns 0, and pthread_lockorder_end_np() is called to clean up the
- pthread_lockorder_np structure.
-*/
+ * pthread_lockorder_begin_np() is called to initialize the
+ * pthread_lockorder_np structure, pthread_lockorder_next_np() is then called
+ * until it returns 0, and pthread_lockorder_end_np() is called to clean up the
+ * pthread_lockorder_np structure.
+ */
int
pthread_lockorder_begin_np(struct pthread_lockorder_np *node)
{
- int ret = 0;
+ int ret;
enter_witness();
+ ret = 0;
node->_pvt = malloc(sizeof(struct _pthread_lockorder_private));
if (node->_pvt == NULL) {
ret = ENOMEM;
Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Aug 20 05:47:07 2012 (r240552)
+++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Aug 20 06:33:36 2012 (r240553)
@@ -28,13 +28,13 @@
#include "witness.h"
/*
- scan_graph() returns 1 if lock is reachable from graph in the lock order
- graph, or 0 if it isn't.
-*/
+ * scan_graph() returns 1 if lock is reachable from graph in the lock order
+ * graph, or 0 if it isn't.
+ */
static int
scan_graph(struct lock_info *graph, struct lock_info *lock)
{
- int ret;
+ int ret;
struct lock_info *child;
if (graph == NULL) {
@@ -57,14 +57,14 @@
}
/*
- Remove the edge from "from" to "to" if "to" would still be reachable from
- "from" without the direct edge.
-*/
+ * Remove the edge from "from" to "to" if "to" would still be reachable from
+ * "from" without the direct edge.
+ */
static void
optimize_path(struct lock_info *from, struct lock_info *to)
{
- struct lock_info *child;
struct lock_info *previous;
+ struct lock_info *child;
struct lock_info *next;
previous = NULL;
@@ -93,9 +93,9 @@
}
/*
- Insert an edge from "from" to "to" in the graph, while maintaining an
- optimal lock order graph. Returns 0 if successful.
-*/
+ * Insert an edge from "from" to "to" in the graph, while maintaining an
+ * optimal lock order graph. Returns 0 if successful.
+ */
int
insert_lock(struct lock_info *from, struct lock_info *to)
{
@@ -106,9 +106,9 @@
}
/*
- If "from" is reachable from "to," a lock order reversal has been
- detected.
- */
+ * If "from" is reachable from "to," a lock order reversal has been
+ * detected.
+ */
if (scan_graph(to, from) && !blessed(from, to)) {
return (-1);
}
@@ -120,12 +120,12 @@
}
/*
- Redundant edges may be present, in which case they fall into two
- categories. Either one of the edge from "from" to one of its
- children will be redundant (in which case it will be handled by the
- following loop) or the newly inserted edge will be (in which case
- the final optimize_path() call will take care of it.
- */
+ * Redundant edges may be present, in which case they fall into two
+ * categories. Either one of the edge from "from" to one of its
+ * children will be redundant (in which case it will be handled by the
+ * following loop) or the newly inserted edge will be (in which case
+ * the final optimize_path() call will take care of it.
+ */
child = to->sibling;
while (child != NULL) {
optimize_path(from, child);
Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Aug 20 05:47:07 2012 (r240552)
+++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Aug 20 06:33:36 2012 (r240553)
@@ -33,15 +33,16 @@
SLIST_HEAD_INITIALIZER(lock_instance_head);
/*
- lookup_lock() returns the lock_instance structure associated with the
- POSIX lock object, creating a new one if needed.
-*/
+ * lookup_lock() returns the lock_instance structure associated with the
+ * POSIX lock object, creating a new one if needed.
+ */
struct lock_instance *
lookup_lock(void *lock)
{
- struct lock_instance *inst = NULL;
struct lock_instance *iter;
+ struct lock_instance *inst;
+ inst = NULL;
SLIST_FOREACH(iter, &lock_instance_head, lock_instance_next) {
if (iter->lock == lock) {
inst = iter;
@@ -63,9 +64,7 @@
return (inst);
}
-/*
- Free the lock_instance structure associated with a POSIX lock object.
-*/
+/* Free the lock_instance structure associated with a POSIX lock object. */
void
destroy_lock(void *lock)
{
@@ -79,9 +78,7 @@
}
}
-/*
- Returns 1 if first and second have been blessed, or 0 if not.
-*/
+/* Returns 1 if first and second have been blessed, or 0 if not. */
int
blessed(struct lock_info *first, struct lock_info *second)
{
@@ -96,9 +93,7 @@
return (0);
}
-/*
- Free all lock_info data.
-*/
+/* Free all lock_info data. */
void
reset_lock_info(void)
{
@@ -124,9 +119,7 @@
}
}
-/*
- Free all lock_instance data.
-*/
+/* Free all lock_instance data. */
void
reset_lock_instance(void)
{
@@ -142,9 +135,9 @@
}
/*
- Returns the lock_info associated with a lock_instance, creating a new one if
- needed.
-*/
+ * Returns the lock_info associated with a lock_instance, creating a new one if
+ * needed.
+ */
struct lock_info *
get_lock_info(struct lock_instance *inst)
{
@@ -172,15 +165,14 @@
return (info);
}
-/*
- Return the lock_info associated with a particular lock name.
-*/
+/* Return the lock_info associated with a particular lock name. */
static struct lock_info *
lookup_info(const char *name)
{
- struct lock_info *info = NULL;
struct lock_info *iter;
+ struct lock_info *info;
+ info = NULL;
SLIST_FOREACH(iter, &lock_info_head, lock_info_next) {
if (strcmp(name, get_lock_name(iter)) == 0) {
info = iter;
@@ -204,9 +196,9 @@
}
/*
- Set the name associated with a lock. If multiple locks share the same name,
- set_lock_name() will ensure that they share the same lock_info.
-*/
+ * Set the name associated with a lock. If multiple locks share the same name,
+ * set_lock_name() will ensure that they share the same lock_info.
+ */
int
set_lock_name(void *lock, const char *name)
{
@@ -232,12 +224,10 @@
return (info->name);
}
- return "";
+ return ("");
}
-/*
- Ensure that a lock has a default name if no name has been previously set.
-*/
+/* Ensure that a lock has a default name if no name has been previously set. */
void
check_default_name(void *lock, const char *prefix)
{
Modified: soc2012/gmiller/locking-head/lib/libwitness/locklist.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/locklist.c Mon Aug 20 05:47:07 2012 (r240552)
+++ soc2012/gmiller/locking-head/lib/libwitness/locklist.c Mon Aug 20 06:33:36 2012 (r240553)
@@ -28,8 +28,9 @@
#include "witness.h"
/*
- lock_entry is used to maintain the list of locks held by the current thread.
-*/
+ * lock_entry is used to maintain the list of locks held by the current
+ * thread.
+ */
struct lock_entry {
SLIST_ENTRY(lock_entry) lock_next;
struct lock_info *lock;
@@ -43,9 +44,7 @@
static int exit_set = 0;
struct lor_head lor_head = STAILQ_HEAD_INITIALIZER(lor_head);
-/*
- Record a lock order reversal in the lor log.
-*/
+/* Record a lock order reversal in the lor log. */
static void
log_reversal(struct lock_info *lock, struct backtrace *lock_trace,
struct lock_info *previous, struct backtrace *previous_trace)
@@ -85,17 +84,17 @@
}
/*
- Add a lock to the list of locks held by the current thread and insert it
- insert it into the lock order graph. If a lock order reversal is detected,
- log it.
-*/
+ * Add a lock to the list of locks held by the current thread and insert it
+ * insert it into the lock order graph. If a lock order reversal is detected,
+ * log it.
+ */
void
add_lock(void *lock)
{
- struct lock_entry *entry;
- struct lock_entry *next;
struct lock_instance *inst;
struct lock_info *info;
+ struct lock_entry *next;
+ struct lock_entry *entry;
/* Call write_xml() on exit to generate the XML data file. */
if (exit_set == 0) {
@@ -123,9 +122,9 @@
entry->lock = info;
/*
- If a reset has been requested since this thread's lock list has
- been reset, reset the data and update the reset count.
- */
+ * If a reset has been requested since this thread's lock list has
+ * been reset, reset the data and update the reset count.
+ */
if (reset_count > thread_reset_count) {
thread_reset_count = reset_count;
@@ -143,18 +142,16 @@
SLIST_INSERT_HEAD(&lock_head, entry, lock_next);
/*
- Insert the lock into the lock order graph and log the reversal if
- one is detected.
- */
+ * Insert the lock into the lock order graph and log the reversal if
+ * one is detected.
+ */
if (next != NULL && insert_lock(next->lock, entry->lock) < 0) {
log_reversal(entry->lock, &entry->trace, next->lock,
&next->trace);
}
}
-/*
- Remove a lock from the list of locks currently held.
-*/
+/* Remove a lock from the list of locks currently held. */
void
remove_lock(void *lock)
{
@@ -176,9 +173,7 @@
}
}
-/*
- Request a reset of the list of locks held by each thread.
-*/
+/* Request a reset of the list of locks held by each thread. */
void
reset_lists(void)
{
Modified: soc2012/gmiller/locking-head/lib/libwitness/unwind.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/unwind.c Mon Aug 20 05:47:07 2012 (r240552)
+++ soc2012/gmiller/locking-head/lib/libwitness/unwind.c Mon Aug 20 06:33:36 2012 (r240553)
@@ -28,27 +28,29 @@
#include "witness.h"
/*
- Return a string containing a description of the given backtrace. The string
- must be freed by the caller using free().
-*/
+ * Return a string containing a description of the given backtrace. The string
+ * must be freed by the caller using free().
+ */
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-soc-all
mailing list