Date: Sat, 16 Jun 2012 21:17:03 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r237812 - in soc2012/gmiller/locking-head: include lib/libthr/thread Message-ID: <20120616211703.9FDB81065677@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gmiller Date: Sat Jun 16 21:17:03 2012 New Revision: 237812 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=237812 Log: Implement profiling of spinlocks. Modified: soc2012/gmiller/locking-head/include/pthread.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/libthr/thread/thr_pspinlock.c Modified: soc2012/gmiller/locking-head/include/pthread.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread.h Sat Jun 16 20:49:08 2012 (r237811) +++ soc2012/gmiller/locking-head/include/pthread.h Sat Jun 16 21:17:03 2012 (r237812) @@ -344,6 +344,8 @@ int _pthread_spin_trylock_profiled(pthread_spinlock_t *, const char *, int); +int _pthread_spin_unlock_profiled(pthread_spinlock_t *, + const char *, int); #ifdef pthread_mutex_lock @@ -359,8 +361,10 @@ #undef pthread_rwlock_timedwrlock #undef pthread_rwlock_tryrdlock #undef pthread_rwlock_trywrlock +#undef pthread_rwlock_unlock #undef pthread_spin_lock #undef pthread_spin_trylock +#undef pthread_spin_unlock #endif @@ -392,6 +396,8 @@ _pthread_spin_lock(s, __FILE__, __LINE__) #define pthread_spin_trylock(s) \ _pthread_spin_trylock(s, __FILE__, __LINE__) +#define pthread_spin_unlock(s) \ + _pthread_spin_unlock(s, __FILE__, __LINE__) #endif Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h Sat Jun 16 20:49:08 2012 (r237811) +++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_private.h Sat Jun 16 21:17:03 2012 (r237812) @@ -754,11 +754,6 @@ void _lock_profile_obtain_success(void *, struct timespec *, const char *, int) __hidden; void _lock_profile_release(void *, const char *file) __hidden; -void _spin_obtain_success(struct pthread_spinlock *, - struct timespec *wait_time, const char *file, int line) __hidden; -void _spin_obtain_failed(struct pthread_spinlock *, - struct timespec *wait_time) __hidden; -void _spin_release(struct pthread_spinlock *, struct timespec *) __hidden; void _libpthread_init(struct pthread *) __hidden; struct pthread *_thr_alloc(struct pthread *) __hidden; void _thread_exit(const char *, int, const char *) __hidden __dead2; @@ -826,12 +821,6 @@ #define LOCK_PROFILE_OBTAIN_FAILED(ts) \ _lock_profile_obtain_failed(ts, file) #define LOCK_PROFILE_RELEASE(l) _lock_profile_release(l, file) -#define SPIN_OBTAIN_SUCCESS(s, ts) \ - _spin_obtain_success(s, ts, file, line) -#define SPIN_OBTAIN_FAILED(s, ts) \ - _spin_obtain_failed(s, ts) -#define SPIN_RELEASE(s, ts) \ - _spin_release(s, ts) #else @@ -839,9 +828,6 @@ #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 SPIN_OBTAIN_SUCCESS(s, ts) do { } while (0) -#define SPIN_OBTAIN_FAILED(s, ts) do { } while (0) -#define SPIN_RELEASE(s, ts) 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 Sat Jun 16 20:49:08 2012 (r237811) +++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Sat Jun 16 21:17:03 2012 (r237812) @@ -240,22 +240,6 @@ THR_CRITICAL_LEAVE(curthread); } -void -_spin_obtain_success(struct pthread_spinlock *s, struct timespec *wait_time, - const char *file, int line) -{ -} - -void -_spin_obtain_failed(struct pthread_spinlock *s, struct timespec *wait_time) -{ -} - -void -_spin_release(struct pthread_spinlock *s, struct timespec *wait_time) -{ -} - static int find_next_record(struct pthread_statistics_np *stats) { Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_pspinlock.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libthr/thread/thr_pspinlock.c Sat Jun 16 20:49:08 2012 (r237811) +++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_pspinlock.c Sat Jun 16 21:17:03 2012 (r237812) @@ -44,10 +44,12 @@ #ifdef LOCK_PROFILING -int _pthread_spin_trylock_profiled(pthread_spinlock_t *lock, - const char *file, int line); int _pthread_spin_lock_profiled(pthread_spinlock_t *lock, const char *file, int line); +int _pthread_spin_trylock_profiled(pthread_spinlock_t *lock, + const char *file, int line); +int _pthread_spin_unlock_profiled(pthread_spinlock_t *lock, + const char *file, int line); #endif @@ -111,9 +113,9 @@ else { ret = THR_UMUTEX_TRYLOCK(curthread, &lck->s_lock); if (ret == 0) { - SPIN_OBTAIN_SUCCESS(lck, &waittime); + LOCK_PROFILE_OBTAIN_SUCCESS(lck, &waittime); } else { - SPIN_OBTAIN_FAILED(lck, &waittime); + LOCK_PROFILE_OBTAIN_FAILED(&waittime); } } @@ -149,7 +151,7 @@ #ifdef LOCK_PROFILING if (!spin_needed) { spin_needed = 1; - SPIN_OBTAIN_FAILED(lck, &waittime); + LOCK_PROFILE_OBTAIN_FAILED(&waittime); } #endif while (lck->s_lock.m_owner) { @@ -166,7 +168,7 @@ } } ret = 0; - SPIN_OBTAIN_SUCCESS(lck, &waittime); + LOCK_PROFILE_OBTAIN_SUCCESS(lck, &waittime); } return (ret); @@ -174,21 +176,26 @@ int _pthread_spin_unlock(pthread_spinlock_t *lock) +#ifdef LOCK_PROFILING +{ + return (_pthread_spin_unlock_profiled(lock, NULL, 0)); +} + +int +_pthread_spin_unlock_profiled(pthread_spinlock_t *lock, const char *file, + int line) +#endif { struct pthread *curthread = _get_curthread(); struct pthread_spinlock *lck; int ret; -#ifdef LOCK_PROFILING - struct timespec waittime; - bzero(&waittime, sizeof(waittime)); -#endif if (lock == NULL || (lck = *lock) == NULL) ret = EINVAL; else { ret = THR_UMUTEX_UNLOCK(curthread, &lck->s_lock); if (ret == 0) { - SPIN_RELEASE(lck, &waittime); + LOCK_PROFILE_RELEASE(lck); } } return (ret);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120616211703.9FDB81065677>