[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fwd: Re: Buffers VS Page Cache



In <[🔎] 4D58173B.7050005@gmail.com>, George Shuklin wrote:
>What data stored in Buffers area, and what data a stored in Cached area?
>And what difference between them?
>
>If you know at least one article in kernels sources/Documentation
>folder, or anywhere in Internet, I'll read it gladly.

http://www.linuxhowtos.org/System/Linux%20Memory%20Management.htm

First hit when doing this search, here:
http://www.google.com/search?q=what+is+the+difference+between+buffers+and+cache+in+linux+kernel+memory+reports&ie=UTF-8&oe=UTF-8

It has a section called "The difference between buffers and cache".

So, searching the web is a good start but, I can't say I know that there is 
specific documentation about this.  My understanding is: "cache" is RAM that 
exactly mirrors a part of the block device, or at least a whole page in size.  
"cache" is used for satisfying read requests to that part of the block 
device, instead of doing real I/O.  When a write occurs that that part of the 
disk the cache is invalidated and the RAM is scheduled for reuse.  "cache" 
can be dropped at any time with just a performance hit.  "buffers" can be any 
size (not necessarily a multiple of the page size) and are used mainly for 
write operations.  Instead of waiting for I/O to finish before returning from 
a system call, data is stored in a "buffer".  Once the "buffer" is confirmed 
as written to disk, the RAM is scheduled for reuse.  "buffers" can't be 
dropped until their I/O completes.  It seems that buffers can turn into cache 
and vice-versa for certain use cases, but I don't know if the kernel actually 
does that.

Both types of memory are effectively free.  Cache can be dropped willy-nilly.  
Buffers can be reclaimed by waiting for their I/O to complete.  Both of these 
actions are done automatically by the kernel when application memory pressure 
increases.
-- 
Boyd Stephen Smith Jr.                   ,= ,-_-. =.
bss@iguanasuicide.net                   ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy         `-'(. .)`-'
http://iguanasuicide.net/                    \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: