Page 1 of 1
question regarding having the kernel mapped in all address s
Posted: Sat Apr 30, 2005 9:03 pm
by proxy
ok, so i am working on setting up my "process" objects and i plan to go the route of having the kernel's memory mapped into all processes address space. However, there is something that occured to me.
I have a kernel heap which grows (up to a certain amount). As it does, it adds pages into the heap as neccessary. Right now the main "easy" way i can think of handling this is to pre-map in all the page tables into the kernel's page directory (not the pages, just the page tables) for the whole size the heap is allowed to grow.
Is there any better way to address this issue?
And on a similar note, what about if i want to make parts of my kernel abled to be paged out, do i need to go through ever running process and update that region of there page table entries?
thanks.
proxy
Re:question regarding having the kernel mapped in all addres
Posted: Sat Apr 30, 2005 11:53 pm
by Brendan
Hi,
proxy wrote:
ok, so i am working on setting up my "process" objects and i plan to go the route of having the kernel's memory mapped into all processes address space. However, there is something that occured to me.
I have a kernel heap which grows (up to a certain amount). As it does, it adds pages into the heap as neccessary. Right now the main "easy" way i can think of handling this is to pre-map in all the page tables into the kernel's page directory (not the pages, just the page tables) for the whole size the heap is allowed to grow.
Is there any better way to address this issue?
This would depend on the maximum size of the kernel's heap, and how likely it is that the maximum heap size is needed - if your heap can grow to 512 MB you'd need to pre-allocate 512 KB of memory for page tables (whether it's used or not).
proxy wrote:And on a similar note, what about if i want to make parts of my kernel abled to be paged out, do i need to go through every running process and update that region of there page table entries?
You'd need to put all of the kernel's page tables into every address space. If you change a page table entry within a page table then the change will automatically occur in all address spaces that use that page table (with the minor exception of invalidating the TLBs in a multi-CPU situation). The only time you'd need to manually mess with all address spaces is when you change one of the kernel's page directory entries (ie. add or remove a page table to the kernel's space).
If all of the page tables used by the kernel are all pre-allocated and never change then you'd never need to worry about changing the paging data for every address space (which is a reason in favour of pre-allocating page tables for the kernel's heap).
You'd also need to be extremely careful with paging parts of the kernel's space to disk - you can get a deadlock (where the kernel needs to get data from the swap in order to get data from the swap). This means things that are used for the disk device driver/s, swap file, memory management, scheduler, IRQ and exception handlers (and possibly IPC) can't be swapped to disk. If you're doing a micro-kernel that doesn't leave much that can be safely swapped to disk (ie. it wouldn't be worth bothering with). For a monolithic kernel it can be a different story though.
Cheers,
Brendan
Re:question regarding having the kernel mapped in all addres
Posted: Sun May 01, 2005 12:01 am
by proxy
yea, right now my kernel heap has a max of 64 megs (seem like enough?) so that's 16 page tables if my math serves me right. This seems reasonable to pre-allocate. So unless you have a better suggestion (always open to suggestions) I think that's the way to go.
proxy