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.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > The Linux Kernel > Linux Swapper

Forgot Password?
 The Linux Kernel   Compiling, theory, programming or other discussion about the linux kernel

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 09-12-2004   #1 (permalink)
Just 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
ministre is offline  



Reply With Quote
Old 11-15-2004   #2 (permalink)
Just Joined!
 
Join Date: Nov 2004
Posts: 5
what i feel is that page tables are now swap out of main memory.

naveen
naveen.yadav is offline   Reply With Quote
Old 11-15-2004   #3 (permalink)
Linux User
 
Join Date: Oct 2004
Location: /dev/random
Posts: 404
Quote:
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_unforgiven is offline   Reply With Quote
Old 11-15-2004   #4 (permalink)
Content Team
 
sarumont's Avatar
 
Join Date: Apr 2003
Location: /dev/urandom
Posts: 3,682
Quote:
Originally Posted by the_unforgiven
Quote:
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
sarumont is offline   Reply With Quote
Old 11-15-2004   #5 (permalink)
Linux 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.
Dolda2000 is offline   Reply With Quote
Old 11-16-2004   #6 (permalink)
Linux User
 
Join Date: Oct 2004
Location: /dev/random
Posts: 404
Quote:
Originally Posted by Dolda2000
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
the_unforgiven is offline   Reply With Quote
Old 11-16-2004   #7 (permalink)
Linux 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.
Dolda2000 is offline   Reply With Quote
Old 11-19-2004   #8 (permalink)
Linux 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
the_unforgiven is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
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
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
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



All times are GMT. The time now is 10:56 PM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1