Question on mmap / expecting more calls to vfs_read

Mulyadi Santosa mulyadi.santosa at
Wed Jan 5 17:15:23 EST 2011


On Thu, Jan 6, 2011 at 03:16, Sebastian Pipping <sebastian at> wrote:
> When analyzing the kernel logs I produced I noticed stumbled over the
> case of a few libraries where only the beginning of the file (maybe its
> ELF header) was read repeated times, but nothing after:
>  file                   /lib/
>  max offset+count       456
>  total bytes read ever  502840
> Especially as libc is among them, I guess some reads pass by me somehow.
> Any ideas what is shoveling the file bytes around?
> I found calls to do_mmap_pgoff for these file, though.
> That's when I thought I may need help understanding how mmap works.

AFAIK, mmap will eventually calls VFS read in the case of major fault.
However, in other cases the content could already be in page cache,
that's why you don't see any filesystem or block device related

As we know, and are one of the most linked library....
therefore it is very likely they are already in the page cache. "But I
saw initial read, why is that?". IMHO that's because filesystem layer
need to make sure, it is the same file which is already cached in the
page cache.

To be precise, inode number, in which major and minor block device it
resides...and possibly other determinant factor. Just after it is
decided it's the same, page cache could be 100%
utilized..again..assuming all the content of and stays
in cache and never get flushed back.

Take the above hint with lots of salt, ok? :D


Mulyadi Santosa
Freelance Linux trainer and consultant


More information about the Kernelnewbies mailing list