From 5198821905d2c744344a505060a8260dac04fea4 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Thu, 29 Apr 2021 19:14:38 +0100 Subject: [PATCH] CR Feedback. --- src/mem/alloc.h | 24 ++++++++++++------------ src/mem/globalalloc.h | 4 ++-- src/mem/remoteallocator.h | 6 ++++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/mem/alloc.h b/src/mem/alloc.h index b628aa1..a81e6fa 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -512,7 +512,7 @@ namespace snmalloc DLList super_available; DLList super_only_short_available; - RemoteCache remote; + RemoteCache remote_cache; std::conditional_t remote_alloc; @@ -734,7 +734,8 @@ namespace snmalloc SNMALLOC_FAST_PATH void handle_dealloc_remote(CapPtr p) { - if (likely(Remote::trunc_target_id(p, &large_allocator) == get_trunc_id())) + auto target_id = Remote::trunc_target_id(p, &large_allocator); + if (likely(target_id == get_trunc_id())) { // Destined for my slabs auto p_auth = large_allocator.template capptr_amplify(p); @@ -745,10 +746,8 @@ namespace snmalloc { // Merely routing; despite the cast here, p is going to be cast right // back to a Remote. - remote.dealloc( - Remote::trunc_target_id(p, &large_allocator), - p.template as_reinterpret(), - p->sizeclass()); + remote_cache.dealloc( + target_id, p.template as_reinterpret(), p->sizeclass()); } } @@ -819,11 +818,11 @@ namespace snmalloc } // Our remote queues may be larger due to forwarding remote frees. - if (likely(remote.capacity > 0)) + if (likely(remote_cache.capacity > 0)) return; stats().remote_post(); - remote.post(this, get_trunc_id()); + remote_cache.post(this, get_trunc_id()); } /** @@ -1535,11 +1534,12 @@ namespace snmalloc // Check whether this will overflow the cache first. If we are a fake // allocator, then our cache will always be full and so we will never hit // this path. - if (remote.capacity > 0) + if (remote_cache.capacity > 0) { stats().remote_free(sizeclass); auto offseted = apply_cache_friendly_offset(p, sizeclass); - remote.dealloc(target->trunc_id(), offseted, sizeclass); + remote_cache.dealloc( + target->trunc_id(), offseted, sizeclass); return; } @@ -1578,10 +1578,10 @@ namespace snmalloc stats().remote_free(sizeclass); auto offseted = apply_cache_friendly_offset(p_auth, sizeclass); - remote.dealloc(target->trunc_id(), offseted, sizeclass); + remote_cache.dealloc(target->trunc_id(), offseted, sizeclass); stats().remote_post(); - remote.post(this, get_trunc_id()); + remote_cache.post(this, get_trunc_id()); } ChunkMap& chunkmap() diff --git a/src/mem/globalalloc.h b/src/mem/globalalloc.h index e4a5c27..7ce3189 100644 --- a/src/mem/globalalloc.h +++ b/src/mem/globalalloc.h @@ -123,10 +123,10 @@ namespace snmalloc // Post all remotes, including forwarded ones. If any allocator posts, // repeat the loop. - if (alloc->remote.capacity < REMOTE_CACHE) + if (alloc->remote_cache.capacity < REMOTE_CACHE) { alloc->stats().remote_post(); - alloc->remote.post(alloc, alloc->get_trunc_id()); + alloc->remote_cache.post(alloc, alloc->get_trunc_id()); done = false; } diff --git a/src/mem/remoteallocator.h b/src/mem/remoteallocator.h index 26d6867..0966eec 100644 --- a/src/mem/remoteallocator.h +++ b/src/mem/remoteallocator.h @@ -75,7 +75,8 @@ namespace snmalloc * Return allocator for this object. This may perform amplification. */ template - static alloc_id_t trunc_target_id(CapPtr r, LargeAlloc* large_allocator) + static alloc_id_t + trunc_target_id(CapPtr r, LargeAlloc* large_allocator) { #ifdef SNMALLOC_DONT_CACHE_ALLOCATOR_PTR // Rederive allocator id. @@ -248,7 +249,8 @@ namespace snmalloc // Use the next N bits to spread out remote deallocs in our own // slot. size_t slot = get_slot( - Remote::trunc_target_id(r, &allocator->large_allocator), post_round); + Remote::trunc_target_id(r, &allocator->large_allocator), + post_round); RemoteList* l = &list[slot]; l->last->non_atomic_next = r; l->last = r;