diff --git a/src/system/kernel/slab/ObjectDepot.cpp b/src/system/kernel/slab/ObjectDepot.cpp index bc4c7cfd04..4f219ece24 100644 --- a/src/system/kernel/slab/ObjectDepot.cpp +++ b/src/system/kernel/slab/ObjectDepot.cpp @@ -1,6 +1,6 @@ /* * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. - * 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 @@ DepotMagazine::Push(void* object) } +// #pragma mark - + + static DepotMagazine* alloc_magazine(uint32 flags) { @@ -150,6 +153,7 @@ push_empty_magazine(object_depot* depot, DepotMagazine* magazine) SpinLocker _(depot->inner_lock); _push(depot->empty, magazine); + depot->empty_count++; } @@ -322,3 +326,55 @@ object_depot_make_empty(object_depot* depot, uint32 flags) 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; +} diff --git a/src/system/kernel/slab/Slab.cpp b/src/system/kernel/slab/Slab.cpp index bb6e60b98b..bf9209998b 100644 --- a/src/system/kernel/slab/Slab.cpp +++ b/src/system/kernel/slab/Slab.cpp @@ -1,6 +1,6 @@ /* * Copyright 2010, Ingo Weinhold . - * 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,22 +226,27 @@ dump_cache_info(int argc, char* argv[]) 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 @@ slab_init_post_area() 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"); } diff --git a/src/system/kernel/slab/slab_private.h b/src/system/kernel/slab/slab_private.h index 0282c9e8e6..a43af608cc 100644 --- a/src/system/kernel/slab/slab_private.h +++ b/src/system/kernel/slab/slab_private.h @@ -27,6 +27,8 @@ #include struct ObjectCache; +struct object_depot; + void request_memory_manager_maintenance(); @@ -36,6 +38,10 @@ void block_free(void* block, uint32 flags); 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 static inline Type*