diff options
author | Ramon Fernandez <ramon@mongodb.com> | 2016-08-26 18:28:48 -0400 |
---|---|---|
committer | Ramon Fernandez <ramon@mongodb.com> | 2016-08-26 18:28:48 -0400 |
commit | f2a613a41d6ad7b5a1b66087e386380d38e50599 (patch) | |
tree | 4843fb7b6a835e72046142046e9364f7d7dda992 /src/third_party/wiredtiger/src/include/mutex.i | |
parent | 7614c0eb2449eb4ec22d21b677177124d61f1888 (diff) | |
download | mongo-f2a613a41d6ad7b5a1b66087e386380d38e50599.tar.gz |
Import wiredtiger: 2566118fc68b0124187e806bed52eb7cdbcb1be0 from branch mongodb-3.4
ref: 34182ad..2566118fc6
for: 3.3.12
WT-2631 nullptr is passed for parameters marked with attribute non-null
WT-2638 ftruncate may not be supported
WT-2645 wt dump: push the complexity of collecting metadata into a dump cursor
WT-2678 The metadata should not imply that an empty value is true
WT-2695 Integrate s390x accelerated crc32c support
WT-2719 add fuzz testing for WiredTiger options and reconfiguration.
WT-2734 Improve documentation of eviction behavior
WT-2766 Don't count eviction of lookaside file pages for the purpose of checking stuck cache
WT-2783 wtperf multi-btree.wtperf dumps core on Mac
WT-2787 Include src/include/wiredtiger_ext.h is problematic
WT-2795 Update documentation around read-only configuration
WT-2807 Switch Jenkins performance tests to tcmalloc
WT-2813 small cache usage stuck even with large cache
WT-2814 Enhance wtperf to support single-op truncate mode
WT-2816 Improve WiredTiger eviction performance
WT-2817 Investigate performance regression in develop, add workload to wtperf/runners
WT-2818 The page visibility check when queuing pages for eviction is overly restrictive
WT-2820 add gcc warn_unused_result attribute
WT-2822 panic mutex and other functions that cannot fail
WT-2823 support file handles without a truncate method
WT-2826 clang38 false positive on uninitialized variable.
WT-2827 checkpoint log_size configuration improvements
WT-2828 Make long wtperf tests reflect mongoDB usage
WT-2829 Switch automated testing to use enable-strict configure option
WT-2832 Python test uses hard-coded temporary directory
WT-2834 Join cursor: discrepancy with bloom filters
WT-2835 WT_CONNECTION.leak-memory can skip memory map and cache cleanup
WT-2838 Don't free session handles on close if leak memory is configured
WT-2839 lint: Ignoring return value of function
WT-2840 clang analysis: garbage values
WT-2841 Jenkins Valgrind runner is reporting errors in test wt2719_reconfig
WT-2843 Fix a bug in recovery if there is no filesystem truncate support
WT-2846 Several bugs related to reconfiguring eviction server at runtime
WT-2847 Merge fair locks into read/write locks.
WT-2850 clang 4.1 attribute warnings when building
WT-2853 Multi threaded reader writer example shows temporary slowdown or lockup
WT-2857 POSIX ftruncate calls should be #ifdef'd HAVE_FTRUNCATE
WT-2862 Fix lint error in test case for forced eviction with multiple cursors
WT-2863 Support UTF-8 paths on Windows
Diffstat (limited to 'src/third_party/wiredtiger/src/include/mutex.i')
-rw-r--r-- | src/third_party/wiredtiger/src/include/mutex.i | 126 |
1 files changed, 15 insertions, 111 deletions
diff --git a/src/third_party/wiredtiger/src/include/mutex.i b/src/third_party/wiredtiger/src/include/mutex.i index 65956c13c08..cb1847d9991 100644 --- a/src/third_party/wiredtiger/src/include/mutex.i +++ b/src/third_party/wiredtiger/src/include/mutex.i @@ -154,9 +154,10 @@ __wt_spin_trylock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) static inline void __wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { - WT_UNUSED(session); + WT_DECL_RET; - (void)pthread_mutex_lock(&t->lock); + if ((ret = pthread_mutex_lock(&t->lock)) != 0) + WT_PANIC_MSG(session, ret, "pthread_mutex_lock: %s", t->name); } #endif @@ -167,16 +168,14 @@ __wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) static inline void __wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { - WT_UNUSED(session); + WT_DECL_RET; - (void)pthread_mutex_unlock(&t->lock); + if ((ret = pthread_mutex_unlock(&t->lock)) != 0) + WT_PANIC_MSG(session, ret, "pthread_mutex_unlock: %s", t->name); } #elif SPINLOCK_TYPE == SPINLOCK_MSVC -#define WT_SPINLOCK_REGISTER -1 -#define WT_SPINLOCK_REGISTER_FAILED -2 - /* * __wt_spin_init -- * Initialize a spinlock. @@ -184,13 +183,18 @@ __wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) static inline int __wt_spin_init(WT_SESSION_IMPL *session, WT_SPINLOCK *t, const char *name) { - WT_UNUSED(session); + DWORD windows_error; + + if (InitializeCriticalSectionAndSpinCount(&t->lock, 4000) == 0) { + windows_error = __wt_getlasterror(); + __wt_errx(session, + "%s: InitializeCriticalSectionAndSpinCount: %s", + name, __wt_formatmessage(session, windows_error)); + return (__wt_map_windows_error(windows_error)); + } t->name = name; t->initialized = 1; - - InitializeCriticalSectionAndSpinCount(&t->lock, 4000); - return (0); } @@ -251,103 +255,3 @@ __wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) #error Unknown spinlock type #endif - -/* - * __wt_fair_trylock -- - * Try to get a lock - give up if it is not immediately available. - */ -static inline int -__wt_fair_trylock(WT_SESSION_IMPL *session, WT_FAIR_LOCK *lock) -{ - WT_FAIR_LOCK new, old; - - WT_UNUSED(session); - - old = new = *lock; - - /* Exit early if there is no chance we can get the lock. */ - if (old.fair_lock_waiter != old.fair_lock_owner) - return (EBUSY); - - /* The replacement lock value is a result of allocating a new ticket. */ - ++new.fair_lock_waiter; - return (__wt_atomic_cas32( - &lock->u.lock, old.u.lock, new.u.lock) ? 0 : EBUSY); -} - -/* - * __wt_fair_lock -- - * Get a lock. - */ -static inline int -__wt_fair_lock(WT_SESSION_IMPL *session, WT_FAIR_LOCK *lock) -{ - uint16_t ticket; - int pause_cnt; - - WT_UNUSED(session); - - /* - * Possibly wrap: if we have more than 64K lockers waiting, the ticket - * value will wrap and two lockers will simultaneously be granted the - * lock. - */ - ticket = __wt_atomic_fetch_add16(&lock->fair_lock_waiter, 1); - for (pause_cnt = 0; ticket != lock->fair_lock_owner;) { - /* - * We failed to get the lock; pause before retrying and if we've - * paused enough, sleep so we don't burn CPU to no purpose. This - * situation happens if there are more threads than cores in the - * system and we're thrashing on shared resources. - */ - if (++pause_cnt < WT_THOUSAND) - WT_PAUSE(); - else - __wt_sleep(0, 10); - } - - /* - * Applications depend on a barrier here so that operations holding the - * lock see consistent data. - */ - WT_READ_BARRIER(); - - return (0); -} - -/* - * __wt_fair_unlock -- - * Release a shared lock. - */ -static inline int -__wt_fair_unlock(WT_SESSION_IMPL *session, WT_FAIR_LOCK *lock) -{ - WT_UNUSED(session); - - /* - * Ensure that all updates made while the lock was held are visible to - * the next thread to acquire the lock. - */ - WT_WRITE_BARRIER(); - - /* - * We have exclusive access - the update does not need to be atomic. - */ - ++lock->fair_lock_owner; - - return (0); -} - -#ifdef HAVE_DIAGNOSTIC -/* - * __wt_fair_islocked -- - * Test whether the lock is currently held. - */ -static inline bool -__wt_fair_islocked(WT_SESSION_IMPL *session, WT_FAIR_LOCK *lock) -{ - WT_UNUSED(session); - - return (lock->fair_lock_waiter != lock->fair_lock_owner); -} -#endif |