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

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 15 Feb 2010 14:22:58 +0100 (CET)

Author: axeld
Date: 2010-02-15 14:22:58 +0100 (Mon, 15 Feb 2010)
New Revision: 35466
Changeset: http://dev.haiku-os.org/changeset/35466/haiku

Modified:
   haiku/trunk/src/system/kernel/slab/ObjectDepot.cpp
   haiku/trunk/src/system/kernel/slab/Slab.cpp
   haiku/trunk/src/system/kernel/slab/slab_private.h
Log:
* Fixed maintaining the object depot's free magazine count (it's not really used
  though).
* Added/improved some KDL commands to make the slab easier to work with from
  KDL.


Modified: haiku/trunk/src/system/kernel/slab/ObjectDepot.cpp
===================================================================
--- haiku/trunk/src/system/kernel/slab/ObjectDepot.cpp  2010-02-15 13:20:01 UTC 
(rev 35465)
+++ haiku/trunk/src/system/kernel/slab/ObjectDepot.cpp  2010-02-15 13:22:58 UTC 
(rev 35466)
@@ -1,6 +1,6 @@
 /*
  * Copyright 2010, Ingo Weinhold, ingo_weinhold@xxxxxxx
- * Copyright 2008, Axel Dörfler. All Rights Reserved.
+ * Copyright 2008-2010, Axel Dörfler. All Rights Reserved.
  * Copyright 2007, Hugo Santos. All Rights Reserved.
  *
  * Distributed under the terms of the MIT License.
@@ -76,6 +76,9 @@
 }
 
 
+// #pragma mark -
+
+
 static DepotMagazine*
 alloc_magazine(uint32 flags)
 {
@@ -150,6 +153,7 @@
        SpinLocker _(depot->inner_lock);
 
        _push(depot->empty, magazine);
+       depot->empty_count++;
 }
 
 
@@ -322,3 +326,55 @@
        while (emptyMagazines)
                free_magazine(_pop(emptyMagazines), flags);
 }
+
+
+// #pragma mark - private kernel API
+
+
+void
+dump_object_depot(object_depot* depot)
+{
+       kprintf("  full:  %p, count %lu\n", depot->full, depot->full_count);
+       kprintf("  empty: %p, count %lu\n", depot->empty, depot->empty_count);
+       kprintf("  stores:\n");
+
+       int cpuCount = smp_get_num_cpus();
+
+       for (int i = 0; i < cpuCount; i++) {
+               kprintf("  [%d] loaded:   %p\n", i, depot->stores[i].loaded);
+               kprintf("      previous: %p\n", depot->stores[i].previous);
+       }
+}
+
+
+int
+dump_object_depot(int argCount, char** args)
+{
+       if (argCount != 2)
+               kprintf("usage: %s [address]\n", args[0]);
+       else
+               dump_object_depot((object_depot*)parse_expression(args[1]));
+
+       return 0;
+}
+
+
+int
+dump_depot_magazine(int argCount, char** args)
+{
+       if (argCount != 2) {
+               kprintf("usage: %s [address]\n", args[0]);
+               return 0;
+       }
+
+       DepotMagazine* magazine = (DepotMagazine*)parse_expression(args[1]);
+
+       kprintf("next:          %p\n", magazine->next);
+       kprintf("current_round: %u\n", magazine->current_round);
+       kprintf("round_count:   %u\n", magazine->round_count);
+
+       for (uint16 i = 0; i < magazine->current_round; i++)
+               kprintf("  [%i] %p\n", i, magazine->rounds[i]);
+
+       return 0;
+}

Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp
===================================================================
--- haiku/trunk/src/system/kernel/slab/Slab.cpp 2010-02-15 13:20:01 UTC (rev 
35465)
+++ haiku/trunk/src/system/kernel/slab/Slab.cpp 2010-02-15 13:22:58 UTC (rev 
35466)
@@ -1,6 +1,6 @@
 /*
  * Copyright 2010, Ingo Weinhold <ingo_weinhold@xxxxxx>.
- * Copyright 2008, Axel Dörfler. All Rights Reserved.
+ * Copyright 2008-2010, Axel Dörfler. All Rights Reserved.
  * Copyright 2007, Hugo Santos. All Rights Reserved.
  *
  * Distributed under the terms of the MIT License.
@@ -226,23 +226,28 @@
                return 0;
        }
 
-       ObjectCache* cache = (ObjectCache*)strtoul(argv[1], NULL, 16);
+       ObjectCache* cache = (ObjectCache*)parse_expression(argv[1]);
 
-       kprintf("name: %s\n", cache->name);
-       kprintf("lock: %p\n", &cache->lock);
-       kprintf("object_size: %lu\n", cache->object_size);
+       kprintf("name:              %s\n", cache->name);
+       kprintf("lock:              %p\n", &cache->lock);
+       kprintf("object_size:       %lu\n", cache->object_size);
        kprintf("cache_color_cycle: %lu\n", cache->cache_color_cycle);
-       kprintf("used_count: %lu\n", cache->used_count);
-       kprintf("empty_count: %lu\n", cache->empty_count);
-       kprintf("pressure: %lu\n", cache->pressure);
-       kprintf("slab_size: %lu\n", cache->slab_size);
-       kprintf("usage: %lu\n", cache->usage);
-       kprintf("maximum: %lu\n", cache->maximum);
-       kprintf("flags: 0x%lx\n", cache->flags);
-       kprintf("cookie: %p\n", cache->cookie);
+       kprintf("used_count:        %lu\n", cache->used_count);
+       kprintf("empty_count:       %lu\n", cache->empty_count);
+       kprintf("pressure:          %lu\n", cache->pressure);
+       kprintf("slab_size:         %lu\n", cache->slab_size);
+       kprintf("usage:             %lu\n", cache->usage);
+       kprintf("maximum:           %lu\n", cache->maximum);
+       kprintf("flags:             0x%lx\n", cache->flags);
+       kprintf("cookie:            %p\n", cache->cookie);
        kprintf("resize entry don't wait: %p\n", cache->resize_entry_dont_wait);
-       kprintf("resize entry can wait: %p\n", cache->resize_entry_can_wait);
+       kprintf("resize entry can wait:   %p\n", cache->resize_entry_can_wait);
 
+       if ((cache->flags & CACHE_NO_DEPOT) == 0) {
+               kprintf("depot:\n");
+               dump_object_depot(&cache->depot);
+       }
+
        return 0;
 }
 
@@ -735,6 +740,10 @@
        add_debugger_command("slabs", dump_slabs, "list all object caches");
        add_debugger_command("slab_cache", dump_cache_info,
                "dump information about a specific object cache");
+       add_debugger_command("slab_depot", dump_object_depot,
+               "dump contents of an object depot");
+       add_debugger_command("slab_magazine", dump_depot_magazine,
+               "dump contents of a depot magazine");
 }
 
 

Modified: haiku/trunk/src/system/kernel/slab/slab_private.h
===================================================================
--- haiku/trunk/src/system/kernel/slab/slab_private.h   2010-02-15 13:20:01 UTC 
(rev 35465)
+++ haiku/trunk/src/system/kernel/slab/slab_private.h   2010-02-15 13:22:58 UTC 
(rev 35466)
@@ -27,7 +27,9 @@
 #include <debug_paranoia.h>
 
 struct ObjectCache;
+struct object_depot;
 
+
 void           request_memory_manager_maintenance();
 
 void*          block_alloc(size_t size, size_t alignment, uint32 flags);
@@ -36,7 +38,11 @@
 void           block_allocator_init_boot();
 void           block_allocator_init_rest();
 
+void           dump_object_depot(object_depot* depot);
+int                    dump_object_depot(int argCount, char** args);
+int                    dump_depot_magazine(int argCount, char** args);
 
+
 template<typename Type>
 static inline Type*
 _pop(Type*& head)


Other related posts:

  • » [haiku-commits] r35466 - haiku/trunk/src/system/kernel/slab - axeld