diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-22 14:36:45 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-22 14:36:45 +0100 |
commit | 9fc54ba93141b90a82e56dfb707d3e56b105a442 (patch) | |
tree | 0351c14c506823406a3865e0705af7b2a1ced6cc /Kernel | |
parent | 6428669a37a7ae15cf54186354f4eb49f3936f38 (diff) | |
download | serenity-9fc54ba93141b90a82e56dfb707d3e56b105a442.zip |
Kernel: Tweak SlabAllocator's slab sizes
Nobody was using the 8-byte slab size, so get rid of it and move all of
its capacity to the new 64-byte slab size (which replaces 48-byte.)
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Heap/SlabAllocator.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/Kernel/Heap/SlabAllocator.cpp b/Kernel/Heap/SlabAllocator.cpp index 4b4c338534..0aed1747a9 100644 --- a/Kernel/Heap/SlabAllocator.cpp +++ b/Kernel/Heap/SlabAllocator.cpp @@ -106,53 +106,46 @@ private: static_assert(sizeof(FreeSlab) == templated_slab_size); }; -static SlabAllocator<8> s_slab_allocator_8; static SlabAllocator<16> s_slab_allocator_16; static SlabAllocator<32> s_slab_allocator_32; -static SlabAllocator<48> s_slab_allocator_48; +static SlabAllocator<64> s_slab_allocator_64; -static_assert(sizeof(Region) <= s_slab_allocator_48.slab_size()); +static_assert(sizeof(Region) <= s_slab_allocator_64.slab_size()); template<typename Callback> void for_each_allocator(Callback callback) { - callback(s_slab_allocator_8); callback(s_slab_allocator_16); callback(s_slab_allocator_32); - callback(s_slab_allocator_48); + callback(s_slab_allocator_64); } void slab_alloc_init() { - s_slab_allocator_8.init(384 * KB); s_slab_allocator_16.init(128 * KB); s_slab_allocator_32.init(128 * KB); - s_slab_allocator_48.init(128 * KB); + s_slab_allocator_64.init(512 * KB); } void* slab_alloc(size_t slab_size) { - if (slab_size <= 8) - return s_slab_allocator_8.alloc(); if (slab_size <= 16) return s_slab_allocator_16.alloc(); if (slab_size <= 32) return s_slab_allocator_32.alloc(); - if (slab_size <= 48) - return s_slab_allocator_48.alloc(); + if (slab_size <= 64) + return s_slab_allocator_64.alloc(); ASSERT_NOT_REACHED(); } void slab_dealloc(void* ptr, size_t slab_size) { - if (slab_size <= 8) - return s_slab_allocator_8.dealloc(ptr); if (slab_size <= 16) return s_slab_allocator_16.dealloc(ptr); if (slab_size <= 32) return s_slab_allocator_32.dealloc(ptr); - if (slab_size <= 48) - return s_slab_allocator_48.dealloc(ptr); + if (slab_size <= 64) + return s_slab_allocator_64.dealloc(ptr); ASSERT_NOT_REACHED(); } |