8

This question answers to the question on how to find the what is part of cache. However, in the fincore executable you have to pass the filename to check if it is part of cache.

Is there a tools or a method to find all the entries that are part of the cached memory without passing the filenames.

PS: We are running it in an embedded system, and running a for loop and passing all the files to fincore itself is a more time and memory consuming process. Hence, I’m looking for other methods.

6

I don't know of any place where the kernel exposes the filenames associated with the blocks that it has cached. According to this answer

https://stackoverflow.com/a/4941371

The best you could probably do even with a custom kernel module would be to get a list of inodes and devices. From there you would still likely need to walk the filesystem looking for those files.

You may then ask "But, how does fincore know about the files I've listed?" Or you might not, but I found the method pretty clever, so here it is. The fincore tool works by doing the following:

The mincore system call tells you whether the given pages of memory are in core memory (ie, would not cause a page fault when accessed). Since mmap lazily loads the mapped file, and we haven't read any of the mapped region yet, any pages that would not cause a page fault must otherwise be part of our cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.