views:

256

answers:

3

Essentially my question is, does anyone know of a utility for inspecting the buffer cache in linux?

+1  A: 

The linux kernel doesn't cache files, it caches blocks. A file may consist of many blocks, some of which may be cached and some which may not. What exactly are you trying to accomplish?

Robert Gamble
A: 

I believe lsof might help you.

Leonardo Constantino
lsof will tell you what processes have what files open, it doesn't tell you anything about the buffer cache.
Robert Gamble
Don't be so sure. The man page is huge:-D DThis option directs lsof's use of the device cache file. The use of this option is sometimes restricted. See the DEVICE CACHE FILE section and the sections that follow it for more information on this option.
Leonardo Constantino
I am very familiar with lsof and I know that it doesn't read the kernel's buffer cache. The device cache file that you mention is a regular file that lsof can create on systems that don't have /proc to speed up device file information lookups.
Robert Gamble
A: 

More detail on what you're trying to do might be helpful. As Robert mentioned, the buffer cache isn't file-oriented.

It probably wouldn't be hard to troll through /dev/kmem to extract the contents of the buffer cache, but why would you want to?

Mark Bessey