Find the answer to your Linux question:
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.
  1. #1
    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

  2. #2
    Just Joined!
    Join Date
    Nov 2004
    Posts
    5
    what i feel is that page tables are now swap out of main memory.

    naveen

  3. #3
    Linux User
    Join Date
    Oct 2004
    Location
    /dev/random
    Posts
    404
    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

  4. #4
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    Quote Originally Posted by the_unforgiven
    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

  5. #5
    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.

  6. #6
    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

  7. #7
    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.

  8. #8
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •