Author: bonefish Date: 2010-01-19 21:45:20 +0100 (Tue, 19 Jan 2010) New Revision: 35182 Changeset: http://dev.haiku-os.org/changeset/35182/haiku Modified: haiku/trunk/src/system/kernel/slab/ObjectCache.cpp haiku/trunk/src/system/kernel/slab/Slab.cpp Log: * 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. Modified: haiku/trunk/src/system/kernel/slab/ObjectCache.cpp =================================================================== --- haiku/trunk/src/system/kernel/slab/ObjectCache.cpp 2010-01-19 20:37:39 UTC (rev 35181) +++ haiku/trunk/src/system/kernel/slab/ObjectCache.cpp 2010-01-19 20:45:20 UTC (rev 35182) @@ -10,11 +10,13 @@ #include <string.h> -#include "slab_private.h" +#include <util/AutoLock.h> #include <vm/vm.h> #include <vm/VMAddressSpace.h> +#include "slab_private.h" + static const size_t kCacheColorPeriod = 8; kernel_args* ObjectCache::sKernelArgs = NULL; @@ -34,7 +36,10 @@ 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 @@ 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)) { Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp =================================================================== --- haiku/trunk/src/system/kernel/slab/Slab.cpp 2010-01-19 20:37:39 UTC (rev 35181) +++ haiku/trunk/src/system/kernel/slab/Slab.cpp 2010-01-19 20:45:20 UTC (rev 35182) @@ -478,11 +478,11 @@ 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())