Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Page replacement algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Page cache in Linux === [[Linux kernel|Linux]] uses a unified page cache for * [[sbrk|<code>brk</code>]] and anonymous [[mmap|<code>mmap</code>]]ed-regions. This includes the [[heap (programming)|heap]] and [[stack-based memory allocation|stack]] of [[user space and kernel space|user-space]] programs. It is written to swap when paged out. * Non-anonymous (file-backed) <code>mmap</code>ed regions. If present in memory and not privately modified the physical page is shared with file cache or buffer. * Shared memory acquired through [[shared memory#Support on Unix-like systems|<code>shm_open</code>]]. * The [[tmpfs]] in-memory filesystem; written to swap when paged out. * The file cache including; written to the underlying block storage (possibly going through the buffer, see below) when paged out. * The cache of [[block device]]s, called the "buffer" by Linux (not to be confused with other structures also called buffers like those use for [[anonymous pipe|pipes]] and buffers used internally in Linux); written to the underlying storage when paged out. The unified page cache operates on units of the smallest page size supported by the CPU (4 KiB in [[ARMv8]], [[x86]] and [[x86-64]]) with some pages of the next larger size (2 MiB in [[x86-64]]) called "huge pages" by Linux. The pages in the page cache are divided in an "active" set and an "inactive" set. Both sets keep a LRU list of pages. In the basic case, when a page is accessed by a user-space program it is put in the head of the inactive set. When it is accessed repeatedly, it is moved to the active list. Linux moves the pages from the active set to the inactive set as needed so that the active set is smaller than the inactive set. When a page is moved to the inactive set it is removed from the page table of any process address space, without being paged out of physical memory.<ref>See explanation at the start of [https://github.com/torvalds/linux/blob/master/mm/workingset.c <code>/mm/workingset.c</code>] in the Linux source</ref><ref>{{cite news|last1=Corbet|first1=Jonathan Corbet|title=Better active/inactive list balancing|url=https://lwn.net/Articles/495543/|date=2012-05-02|work=[[LWN.net]]}}</ref> When a page is removed from the inactive set, it is paged out of physical memory. The size of the "active" and "inactive" list can be queried from <code>/proc/meminfo</code> in the fields "Active", "Inactive", "Active(anon)", "Inactive(anon)", "Active(file)" and "Inactive(file)".
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)