From 38883485c80841f15365d0502418dcc224f01d45 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Wed, 5 Jun 2024 23:01:19 +0200 Subject: mm: use linked-list-allocator as kmalloc I'll implement my own allocator later. Currently using linked-list allocator [1] to manage the kernel heap (as in kmalloc, not vmalloc). It manages the ID-mapped region (from VA 0xffff_8000_0000_0000). This allocator is initialized to use the _largest_ physical memory block. If the kernel image (text and data) live in this zone then skip the occupied part. Key difference between kmalloc and vmalloc: - kmalloc pretty much manages the physical memory: the allocated address are within the id-mapped region (see above) therefore the allocated memory must also be contigous in physical memory. Such memory MUST NOT page fault. This is prone to fragmentation, so do not use kmalloc to allocate big objects (e.g. bigger than one 4k page). - vmalloc manages kernel heap memory and the mapping is managed by paging. Such memory could trigger pagefault in kernel mode. Note that the kmalloc conflicts with the previous used stack based PMA as they operates on the same VM zone. References: [1] https://github.com/rust-osdev/linked-list-allocator Signed-off-by: Tianhao Wang --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Cargo.toml') diff --git a/Cargo.toml b/Cargo.toml index b858d96..1d96a55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,8 @@ license = "eupl-1.2" [dependencies] spin = "0.9.8" bitflags = "2.4.2" +# TODO make my own heap allocator +linked_list_allocator = "0.10.5" [dependencies.lazy_static] version = "1.4" -- cgit v1.2.3-70-g09d2