Results 1 to 8 of 8
Hello,
I have a question about the functioning of the linux swapper. I am looking at kernel 2.4.26. I am also refering to the o'reilly book "undestanding the linux kernel".
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-12-2004 #1Just Joined!
- Join Date
- Sep 2004
- Posts
- 1
Linux Swapper
Hello,
I have a question about the functioning of the linux swapper. I am looking at kernel 2.4.26. I am also refering to the o'reilly book "undestanding the linux kernel".
From what I undestand, when the system runs low on physical memory, linux goes through the page table of user processes and swaps out some pages to the swap cache which are then periodically flushed to disk (swap partition)
My question is the following:
The pages that store the page tables themselves (i.e the pages that store the pgd, pmd and pte), are those pages ever swapped out ? Or is it the case that only pages that contain data, code, stack, heap etc... are swapped out while pages containing the page tables themselves are never swapped out.
Thanks
- 11-15-2004 #2Just Joined!
- Join Date
- Nov 2004
- Posts
- 5
what i feel is that page tables are now swap out of main memory.
naveen
- 11-15-2004 #3Linux User
- Join Date
- Oct 2004
- Location
- /dev/random
- Posts
- 404
AFAIK, none of the kernel-level data structures - including the page-tables - are ever swapped out.The pages that store the page tables themselves (i.e the pages that store the pgd, pmd and pte), are those pages ever swapped out ? Or is it the case that only pages that contain data, code, stack, heap etc... are swapped out while pages containing the page tables themselves are never swapped out.
Someone correct me if I'm wrong.The Unforgiven
Registered Linux User #358564
- 11-15-2004 #4I'm 99% sure they aren't. I never used my swap space except when emerging something like qt. Now I don't have a swap partition and everything runs fine.
Originally Posted by the_unforgiven
"Time is an illusion. Lunchtime, doubly so."
~Douglas Adams, The Hitchhiker's Guide to the Galaxy
- 11-15-2004 #5Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
I haven't checked, but I cannot even imagine that Linux wouldn't swap out the page tables if needed. Otherwise, that would be a great DOS attack... fork 100 processes that map their address spaces full of mmap'd /dev/zero, and you'll have taken up 400 MBs of unswappable memory. It would be the easiest way ever of bringing down a system, and, unlike a fork bomb, you can't stop it with ulimit, since memory ulimits are accounted for per process, not per user.
- 11-16-2004 #6Linux User
- Join Date
- Oct 2004
- Location
- /dev/random
- Posts
- 404
No, it's not that easy to cause DoS...
Originally Posted by Dolda2000
The linux kernel (in fact, the original UNIX itself) implements page-tables with multiple levels of indirections. So, the amount of memory they can address is rather huge. The only problem you would face is that the memory access would be a little bit slowed down.
Also, I faintly remember - maybe completely wrong - linux does allow for per user memory limits.The Unforgiven
Registered Linux User #358564
- 11-16-2004 #7Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
That's not it. Even though you have multi-level page tables, each mapped page always takes 4 bytes in the page table. The thing with multi-level page tables is precisely that it does allow you to swap out parts of the tables. If you don't do that, each mapped page will always take 4 bytes no matter what you do.
Please note also that it is not Linux/UNIX that implement multi-level page tables -- it's the hardware that provides them. Whatever kernel is running on the hardware have to use multi-level page tables whether it wants to or not, because that's how the hardware works. The reason that the hardware provides multi-level page tables is, as stated above, that it allows you to swap out parts of the tables.
Linux doesn't necessarily implement multi-level page tables. If you run on MIPS, for example, there's no page table at all, just a software-programmable TLB.
- 11-19-2004 #8Linux User
- Join Date
- Oct 2004
- Location
- /dev/random
- Posts
- 404
Yeah, I guess, I should go back and study UNIX/Linux kernel again..
The Unforgiven
Registered Linux User #358564


Reply With Quote
