LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Get files that are in cache (https://www.linuxquestions.org/questions/linux-kernel-70/get-files-that-are-in-cache-4175421320/)

mhtrinh 08-09-2012 09:01 PM

Get files that are in cache
 
Hi,

Short story :
I would like to get all the files that are currently loaded in the cache/buffer. Anyone know a tool to do it ??

Long story : my filesystem is an ext4 fs, with the kernel 3.4.6
I'm trying to preload files (with simple "cat files > /dev/null") in order to have better disk spin down.
I tried to trace down opened files by my usual program with "strace -ff" and "lsof" but some files are still missing. To test, I run "sync; echo 3 > /proc/sys/vm/drop_caches", preload files, follow read event in /proc/kmsg.
So now I want to drop_caches, wait my system to stabilize, run my program, get all files in cache > those are files to be preload

Thanks in advance.

unSpawn 08-10-2012 06:13 PM

Quote:

Originally Posted by mhtrinh (Post 4750439)
I'm trying to preload files

Maybe have a look at the "readahead" package?

* BTW could you please update your profile? It still lists your distribution as "Fedora 7" and I sure hope you're not running that but the current release.

mhtrinh 08-11-2012 08:01 AM

If you are talking about the kernel readahead feature : it's not adapted for what I want. readahead load big file entirely (depend on your threshold) instead of part of it only when there is an open file request. That don't work to pre-load files that you know that is goiing to be open later but are not opened yet.

About files in cache, I found a tool set linux-ftools : http://code.google.com/p/linux-ftools/
It can say if a specific file is cached (and more) or not. So to know all files that are in cache with this tool, you will have to scan through all files in your system :-(

I hope that there is more adapted tool ...

unSpawn 08-12-2012 12:29 PM

Quote:

Originally Posted by mhtrinh (Post 4751647)
readahead load big file entirely (depend on your threshold) instead of part of it only when there is an open file request. That don't work to pre-load files that you know that is goiing to be open later but are not opened yet.

Well, even though the readahead package is specifically meant for the task and even though its README specifically says "The first data block of each file is retrieved from the corresponding inode" you probably know better.


All times are GMT -5. The time now is 09:09 AM.