LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2011, 05:15 PM   #1
just1alexx
LQ Newbie
 
Registered: Jun 2011
Location: Cranford, NJ
Distribution: don't have a preference (ubuntu right now)
Posts: 12

Rep: Reputation: Disabled
Question 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
 
Old 10-21-2011, 07:36 PM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by just1alexx View Post
(Using a one-level page table)
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.
 
Old 10-21-2011, 07:41 PM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Quote:
Originally Posted by just1alexx View Post
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.

Examples:
IBM/360 (24-bit): two levels: 16 MiB = 256*32*2KiB (address-bits: 32=8+5+11)
x86/32-bit: two levels: 4 GiB = 1024*1024*4 KiB (address-bits: 32=10+10+12)
x86/32-bit/PAE: three levels: 4 GiB = 4*512*512*4 KiB (address-bits: 32=2+9+9+12)
x86-64/48-bit: four levels: 256 TiB = 512*512*512*512*4 KiB (address-bits: 48=9+9+9+9+12)

Last edited by NevemTeve; 10-22-2011 at 07:32 AM. Reason: Error corrected, thanks to johnsfine
 
Old 10-21-2011, 07:47 PM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by NevemTeve View Post
x86-64/48-bit: four levels: 256 TiB = 512*512*512*4 KiB (address-bits: 9+9+9+12)
Slight typo there. I think you meant:

x86-64/48-bit: four levels: 256 TiB = 512*512*512*512*4 KiB (address-bits: 9+9+9+9+12)
 
Old 10-21-2011, 07:57 PM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Fixed -- thank you!
 
Old 10-21-2011, 08:08 PM   #6
just1alexx
LQ Newbie
 
Registered: Jun 2011
Location: Cranford, NJ
Distribution: don't have a preference (ubuntu right now)
Posts: 12

Original Poster
Rep: Reputation: Disabled
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....
 
Old 10-21-2011, 08:09 PM   #7
just1alexx
LQ Newbie
 
Registered: Jun 2011
Location: Cranford, NJ
Distribution: don't have a preference (ubuntu right now)
Posts: 12

Original Poster
Rep: Reputation: Disabled
sorry about the overkill question, i just read NevemTeve post
 
Old 10-22-2011, 06:26 AM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by just1alexx View Post
as johnsfine suggested the solution would be to pre-allocate the tables
I said "You could pre allocate". That was not a suggested design. That was just showing a possibility in a theoretical discussion.

Quote:
Wouldn't there be a mechanism at compile time to specify the maximum size of the process?
The max size is usually not known at compile time.

Quote:
Note that it does not matter how many levels are in the design, the last table will always have (memory_size)/(page_size) entries....
I think you mean (memory_size*entry_size)/(page_size)

In PAE and x86-64 the entry size is 8 and the pages size is 4096, so up to a 512*4096 byte memory area could be mapped by a 4096 byte page table.

But usually the image is not contiguous, so each level is a somewhat bigger fraction of the level it maps than that formula suggests.
 
Old 10-22-2011, 06:41 AM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
zypper update makes /var/lib/rpm/Packages grow and grow and grow... Earl3 Linux - General 3 06-27-2011 02:07 PM
how to dynamically grow the ext3 file system in centOs hemanthv414 Linux - Server 6 11-04-2010 02:03 PM
LXer: Linux desktops grow and grow and grow LXer Syndicated Linux News 0 11-23-2007 01:00 PM
PHP - Dynamically listing pictures - but only a certain # per page? ziphem Programming 1 06-24-2007 05:52 AM
Dynamically select data from MySQL tables tangle Programming 6 02-28-2006 05:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration