summaryrefslogtreecommitdiffstats
path: root/include/jemalloc
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2017-02-06 07:58:02 (GMT)
committerJason Evans <jasone@canonware.com>2017-02-09 02:50:03 (GMT)
commitdb7da563595e49fa56cfd2b94cc77fed3d8ac755 (patch)
treecd433bb0aad8fa5d486c65cbe5f79e365dc056d3 /include/jemalloc
parentde8a68e85304848189643fb48100c18aa9d60e32 (diff)
downloadjemalloc-db7da563595e49fa56cfd2b94cc77fed3d8ac755.zip
jemalloc-db7da563595e49fa56cfd2b94cc77fed3d8ac755.tar.gz
jemalloc-db7da563595e49fa56cfd2b94cc77fed3d8ac755.tar.bz2
Spin adaptively in rtree_elm_acquire().
Diffstat (limited to 'include/jemalloc')
-rw-r--r--include/jemalloc/internal/rtree_inlines.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/include/jemalloc/internal/rtree_inlines.h b/include/jemalloc/internal/rtree_inlines.h
index 0d96948..4de0479 100644
--- a/include/jemalloc/internal/rtree_inlines.h
+++ b/include/jemalloc/internal/rtree_inlines.h
@@ -153,21 +153,22 @@ rtree_read(tsdn_t *tsdn, rtree_t *rtree, rtree_ctx_t *rtree_ctx, uintptr_t key,
JEMALLOC_INLINE rtree_elm_t *
rtree_elm_acquire(tsdn_t *tsdn, rtree_t *rtree, rtree_ctx_t *rtree_ctx,
uintptr_t key, bool dependent, bool init_missing) {
- rtree_elm_t *elm;
-
- elm = rtree_elm_lookup(tsdn, rtree, rtree_ctx, key, dependent,
- init_missing);
+ rtree_elm_t *elm = rtree_elm_lookup(tsdn, rtree, rtree_ctx, key,
+ dependent, init_missing);
if (!dependent && elm == NULL) {
return NULL;
}
- extent_t *extent;
- void *s;
- do {
- extent = rtree_elm_read(elm, false);
+ spin_t spinner = SPIN_INITIALIZER;
+ while (true) {
+ extent_t *extent = rtree_elm_read(elm, false);
/* The least significant bit serves as a lock. */
- s = (void *)((uintptr_t)extent | (uintptr_t)0x1);
- } while (atomic_cas_p(&elm->pun, (void *)extent, s));
+ void *s = (void *)((uintptr_t)extent | (uintptr_t)0x1);
+ if (!atomic_cas_p(&elm->pun, (void *)extent, s)) {
+ break;
+ }
+ spin_adaptive(&spinner);
+ }
if (config_debug) {
rtree_elm_witness_acquire(tsdn, rtree, key, elm);