[haiku-commits] r35204 - haiku/trunk/src/system/kernel/slab

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 20 Jan 2010 19:05:00 +0100 (CET)

Author: bonefish
Date: 2010-01-20 19:05:00 +0100 (Wed, 20 Jan 2010)
New Revision: 35204
Changeset: http://dev.haiku-os.org/changeset/35204/haiku

Modified:
   haiku/trunk/src/system/kernel/slab/HashedObjectCache.cpp
   haiku/trunk/src/system/kernel/slab/ObjectCache.h
   haiku/trunk/src/system/kernel/slab/Slab.cpp
   haiku/trunk/src/system/kernel/slab/SmallObjectCache.cpp
Log:
* Reverted r35203, i.e. ObjectCache::object_per_slab is gone again.
* Changed the semantics of object_cache_reserve_internal(). Now it makes sure
  the given number of objects are free. As a side effect this also changes
  the semantics of object_cache_reserve() similarly, though I have trouble
  seeing the purpose of the function in the first place.


Modified: haiku/trunk/src/system/kernel/slab/HashedObjectCache.cpp
===================================================================
--- haiku/trunk/src/system/kernel/slab/HashedObjectCache.cpp    2010-01-20 
17:46:06 UTC (rev 35203)
+++ haiku/trunk/src/system/kernel/slab/HashedObjectCache.cpp    2010-01-20 
18:05:00 UTC (rev 35204)
@@ -72,8 +72,6 @@
                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;
 }
 

Modified: haiku/trunk/src/system/kernel/slab/ObjectCache.h
===================================================================
--- haiku/trunk/src/system/kernel/slab/ObjectCache.h    2010-01-20 17:46:06 UTC 
(rev 35203)
+++ haiku/trunk/src/system/kernel/slab/ObjectCache.h    2010-01-20 18:05:00 UTC 
(rev 35204)
@@ -47,7 +47,6 @@
                                                                        // 
minimum number of free objects
 
                        size_t                          slab_size;
-                       size_t                          objects_per_slab;
                        size_t                          usage;
                        size_t                          maximum;
                        uint32                          flags;

Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp
===================================================================
--- haiku/trunk/src/system/kernel/slab/Slab.cpp 2010-01-20 17:46:06 UTC (rev 
35203)
+++ haiku/trunk/src/system/kernel/slab/Slab.cpp 2010-01-20 18:05:00 UTC (rev 
35204)
@@ -312,20 +312,19 @@
 }
 
 
+/*!    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 @@
 
                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;

Modified: haiku/trunk/src/system/kernel/slab/SmallObjectCache.cpp
===================================================================
--- haiku/trunk/src/system/kernel/slab/SmallObjectCache.cpp     2010-01-20 
17:46:06 UTC (rev 35203)
+++ haiku/trunk/src/system/kernel/slab/SmallObjectCache.cpp     2010-01-20 
18:05:00 UTC (rev 35204)
@@ -35,9 +35,6 @@
        else
                cache->slab_size = B_PAGE_SIZE;
 
-       cache->objects_per_slab = (cache->slab_size - sizeof(slab))
-               / cache->object_size;
-
        return cache;
 }
 


Other related posts:

  • » [haiku-commits] r35204 - haiku/trunk/src/system/kernel/slab - ingo_weinhold