Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    linux memory management


    I have a couple of questions about linux's memory management. I tried reading around, but I couldn't find clear answers. Hopefully one guru will take pity on me.

    1) On a process switch, does Linux flush to disk all memory pages resident in RAM of the process being evicted? If not, it means that, at some point, pages belonging to several processes can be resident in RAM. If so, let's say process A is now active and it tries to read from page x, which is marked as swapped to disk. By a page fault, the kernel will read the page from disk, in order to put it somewhere in RAM. Let's say there's no RAM available, so it has to flush a frame from RAM to make room. Say it chooses a frame that doesn't belong to process A, but to another process, B. How will the kernel be able to update B's page table, to mark the fact that this frame is no longer in RAM? How will it even now the id of process B? If there a reference from each frame to the process to which it belongs? Am I seriously missing something?

    2) I don't understand about zone highmem... I understand that the "kernel address space" is part of each process' address space, practically the kernel's memory is mapped in each process' page tables. It comprises of all the addresses about 3GB (0xc0000...). This means that the kernel can access at most 1GB of memory at any given time. But how is this related to the first physical 1GB of RAM (or first 768MB)? The way I see it, the kernel can map in it's page table whatever part of RAM it wants, not only from the first physical 1GB... So why is physical memory beyond the first 1GB treated specially?

    Thank you so much,

  2. #2
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    The Netherlands
    The reason why behind one 1 Gig is treated in a Diffrent way is (if I recall correctly) the same reason why memory behind the first 512(?) KB is treated Diffrently.
    New Users, please read this..
    Google first, then ask..

  3. #3
    2) Normally Lunux uses 1GB/3GB split across kernel and process.
    So. Kernel can map only the first 1GB into its address space. So it will have pagetables enough to address this 1GB.

    So As far as I know mem above this 1GB is called High Mem. So to address this High Mem its has to map that High mem into its address space. Kernel resrves some memory(if Im not worng page tables) to map these high mem. So in effect the directly mapped memory reduces to less than 1GB.

    There are functions available in kernel to do this.

  4. $spacer_open
  5. #4
    Yes, but the question was, why does it do this? Why does it choose to arbitrarily map a large portion of the first GB of physical RAM, instead of mapping what it needs.

  6. #5
    Linux supposes that normal PC will not use more than 1GB of RAM.

    if some body wants more that 756MB of RAM there are patches for 2gb/2gbsplit 3gb/1gb splits where you need not map the high mem.

    IF you want 4gb direct map write the application in kenel

  7. #6
    Just Joined!
    Join Date
    Dec 2007
    About question 2 :
    In my opinion , there are 3 zones in a "pg_data_t" .
    They are : DMA, low memory, high memory .
    High memory zone is from 896MB to 1 G (for I386 arch the MACRO is MAXMEM),which can not be accessed by kernel directly.
    So the question is why kernel treats 0~896MB as specially ?
    I think kernel would like to access some physical memory , but there should be a limited point,the start point of high memory is the limited point .

Posting Permissions

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