Linux 2.4 VM Documentation 115
popoutman writes "Mel Gorman has announced the availability of a guide to the 2.4 kernel VM
including a walkthrough of the VM code. Anyone interested in obtaining a solid understanding of the Linux 2.4 VM will certainly want to take a look at this documentation. Mel says that the effort is at least several weeks from being finished, but that he's releasing it now with the hopes of getting feedback to be sure he's on the right track.
He also notes that the 2.5 VM is still too much of a moving target for him to document it just yet." See also a Kerneltrap story.
Re:Here's a tip for the author. (Score:2, Informative)
As a (an ex-)Java guy I immediately thought it stood for "Virtual Machine."
Re:Here's a tip for the author. (Score:3, Informative)
1. virtual memory (using secondary storage to allow the program to address more memory locations than there is in physical RAM)
2. virtual machine (a machine implemented in software on a real machine, which *could* have different opcodes, or the same ones as the real machine)
3. VM - the operating system by IBM which allows one of their mainframes to act like many (stands for virtual machine)
( Also, there's the VM in VMS, the DEC Vax and Alpha operating system, which stands for VIrtual Memory as in #1)
Re:VM: Does it really matter? (Score:5, Informative)
This is a good question -- there are several features the VM system allows for in addition to overcommitting physical memory. If your system has enough memory to run with no swap/paging space set up, the VM system still provides these features without ever paging or swapping out memory.
The first is demand paging. That is, only those pages of an executable that are needed are brought into memory, and on-demand. Yes, this saves memory, but more importantly, it makes program startup much faster. Without demand paging, the whole program would need to be brought into memory at startup. Nowadays, when disks are much slower relative to CPUs, than they used to be, this makes a big difference, especially in the Unix shell-pipeline style of programming, where you run many different short-lived programs.
Secondly, the VM system allows for shared memory segments between processes. This allows for shared memory, threads and shared libraries.
Finally, the VM system implements caching of the file system, which we all know and love as a good use for all the memory we stuff into our machines now.
Re:VM: Does it really matter? (Score:2, Informative)
-- Jack
Documentation and uncommunicative maintainer (Score:4, Informative)
Re:VM: Does it really matter? (Score:3, Informative)
Re:Better document... (Score:2, Informative)
Platforms supported:
acorn26 acorn32 algor alpha amiga amigappc arc arm32 atari bebox cats cesfic cobalt dreamcast evbarm evbmips evbppc evbsh3 evbsh5 hp300 hp700 hpcarm hpcmips hpcsh i386 luna68k mac68k macppc mipsco mmeye mvme68k mvmeppc netwinder news68k newsmips next68k ofppc pc532 playstation2 pmax pmppc prep sandpoint sbmips sgimips shark sparc sparc64 sun2 sun3 vax x68k x86_64
Re:VM: Does it really matter? (Score:2, Informative)
Virtual Memory means virtualizing a process's access to memory such that the memory addresses it accesses isn't necessarily the same physical memory address. It allows for complete memory separation between processes, which offers a vast amount of protection so that processes can't crash other processes.
The only alternative to Virtual Memory is to use actual physical memory addresses. This was exactly the case with DOS. In DOS you would have to manage memory and make sure your process (it's single-threaded... remember?!?) didn't overwrite memory that it didn't own. Everything in memory could be accessed from every single process.
With virtual memory, two processes could access memory location 0x1000000 and it would map to different physical memory addresses. In fact, the OS will give each process a full memory address range that is completely usuable by the process without any fear of stepping over someone else's memory. This effectively separates processes and prevents a hell of a lot of corruption because of memory bugs in programs.
This really simplifies programming because whenever we get a memory address from malloc, we don't have to do anything about making sure we don't step over someone else's memory information.
What you are in fact talking about is paging, the act of having a backing store of information on hard drive. This allows you to keep track of more memory than you physically have, by swapping memory back and forth from physical memory to a hard drive. Any unused memory would be paged to disk.
Yes, today you can have gigabytes of memory, and when running Mozilla, boy you really don't need virtual memory.
But what about 10 years from now, when Microsoft Office takes up 50 GB of hard drive space, and 16 GB of memory?
Virtual memory is a way of abstracting memory use on a per process basis, and it's inclusion in most modern operating systems is one of the reasons why things are relatively stable these days, compared to the old DOS days, anyway.
Re:VM: Does it really matter? (Score:5, Informative)
Because it's important. :-)
Some people think that virtual memory means paging to secondary memory, such as disk. It doesn't. Virtual memory systems can support this, but many OSes (e.g. QNX) support virtual memory with no disk paging. (OK, QNX does support disk paging, but only as an afterthought, so that QNX can be self-compiled. GCC takes a lot of memory.)
Virtual memory provides a virtual address space for each process. The benefits include:
This is just off the top of my head.
Re:VM: Does it really matter? (Score:3, Informative)
Another benefit is sparse allocation. When memory is allocated, it's all mapped to a zero filled page and marked copy on write. That allows programs to allocate massive arrays that are expected to be primarily filled with zeros without actually requiring that much memory. When a value is writen, a new page is allocated and mapped into the virtual space.
If desired, a file can be mmaped into the array instead to provide a simple persistant storage.
IIRC, suspend to disk is (or at least can be) also accomplished through VM.
The VM also allows an x86 system to have more than 4GB of ram. No single process can have more than a total of 4G (counting the kernel space) but using PAE, more than a total of 4GB can be allocated to multiple processes through the VM.
Although Linux doesn't do this, some OSes completely replace the filesystem with a VM. All files and directories are objects and are demand paged.