After this documentation was released in July 2003, I was approached
by Prentice Hall and asked to write a book on the Linux VM under the Bruce Peren's Open Book Series.
The book is available and called simply "Understanding The Linux Virtual
Memory Manager". There is a lot of additional material in the book that is
not available here, including details on later 2.4 kernels, introductions
to 2.6, a whole new chapter on the shared memory filesystem, coverage of TLB
management, a lot more code commentary, countless other additions and
clarifications and a CD with lots of cool stuff on it. This material (although
now dated and lacking in comparison to the book) will remain available
although I obviously encourge you to buy the book from your favourite book
store :-) . As the book is under the Bruce Perens Open Book Series, it will
be available 90 days after appearing on the book shelves which means it
is not available right now. When it is available, it will be downloadable
from http://www.phptr.com/perens
so check there for more information.
To be fully clear, this webpage is not the actual book.
Next: 13.1 Selecting a Process
Up: understand-html
Previous: 12.9 Reading/Writing the Swap
  Contents
  Index
13. Out Of Memory Management
When the machine is low on memory, old page frames will be reclaimed
(see Chapter 11) but during the process
is may find it was unable to free enough pages to satisfy a request even
when scanning at highest priority. If it does fail to free page frames,
out_of_memory() is called to see if the system is out of
memory and needs to kill a process.
Figure 13.1:
Call Graph: out_of_memory()
|
Unfortunately, it is possible that the system is not out memory and simply
needs to wait for IO to complete or for pages to be swapped to backing storage
so before deciding to kill a process, it goes through the following checklist.
- Is there enough swap space left (nr_swap_pages > 0) ? If yes, not OOM
- Has it been more than 5 seconds since the last failure? If yes, not OOM
- Have we failed within the last second? If no, not OOM
- If there hasn't been 10 failures at least in the last 5 seconds, we're not OOM
- Has a process been killed within the last 5 seconds? If yes, not OOM
It is only if the above tests are passed that oom_kill()
is called to select a process to kill.
Subsections
Next: 13.1 Selecting a Process
Up: understand-html
Previous: 12.9 Reading/Writing the Swap
  Contents
  Index
Mel
2004-02-15