diff --git a/src/system/kernel/slab/HashedObjectCache.cpp b/src/system/kernel/slab/HashedObjectCache.cpp index 3de684091f..b90b129d5b 100644 --- a/src/system/kernel/slab/HashedObjectCache.cpp +++ b/src/system/kernel/slab/HashedObjectCache.cpp @@ -72,8 +72,6 @@ HashedObjectCache::Create(const char* name, size_t object_size, cache->slab_size = max_c(16 * B_PAGE_SIZE, 8 * object_size); cache->lower_boundary = __fls0(cache->object_size); - cache->objects_per_slab = cache->slab_size / cache->object_size; - return cache; } diff --git a/src/system/kernel/slab/ObjectCache.h b/src/system/kernel/slab/ObjectCache.h index b4cb59a828..9205886c53 100644 --- a/src/system/kernel/slab/ObjectCache.h +++ b/src/system/kernel/slab/ObjectCache.h @@ -47,7 +47,6 @@ struct ObjectCache : DoublyLinkedListLinkImpl { // minimum number of free objects size_t slab_size; - size_t objects_per_slab; size_t usage; size_t maximum; uint32 flags; diff --git a/src/system/kernel/slab/Slab.cpp b/src/system/kernel/slab/Slab.cpp index c939967e5a..57cc168cb0 100644 --- a/src/system/kernel/slab/Slab.cpp +++ b/src/system/kernel/slab/Slab.cpp @@ -312,20 +312,19 @@ increase_object_reserve(ObjectCache* cache) } +/*! Makes sure that \a objectCount objects can be allocated. +*/ static status_t object_cache_reserve_internal(ObjectCache* cache, size_t objectCount, uint32 flags, bool unlockWhileAllocating) { - size_t slabCount = (objectCount - 1) / cache->objects_per_slab + 1; - - while (slabCount > 0) { + while (objectCount > cache->total_objects - cache->used_count) { slab* newSlab = cache->CreateSlab(flags, unlockWhileAllocating); if (newSlab == NULL) return B_NO_MEMORY; cache->empty.Add(newSlab); cache->empty_count++; - slabCount--; } return B_OK; @@ -422,18 +421,12 @@ object_cache_resizer(void*) MutexLocker cacheLocker(cache->lock); - size_t freeObjects = cache->total_objects - cache->used_count; - - while (freeObjects < cache->min_object_reserve) { - status_t error = object_cache_reserve_internal(cache, - cache->min_object_reserve - freeObjects, 0, true); - if (error != B_OK) { - dprintf("object cache resizer: Failed to resize object cache " - "%p!\n", cache); - break; - } - - freeObjects = cache->total_objects - cache->used_count; + status_t error = object_cache_reserve_internal(cache, + cache->min_object_reserve, 0, true); + if (error != B_OK) { + dprintf("object cache resizer: Failed to resize object cache " + "%p!\n", cache); + break; } request->pending = false; diff --git a/src/system/kernel/slab/SmallObjectCache.cpp b/src/system/kernel/slab/SmallObjectCache.cpp index aa4b0af430..5af322cbe4 100644 --- a/src/system/kernel/slab/SmallObjectCache.cpp +++ b/src/system/kernel/slab/SmallObjectCache.cpp @@ -35,9 +35,6 @@ SmallObjectCache::Create(const char* name, size_t object_size, else cache->slab_size = B_PAGE_SIZE; - cache->objects_per_slab = (cache->slab_size - sizeof(slab)) - / cache->object_size; - return cache; }