mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:27:35 +00:00
Kernel: Make kmalloc heap expansion kmalloc-free
Previously, the heap expansion logic could end up calling kmalloc recursively, which was quite messy and hard to reason about. This patch redesigns heap expansion so that it's kmalloc-free: - We make a single large virtual range allocation at startup - When expanding, we bump allocate VM from that region - When expanding, we populate page tables directly ourselves, instead of going via MemoryManager. This makes heap expansion a great deal simpler. However, do note that it introduces two new flaws that we'll need to deal with eventually: - The single virtual range allocation is limited to 64 MiB and once exhausted, kmalloc() will fail. (Actually, it will PANIC for now..) - The kmalloc heap can no longer shrink once expanded. Subheaps stay in place once constructed.
This commit is contained in:
parent
1a35e27490
commit
f7a4c34929
3 changed files with 140 additions and 370 deletions
|
@ -22,6 +22,8 @@ namespace Kernel {
|
|||
class PageDirectoryEntry;
|
||||
}
|
||||
|
||||
struct KmallocGlobalData;
|
||||
|
||||
namespace Kernel::Memory {
|
||||
|
||||
constexpr bool page_round_up_would_wrap(FlatPtr x)
|
||||
|
@ -140,6 +142,7 @@ class MemoryManager {
|
|||
friend class AnonymousVMObject;
|
||||
friend class Region;
|
||||
friend class VMObject;
|
||||
friend struct ::KmallocGlobalData;
|
||||
|
||||
public:
|
||||
static MemoryManager& the();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue