codyd51 wrote:
Hello!
I'm in the process of rewriting my virtual memory manager and have run into a hang-up.
Each address space is composed of a page-directory and a bitmap describing allocated pages. Each address-space shares the page tables that identity-map low memory, kernel data+code, kernel ELF sections, etc. Memory is allocated on a first-fit basis, so it's reasonable for an allocation to be fulfilled in a globally shared page table.
If a process allocates memory within one of these globally-shared-tables, then every process will then receive the updated state in the shared page tables. However, only the process that fulfilled the allocation would have the memory marked in its allocation bitmap.
I was banging my head against this for a few days after seeing mismatched states between a process's page-tables and allocation bitmap until I realized what was going on. For now, on task switch, I iterate the shared tables and ensure nothing is out-of-sync, and panic if it is.
I'm trying to come up with a clean way to signal allocations to a shared table, so that every process that shares the table can mark the pages as allocated in its bitmap. A few ideas:
If you have shared tables in kernel space, why bother tracking those per-process?
Instead, use your per-process bitmap purely per process user mapping, and perhaps have a shared bitmap for kernel mappings. That way, you just need to manage a single shared bitmap, but you will have to partition your bitmap handling between user and kernel mappings.