Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Page cache

From Wikipedia, the free encyclopedia
Software-based, block-level cache of drive data stored in the host computer's main memory
This article'sfactual accuracy isdisputed. Relevant discussion may be found on thetalk page. Please help to ensure that disputed statements arereliably sourced.(January 2025) (Learn how and when to remove this message)

In computing, apage cache, sometimes also calleddisk cache,[1] is a transparentcache for thepages originating from asecondary storage device such as ahard disk drive (HDD) or asolid-state drive (SSD). Theoperating system keeps a page cache in otherwise unused portions of themain memory (RAM), resulting in quicker access to the contents of cached pages and overall performance improvements. A page cache is implemented inkernels with thepaging memory management, and is mostly transparent to applications.

Usually, all physical memory not directly allocated to applications is used by the operating system for the page cache. Since the memory would otherwise be idle and is easily reclaimed when applications request it, there is generally no associated performance penalty and the operating system might even report such memory as "free" or "available".

When compared to main memory, hard disk drive read/writes are slow andrandom accesses require expensivedisk seeks; as a result, larger amounts of main memory bring performance improvements as more data can be cached in memory.[2] Separate disk caching is provided on the hardware side, by dedicated RAM orNVRAM chips located either in thedisk controller (in which case the cache is integrated into a hard disk drive and usually calleddisk buffer[3]), or in adisk array controller, such memory should not be confused with the page cache. Theoperating system may also use some ofmain memory as filesystem write buffer, it may be calledpage buffer.[4]

Memory conservation

[edit]
Further information:demand paging

Pages in the page cache modified after being brought in are called dirty pages.[5] Since non-dirty pages in the page cache have identical copies insecondary storage (e.g. hard disk drive or solid-state drive), discarding and reusing their space is much quicker than paging out application memory, and is often preferred over flushing the dirty pages into secondary storage and reusing their space. Executablebinaries, such as applications and libraries, are also typically accessed through page cache and mapped to individualprocess spaces usingvirtual memory (this is done through themmap system call on Unix-like operating systems). This not only means that the binary files are shared between separate processes, but also that unused parts of binaries will be flushed out of main memory eventually, leading to memory conservation.

Since cached pages can be easily evicted and re-used, some operating systems, notablyWindows NT, even report the page cache usage as "available" memory, while the memory is actually allocated to disk pages. This has led to some confusion about the utilization of page cache in Windows.

Disk writes

[edit]

The page cache also aids in writing to a disk. Pages in the main memory that have been modified during writing data to disk are marked as "dirty" and have to be flushed to disk before they can be freed. When a file write occurs, the cached page for the particular block is looked up. If it is already found in the page cache, the write is done to that page in the main memory. If it is not found in the page cache, then, when the write perfectly falls onpage size boundaries, the page is not even read from disk, but allocated and immediately marked dirty. Otherwise, the page(s) are fetched from disk and requested modifications are done. A file that is created or opened in the page cache, but not written to, might result in azero-byte file at a later read.

However, not all cached pages can be written to as program code is often mapped asread-only orcopy-on-write; in the latter case, modifications to code will only be visible to the process itself and will not be written to disk.

Side-channel attacks

[edit]

In 2019, security researchers demonstratedside-channel attacks against the page cache: it's possible to bypassprivilege separation and exfiltrate data about other processes by systematically monitoring whether some file pages (for exampleexecutable orlibrary files) are present in the cache or not.[6]

See also

[edit]

References

[edit]
  1. ^Robert Love (2005-01-12)."Linux Kernel Development (Second Edition), Chapter 15. The Page Cache and Page Writeback".makelinux.net. Sams Publishing. Archived from the original on March 17, 2013. Retrieved2015-07-24.
  2. ^"Disk Cache".Webopedia. September 1996.
  3. ^Mark Kyrnin."What to Look for in a Hard Drive".about.com. Archived from the original on 2015-04-04. Retrieved2014-12-20.A drive's buffer is an amount of RAM on the drive to store frequently accessed data from the drive.
  4. ^"free(1) — procps — Debian bookworm — Debian Manpages".
  5. ^"Glossary - TechNet Library". Microsoft. 28 January 2010.
  6. ^Gruss, Daniel; Kraft, Erik; Tiwari, Trishita; Schwarz, Michael; Trachtenberg, Ari; Hennessey, Jason; Ionescu, Alex; Fogh, Anders (2019-01-04). "Page Cache Attacks".arXiv:1901.01161 [cs.CR].

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=Page_cache&oldid=1278568816"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp