[lkml]   [2001]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Linux VM design
Hi VM folks,

I'd like your comments on this (rather simplistic) hypothetic
VM description. If you know what's wrong with it, please tell me.

Ram page can be:

Not used by anything.

clean non-backed
Initially allocated page. All such pages share
global zero-filled readonly page. On write COW magic
is making a dirty non-backed copy

dirty non-backed
This ram page have copy neither in swap nor in fs.
Under light i/o load page laundering machinery
_may_ allocate swap for it and write it back.
Only after a timeout. No point in writing back
too early/too often. This laundering can be
turned off completely without much harm.

clean swap-backed
This ram page has a copy on swap. It is not modified
(either swapped in or is already laundered)
Note: as soon as it gets dirty, it becomes
dirty *non-backed* and swap page is freed

dirty swap-backed
This ram page was modified some time ago, become
dirty non-backed, and is being written back right now
to newly allocated swap page (laundering or
(evicting LRU ram page under memory pressure)).
A temporary stage. Turns clean swap-backed
as soon as write completes.

clean fs-backed
This ram page is mmapped from a file and is not modified
or already written back

dirty fs-backed
This ram page is mmapped from a file and is modified.
It needs to be written back within reasonable timeout
to keep fs data consistent

How LRU works

All non-free ram pages are in LRU list. Top ram page on the list
is the most recently accessed one. Bottom one is least recently
accessed one.

VM periodically scans all process pte's looking for 'accessed'
and 'dirty' bits, resets those bits, modifies page status:

Accessed bit set: Move ram page to top of LRU list.
Dirty bit set:
clean non-backed - can't happen (global zero page is RO)
dirty non-backed -> dirty non-backed
clean swap-backed -> dirty non-backed (note: swap page freed!)
dirty swap-backed -> dirty non-backed (note: complicated case. See below)
clean fs-backed -> dirty fs-backed
dirty fs-backed -> dirty fs-backed

Complicated case:
We are writing ram page to swap either due to:
1) Evicting LRU ram page under memory pressure
2) Laundering ram page under light io load
and page gets accessed/dirtied by some process.
In first case we are in deep trouble. To prevent this we must
unmap ram page from all processes before evicting.
In second case we are fine, however, laundering io is wasted.
Ram page should become dirty non-backed again and moved
to top of LRU list, swap page freed.

Ram page eviction

We evict ram pages when we have no free ram pages and
we have a memory request:
1) a process accesses not-present (swapped out) page
2) a process accesses not-present page mmaped to a file
3) a process writes to clean non-backed ram page and COW needs
new ram page to make a copy

Rate of such evictions is a good measure of mem pressure.

We evict ram page from the bottom of LRU list by unmapping it from
all processes, writing back to fs or allocating swap and writing back
to swap if it is dirty and using freed ram page to fulfill memory
Best regards, VDA

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:03    [W:0.039 / U:3.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site