Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
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.
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.
AFAIK, none of the kernel-level data structures - including the page-tables - are ever swapped out.
Someone correct me if I'm wrong.
__________________
The Unforgiven
Registered Linux User #358564
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.
AFAIK, none of the kernel-level data structures - including the page-tables - are ever swapped out.
Someone correct me if I'm wrong.
I'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.
__________________ "Time is an illusion. Lunchtime, doubly so."
~Douglas Adams, The Hitchhiker's Guide to the Galaxy
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.
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.
No, it's not that easy to cause DoS...
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
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.
A Newbie's Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you're a complete Linux newbie and looking for a quick and easy guide to get you started this is it. subscribe
Open Source Security Myths Dispelled Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization subscribe
InformationWeek InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology. subscribe