socsvn commit: r240551 - in soc2012/gmiller/locking-head: .
lib/libthr/thread
gmiller at FreeBSD.org
gmiller at FreeBSD.org
Mon Aug 20 05:00:07 UTC 2012
Author: gmiller
Date: Mon Aug 20 05:00:03 2012
New Revision: 240551
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240551
Log:
r240629 at FreeBSD-dev: root | 2012-08-17 20:46:07 -0500
Add some comments to the lock profiling code.
Modified:
soc2012/gmiller/locking-head/ (props changed)
soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h
soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c
Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h
==============================================================================
--- soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h Mon Aug 20 04:26:50 2012 (r240550)
+++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h Mon Aug 20 05:00:03 2012 (r240551)
@@ -727,6 +727,10 @@
extern struct urwlock _thr_list_lock __hidden;
extern struct umutex _thr_event_lock __hidden;
+/*
+ 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
@@ -748,11 +752,6 @@
int _mutex_owned(struct pthread *, const struct pthread_mutex *) __hidden;
int _mutex_reinit(pthread_mutex_t *) __hidden;
void _mutex_fork(struct pthread *curthread) __hidden;
-void _lock_profile_init(void) __hidden;
-void _lock_profile_obtain_failed(struct timespec *, const char *) __hidden;
-void _lock_profile_obtain_success(void *, struct timespec *, const char *,
- int) __hidden;
-void _lock_profile_release(void *, const char *file) __hidden;
void _libpthread_init(struct pthread *) __hidden;
struct pthread *_thr_alloc(struct pthread *) __hidden;
void _thread_exit(const char *, int, const char *) __hidden __dead2;
@@ -821,6 +820,12 @@
_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;
+void _lock_profile_obtain_success(void *, struct timespec *, const char *,
+ int) __hidden;
+void _lock_profile_release(void *, const char *file) __hidden;
+
#else
#define INIT_LOCK_PROFILING() do { } while (0)
Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Mon Aug 20 04:26:50 2012 (r240550)
+++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Mon Aug 20 05:00:03 2012 (r240551)
@@ -37,6 +37,10 @@
#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.
+*/
struct acquisition_point {
SLIST_ENTRY(acquisition_point) acq_point_next;
const char *file;
@@ -51,6 +55,10 @@
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.
+*/
struct acquisition {
LIST_ENTRY(acquisition) acq_next;
void *lock;
@@ -76,6 +84,11 @@
static int xml_indent = 0;
static FILE *xml_file;
+/*
+ The following functions are used to write out an XML file containing the
+ profiling data on exit.
+*/
+
static void
indent(void)
{
@@ -213,6 +226,10 @@
return (acq_point);
}
+/*
+ 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)
@@ -247,6 +264,11 @@
THR_CRITICAL_LEAVE(curthread);
}
+/*
+ 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)
{
@@ -259,6 +281,10 @@
}
}
+/*
+ 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)
{
@@ -323,6 +349,14 @@
THR_CRITICAL_LEAVE(curthread);
}
+/*
+ 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)
{
More information about the svn-soc-all
mailing list