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

Re: Memory usage: buffer and cache



On Fri, 2004-10-22 at 00:37, Paul Johnson wrote:
> OK, this is probably the most obvious question ever, but I just can't
> find it in Google or Wikipedia.
> 
> Just what the heck is the difference between buffer and cache in terms
> of memory usage?  What is each catagory used for?

Kernel buffer cache stores the most recently accessed blocks from a
block device.

Kernel cache stores cached kernel data structures. So say you create a
process, a new task_struct may be created. When that process is
destroyed, the kernel will cache that data structure so that it doesn't
have to keep allocating and destroying common data structures. This is
the purpose of the slab layer.

Think about creating a linked list of 128,000 nodes structures. If you
delete 1000 nodes you could choose not to call free() but instead manage
that heap memory with a list of pointers. When you want to add a new
node, rather than call malloc() you could just use a pointer from your
list or a "cached node".

This is the conceptual idea behind kernel cache and the slab layer.

-- 
Eric Gaumer <gaumerel@ecs.fullerton.edu>

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


Reply to: