Kernel: Unbreak SlabAllocator after startup-time constructors

Now that the kernel supports startup-time constructors, we were first
doing slab_alloc_init(), and then the constructors ran later on,
zeroing out the freelist pointers.

This meant that all slab allocators thought they were completelty
exhausted and forwarded all requests to kmalloc() instead.
This commit is contained in:
Andreas Kling 2019-11-15 12:47:18 +01:00
parent b6ccbd32eb
commit 7ef9c703d2
Notes: sideshowbarker 2024-07-19 11:13:10 +09:00

View file

@ -61,11 +61,12 @@ private:
char padding[templated_slab_size - sizeof(FreeSlab*)]; char padding[templated_slab_size - sizeof(FreeSlab*)];
}; };
FreeSlab* m_freelist { nullptr }; // NOTE: These are not default-initialized to prevent an init-time constructor from overwriting them
size_t m_num_allocated { 0 }; FreeSlab* m_freelist;
size_t m_num_free { 0 }; size_t m_num_allocated;
void* m_base { nullptr }; size_t m_num_free;
void* m_end { nullptr }; void* m_base;
void* m_end;
static_assert(sizeof(FreeSlab) == templated_slab_size); static_assert(sizeof(FreeSlab) == templated_slab_size);
}; };