Page management question
Posted: Mon Jun 23, 2008 8:29 pm
Hi all. I've been doing some studying on how to allocate pages in the physical memory manager. Seems to me there are two basic ways to do it: a bitmap of used/unused pages or a stack of unused pages (or some combination of the two). That much I understand okay.
At the moment I haven't done anything fancy. I've just got a stack of every unused 4 kB page in the 4 GB address space. The stack takes up 4 MB. I'm just wondering, how does this fit into the paging mechanism?? I've identity-mapped the first 8 MB where the kernel and page stack are to get around this for now. My assumption is that they will need to stay mapped into every process's address space. Is this correct?
I've also read/realised that every time the number of free pages drops by 1024 I've got another whole 4 kB page not being used by the stack, and that potentially I could send this out to the VMM as an available page, to avoid having to waste the whole 4 megabytes. But how?
Problem is if the virtual memory manager starts remapping that page, don't I lose my identity mapping on the first 8 MB? How do I / can I access my page stack if it's not identity-mapped? What happens when some other pages become unused and need to be added to the stack, so the stack needs to grow bigger, but the VMM hasn't given back the page I need? It wouldn't be a problem if *any* page was suitable, if the page stack was within the linear virtual memory system, but since it's not, I have to get back the exact physical pages that made up the stack in the first place.
I'm fairly confused about it now. There must be a magical answer to this because I don't see how either naïve bitmaps or stacks could handle the amount of pages once you move up to 64-bit.
Ideas?
At the moment I haven't done anything fancy. I've just got a stack of every unused 4 kB page in the 4 GB address space. The stack takes up 4 MB. I'm just wondering, how does this fit into the paging mechanism?? I've identity-mapped the first 8 MB where the kernel and page stack are to get around this for now. My assumption is that they will need to stay mapped into every process's address space. Is this correct?
I've also read/realised that every time the number of free pages drops by 1024 I've got another whole 4 kB page not being used by the stack, and that potentially I could send this out to the VMM as an available page, to avoid having to waste the whole 4 megabytes. But how?
Problem is if the virtual memory manager starts remapping that page, don't I lose my identity mapping on the first 8 MB? How do I / can I access my page stack if it's not identity-mapped? What happens when some other pages become unused and need to be added to the stack, so the stack needs to grow bigger, but the VMM hasn't given back the page I need? It wouldn't be a problem if *any* page was suitable, if the page stack was within the linear virtual memory system, but since it's not, I have to get back the exact physical pages that made up the stack in the first place.
I'm fairly confused about it now. There must be a magical answer to this because I don't see how either naïve bitmaps or stacks could handle the amount of pages once you move up to 64-bit.
Ideas?