From 20ca0c5eaa6a1d4e0a3ddc9d203eab905b3a34d7 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 19 Jan 2010 20:45:20 +0000 Subject: [PATCH] * object_cache_return_object_wrapper(): Calling object_cache_free() is a bad idea, since that would potentially add the object back to the object store or lead to infinite recursion. When the object cache is destroyed it most likely led to infinite loops, because the object would alternately be removed from and added back to the object store. * delete_object_cache(): Lock after destroying the object store, so we don't deadlock. * Use the object store on SMP machines. It seems to work, though I only tested with the network stack and that seems to have problems of its own. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35182 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/slab/ObjectCache.cpp | 12 ++++++++---- src/system/kernel/slab/Slab.cpp | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/system/kernel/slab/ObjectCache.cpp b/src/system/kernel/slab/ObjectCache.cpp index 87cc221bcb..2a0663a8bd 100644 --- a/src/system/kernel/slab/ObjectCache.cpp +++ b/src/system/kernel/slab/ObjectCache.cpp @@ -10,10 +10,12 @@ #include -#include "slab_private.h" +#include #include #include +#include "slab_private.h" + static const size_t kCacheColorPeriod = 8; @@ -34,7 +36,10 @@ static void object_cache_return_object_wrapper(object_depot* depot, void* cookie, void* object) { - object_cache_free((ObjectCache*)cookie, object); + ObjectCache* cache = (ObjectCache*)cookie; + + MutexLocker _(cache->lock); + cache->ReturnObjectToSlab(cache->ObjectSlab(object), object); } @@ -81,9 +86,8 @@ ObjectCache::Init(const char* name, size_t objectSize, resize_request = NULL; - // TODO: depot destruction is obviously broken // no gain in using the depot in single cpu setups - //if (smp_get_num_cpus() == 1) + if (smp_get_num_cpus() == 1) this->flags |= CACHE_NO_DEPOT; if (!(this->flags & CACHE_NO_DEPOT)) { diff --git a/src/system/kernel/slab/Slab.cpp b/src/system/kernel/slab/Slab.cpp index aa6aeb6e09..1d476d7e7f 100644 --- a/src/system/kernel/slab/Slab.cpp +++ b/src/system/kernel/slab/Slab.cpp @@ -478,11 +478,11 @@ delete_object_cache(object_cache* cache) sObjectCaches.Remove(cache); } - mutex_lock(&cache->lock); - if (!(cache->flags & CACHE_NO_DEPOT)) object_depot_destroy(&cache->depot); + mutex_lock(&cache->lock); + unregister_low_resource_handler(object_cache_low_memory, cache); if (!cache->full.IsEmpty())