diff options
-rw-r--r-- | src/conn/conn_cache_pool.c | 17 | ||||
-rw-r--r-- | src/include/cache.h | 7 | ||||
-rw-r--r-- | src/include/hardware.h | 13 |
3 files changed, 12 insertions, 25 deletions
diff --git a/src/conn/conn_cache_pool.c b/src/conn/conn_cache_pool.c index 22af88c66b1..aa14e9aadde 100644 --- a/src/conn/conn_cache_pool.c +++ b/src/conn/conn_cache_pool.c @@ -277,7 +277,7 @@ __wt_conn_cache_pool_open(WT_SESSION_IMPL *session) * in each connection saves having a complex election process when * the active connection shuts down. */ - F_SET_ATOMIC(cp, WT_CACHE_POOL_ACTIVE); + F_SET(cp, WT_CACHE_POOL_ACTIVE); F_SET(cache, WT_CACHE_POOL_RUN); WT_RET(__wt_thread_create(session, &cache->cp_tid, __wt_cache_pool_server, cache->cp_session)); @@ -368,10 +368,10 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) if (--cp->refs == 0) { WT_ASSERT(session, TAILQ_EMPTY(&cp->cache_pool_qh)); - F_CLR_ATOMIC(cp, WT_CACHE_POOL_ACTIVE); + F_CLR(cp, WT_CACHE_POOL_ACTIVE); } - if (!F_ISSET_ATOMIC(cp, WT_CACHE_POOL_ACTIVE)) { + if (!F_ISSET(cp, WT_CACHE_POOL_ACTIVE)) { WT_TRET(__wt_verbose( session, WT_VERB_SHARED_CACHE, "Destroying cache pool")); __wt_spin_lock(session, &__wt_process.spinlock); @@ -400,7 +400,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) /* Notify other participants if we were managing */ if (F_ISSET(cache, WT_CACHE_POOL_MANAGER)) { - F_CLR_ATOMIC(cp, WT_CACHE_POOL_MANAGED); + cp->pool_managed = 0; WT_TRET(__wt_verbose(session, WT_VERB_SHARED_CACHE, "Shutting down shared cache manager connection")); } @@ -440,7 +440,7 @@ __cache_pool_balance(WT_SESSION_IMPL *session, bool forward) * - Reduce the amount allocated, if we are over the budget * - Increase the amount used if there is capacity and any pressure. */ - while (F_ISSET_ATOMIC(cp, WT_CACHE_POOL_ACTIVE) && + while (F_ISSET(cp, WT_CACHE_POOL_ACTIVE) && F_ISSET(S2C(session)->cache, WT_CACHE_POOL_RUN)) { WT_ERR(__cache_pool_adjust( session, highest, bump_threshold, forward, &adjusted)); @@ -730,7 +730,7 @@ __wt_cache_pool_server(void *arg) cache = S2C(session)->cache; forward = true; - while (F_ISSET_ATOMIC(cp, WT_CACHE_POOL_ACTIVE) && + while (F_ISSET(cp, WT_CACHE_POOL_ACTIVE) && F_ISSET(cache, WT_CACHE_POOL_RUN)) { if (cp->currently_used <= cp->size) WT_ERR(__wt_cond_wait(session, @@ -740,13 +740,12 @@ __wt_cache_pool_server(void *arg) * Re-check pool run flag - since we want to avoid getting the * lock on shutdown. */ - if (!F_ISSET_ATOMIC(cp, WT_CACHE_POOL_ACTIVE) && + if (!F_ISSET(cp, WT_CACHE_POOL_ACTIVE) && F_ISSET(cache, WT_CACHE_POOL_RUN)) break; /* Try to become the managing thread */ - F_CAS_ATOMIC(cp, WT_CACHE_POOL_MANAGED, ret); - if (ret == 0) { + if (__wt_atomic_cas8(&cp->pool_managed, 0, 1)) { F_SET(cache, WT_CACHE_POOL_MANAGER); WT_ERR(__wt_verbose(session, WT_VERB_SHARED_CACHE, "Cache pool switched manager thread")); diff --git a/src/include/cache.h b/src/include/cache.h index f199372ea5e..caf8996e68b 100644 --- a/src/include/cache.h +++ b/src/include/cache.h @@ -151,7 +151,8 @@ struct __wt_cache_pool { /* Locked: List of connections participating in the cache pool. */ TAILQ_HEAD(__wt_cache_pool_qh, __wt_connection_impl) cache_pool_qh; -#define WT_CACHE_POOL_MANAGED 0x01 /* Cache pool has a manager thread */ -#define WT_CACHE_POOL_ACTIVE 0x02 /* Cache pool is active */ - uint8_t flags_atomic; + uint8_t pool_managed; /* Cache pool has a manager thread */ + +#define WT_CACHE_POOL_ACTIVE 0x01 /* Cache pool is active */ + uint8_t flags; }; diff --git a/src/include/hardware.h b/src/include/hardware.h index c9b72f8a609..1ab2c3d39c4 100644 --- a/src/include/hardware.h +++ b/src/include/hardware.h @@ -37,19 +37,6 @@ &(p)->flags_atomic, __orig, __orig | (uint8_t)(mask))); \ } while (0) -#define F_CAS_ATOMIC(p, mask, ret) do { \ - uint8_t __orig; \ - ret = 0; \ - do { \ - __orig = (p)->flags_atomic; \ - if ((__orig & (uint8_t)(mask)) != 0) { \ - ret = EBUSY; \ - break; \ - } \ - } while (!__wt_atomic_cas8( \ - &(p)->flags_atomic, __orig, __orig | (uint8_t)(mask))); \ -} while (0) - #define F_CLR_ATOMIC(p, mask) do { \ uint8_t __orig; \ do { \ |