From 92d8a02291740e02e3528b57a68d0f6d1f4ae2fc Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Wed, 15 Nov 2023 13:10:53 -0800 Subject: [PATCH] [Zion] Cleanup memory debug statistics slightly. --- zion/memory/kernel_heap.cpp | 33 ++++++++++++++------------------- zion/memory/kernel_heap.h | 20 +++++++------------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/zion/memory/kernel_heap.cpp b/zion/memory/kernel_heap.cpp index e82eb62..14a4a37 100644 --- a/zion/memory/kernel_heap.cpp +++ b/zion/memory/kernel_heap.cpp @@ -3,7 +3,7 @@ #include "debug/debug.h" #include "memory/paging_util.h" -#define K_HEAP_DEBUG 1 +#define K_HEAP_DEBUG 0 namespace { @@ -104,11 +104,6 @@ void KernelHeap::DumpDebugDataInternal() { dbgln(""); dbgln("Heap Debug Statistics!"); - dbgln("Pages used: {}", - (next_addr_ - kKernelBuddyHeapStart - 1) / 0x1000 + 1); - // Active Allocs. - dbgln("Active Allocations: {}", alloc_count_); - dbgln("Slab Statistics:"); dbgln("Slab 8: {} slabs, {} allocs", slab_8_.SlabCount(), slab_8_.Allocations()); @@ -123,25 +118,25 @@ void KernelHeap::DumpDebugDataInternal() { dbgln(""); dbgln("Size Distributions of non slab-allocated."); - dbgln("<=8B: {}", distributions[0]); - dbgln("<=16B: {}", distributions[1]); - dbgln("<=32B: {}", distributions[2]); - dbgln("<=64B: {}", distributions[3]); - dbgln("<=128B: {}", distributions[4]); - dbgln("<=256B: {}", distributions[5]); - dbgln("<=512B: {}", distributions[6]); - dbgln("<=1KiB: {}", distributions[7]); - dbgln("<=2KiB: {}", distributions[8]); - dbgln("<=4KiB: {}", distributions[9]); - dbgln("> 4KiB: {}", distributions[10]); + dbgln("Pages used: {}", + (next_addr_ - kKernelBuddyHeapStart - 1) / 0x1000 + 1); + // Active Allocs. + dbgln("Active Allocations: {}", alloc_count_); + + dbgln("<=256B: {}", distributions[0]); + dbgln("<=512B: {}", distributions[1]); + dbgln("<=1KiB: {}", distributions[2]); + dbgln("<=2KiB: {}", distributions[3]); + dbgln("<=4KiB: {}", distributions[4]); + dbgln("> 4KiB: {}", distributions[5]); dbgln(""); } void KernelHeap::RecordSize(uint64_t size) { size -= 1; - size >>= 3; + size >>= 8; uint64_t index = 0; - while (size && index < 11) { + while (size && index < 5) { size >>= 1; index++; } diff --git a/zion/memory/kernel_heap.h b/zion/memory/kernel_heap.h index 22c20ce..c5927cd 100644 --- a/zion/memory/kernel_heap.h +++ b/zion/memory/kernel_heap.h @@ -29,19 +29,13 @@ class KernelHeap { SlabAllocator slab_64_{64}; SlabAllocator slab_128_{128}; - // Distribution collection for the purpose of investigating a slab allocator. - // 0: 0-8B - // 1: 8B-16B - // 2: 16B-32B - // 3: 32B-64B - // 4: 64B-128B - // 5: 128B-256B - // 6: 256B-512B - // 7: 512B-1KiB - // 8: 1KiB-2KiB - // 9: 2KiB-4KiB - // 10: 4KiB+ - uint64_t distributions[11]; + // 0: 128B-256B + // 1: 256B-512B + // 2: 512B-1KiB + // 3: 1KiB-2KiB + // 4: 2KiB-4KiB + // 5: 4KiB+ + uint64_t distributions[6]; void RecordSize(uint64_t size);