The canonical source of this information is /usr/src/linux/Documentation/filesystems/proc.txt
Buffers: Relatively temporary storage for raw disk blocks shouldn't
get tremendously large (20MB or so)
Cached: in-memory cache for files
read from the disk (the page cache). Doesn't include SwapCached.
You can also find some more details here.
The Linux Page Cache ("Cached:" from meminfo ) is the largest single
consumer of RAM on most systems. Any time you do a read() from a file
on disk, that data is read into memory, and goes into the page
cache(1.).
The buffer cache ("Buffers:" in meminfo) is a close
relative to the dentry/inode caches.
Or analysis the source code like this.
The amount of buffers
is the return value of function nr_blockdev_pages(void)
long nr_blockdev_pages(void)
{
struct block_device *bdev;
long ret = 0;
spin_lock(&bdev_lock);
list_for_each_entry(bdev, &all_bdevs, bd_list) {
ret += bdev->bd_inode->i_mapping->nrpages;
}
spin_unlock(&bdev_lock);
return ret;
}
The amount of cached
:
global_page_state(NR_FILE_PAGES) – total_swapcache_pages – i.bufferram
/proc/meminfo
has a field forWriteback
specifically. There is a separate fieldBuffers
, and that is what is shown asbuffers
infree -w
. A common reason forBuffers
memory usage is shown here: "30% of RAM is “buffers”. What is it?" – sourcejedi Feb 13 '19 at 16:27Buffers
is (now) a part of the page cache; it is not counted inCached
, but it is counted as part ofActive(file) + Inactive(file)
. See comments on Stephen Kitt's answer.Dirty
is the part of the page cache which has been written to, and so eventually needs writing back to disk.Writeback
does not includeDirty
. Therefore,Writeback
is not a portion of the value ofBuffers
. – sourcejedi Feb 15 '19 at 15:05Buffers
actually means is the page cache associated with the block device. Some filesystems use this internally; others don't use it at all. /goes to fixup my answer on the "30% of my RAM is buffers" question. – sourcejedi Feb 15 '19 at 15:40