elti
elti

Reputation: 103

Linux memory management (caching)

I'm having a hard time telling the difference between the different cache areas (OS). I'd love a brief explanation about disk\buffer\swap\page cache. Where do they reside? What are the main differences between them?

From what I understand the page cache is part of the main memory that stores pages brought from an I/O device. Are buffer cache and disk cache the same? Do they "live" at the I/O device?

Many thanks!!

Upvotes: 0

Views: 358

Answers (2)

julious lila
julious lila

Reputation: 56

In linux two caches were distinct: Files were in the page cache, disk blocks were in the buffer cache. Given that most files are represented by a filesystem on a disk, data was represented twice, once in each of the caches. Many Unix systems follow a similar pattern.

The buffer cache remains, however, as the kernel still needs to perform block I/O in terms of blocks, not pages. As most blocks represent file data, most of the buffer cache is represented by the page cache. But a small amount of block data isn't file backed—metadata and raw block I/O for example—and thus is solely represented by the buffer cache.

Upvotes: 4

Rupsingh
Rupsingh

Reputation: 1138

Disk cache/Buffer cache

This cache caches disk blocks to optimize block I/O.

It is the RAM used for faster access to disk.It is embedded in the disk or it can be portion of Main memory set aside.

Swap cache/Page cache

This cache caches pages of files to optimize file I/O

The swap cache is a list of page table entries. This page table entry for a swapped out page and describes which swap file the page is being held in together with its location in the swap file, so that when has to be brought back again we will be having its location in swap file.

It resides on disk.

Upvotes: 2

Related Questions