JonasKruckenberg / k23

Experimental WASM Microkernel Operating System
https://jonaskruckenberg.github.io/k23/
250 stars 9 forks source link

Loader: Improve physical memory mapping performance at startup #113

Open JonasKruckenberg opened 3 weeks ago

JonasKruckenberg commented 3 weeks ago

The loader automatically maps all of physical memory at a chosen offset in kernel space (for having access to page tables, introspection of the kernels elf file etc). The current implementation is quite sub-par though as it maps the huge range using the most fine-grained 4k pages (wasting a lot of cycles and memory in the process). Instead we should be mapping with megapages or gigapages (the region allocated by the virt_alloc for mapping is already gigapage-aligned).

Maybe we can even figure out a smart way to map the region using the fewest pages possible by mapping as much as we can using gigapages, then stepping down to megapages and map as much as possible using those and only map using regular pages for the rest of the requested range.