[Zion] Add more debug information about kernel heap usage.

This will be helpful as we work to improve it.

Without deallocations, we currently stand at the following alloc numbers
8 - 142
16 - 319
32 - 364

unsized - 305

total page usage including slabs is 12.
This commit is contained in:
Drew Galbraith 2023-11-15 12:36:18 -08:00
parent 4657c46f73
commit 6d27ee5dc5
6 changed files with 87 additions and 35 deletions

View file

@ -14,30 +14,33 @@ class KernelHeap {
void Free(void* address);
static void DumpDistribution();
static void DumpDebugData();
private:
uint64_t next_addr_;
uint64_t upper_bound_;
uint64_t alloc_count_ = 0;
glcr::UniquePtr<SlabAllocator> slab_8_;
glcr::UniquePtr<SlabAllocator> slab_16_;
glcr::UniquePtr<SlabAllocator> slab_32_;
// Distribution collection for the purpose of investigating a slab allocator.
// 0: 0-4B
// 1: 4B-8B
// 2: 8B-16B
// 3: 16B-32B
// 4: 32B-64B
// 5: 64B-128B
// 6: 128B-256B
// 7: 256B-512B
// 8: 512B-1KiB
// 9: 1KiB-2KiB
// 10: 2KiB-4KiB
// 11: 4KiB+
uint64_t distributions[12];
// 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];
void RecordSize(uint64_t size);
void DumpDebugDataInternal();
};