ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: don't have a preference (ubuntu right now)
Posts: 12
Rep:
Can page tables grow dynamically?
Hi,
(Using a one-level page table)
Let's suppose that a program's virtual image can grow dynamically. If this is the case, then a dynamic page table would be necessary, since a larger page table is necessary for a larger virtual image.
Now, if this is the case, then it would be impossible to keep the page table in contiguous memory, but a requirement for the page table is to be in contiguous memory, otherwise the Memory Management Hardware cannot index into the table.
Can anyone explain this contradiction?
Thanks
Non PAE 32 bit x86 uses a two-level page table.
PAE 32 bit x86 uses a three-level page table.
X86_64 uses a four-level page table.
Quote:
Let's suppose that a program's virtual image can grow dynamically. If this is the case, then a dynamic page table would be necessary, since a larger page table is necessary for a larger virtual image.
You could pre allocate the page table for the max virtual size, since any entry in the page table can be marked non resident.
So even with a one level page table the virtual size of the task could grow.
Quote:
but a requirement for the page table is to be in contiguous memory,
Who requires that?
Quote:
otherwise the Memory Management Hardware cannot index into the table.
What Memory Management unit? Some hypothetical one level paging design? I don't know the details of that unlikely design.
Quote:
Can anyone explain this contradiction?
It seems you are making false assumptions. That tends to lead to contradictions.
Hi,
(Using a one-level page table)
Let's suppose that a program's virtual image can grow dynamically. If this is the case, then a dynamic page table would be necessary, since a larger page table is necessary for a larger virtual image.
Now, if this is the case, then it would be impossible to keep the page table in contiguous memory, but a requirement for the page table is to be in contiguous memory, otherwise the Memory Management Hardware cannot index into the table.
Can anyone explain this contradiction?
Thanks
If the page-table cannot grow dynamically, then the kernel have to allocate it in the maximum possible size. Of course it would be an overkill (example: 4 GiB address space, 4 KiB page size, 32 bit/page-table-entry => 4 MiB for the page table); that's why we use two-, three- or even more level hierarchical page-tables.
Distribution: don't have a preference (ubuntu right now)
Posts: 12
Original Poster
Rep:
That's why I asked for a one-level page table, but it seems that it is not used because of its inefficiency. I know that in order to support a big image sizes a multi-level is the way to go. (Or even something like an inverse page table).
I said that a requirement was that it was in contiguous memory because it does not matter the level of the page table hierarchy, the first table has to be in contiguous memory. Otherwise the address translation mechanism of adding the leftmost bits of the logical address (page number) to the first table's base address would not work. Of course the rest of the tables can be managed with the same paging mechanism as the user processes.
Ok, since johnsfine clarified that a one-level page table is unlikely to be around because of its inefficiency, then my question about a one-level page table is officially solved. But I have another question:
Having a multi-level page table, since a dynamic growth of the virtual image implies a dynamic growth for all the tables (no matter the level used) then as johnsfine suggested the solution would be to pre-allocate the tables to accommodate a predefined image size. However, johnsfine, don't you think that allocating a table for the maximum virtual size is an overkill? Wouldn't there be a mechanism at compile time to specify the maximum size of the process?
Note that it does not matter how many levels are in the design, the last table will always have (memory_size)/(page_size) entries....
Philosophical mind games are all well and good, but MMUs deal with physical memory. They neither know nor care of virtual addressing.
The kernel is mapped into non-paged ram. Period. It has page tables but they map one-to-one into physical addresses, unlike user-space.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.