Thread (9 messages) 9 messages, 4 authors, 2011-01-12

Question on mmap / expecting more calls to vfs_read

From: Sebastian Pipping <hidden>
Date: 2011-01-06 23:49:25

On 01/06/11 07:53, Rajat Sharma wrote:
Hi Sebastian,

you guess for ELF header seems to be valid to me. When executables or
binaries are loaded memory, it is done through mmap call to the file,
and to understand what file is and what binary handler in kernel can
handle its section, kernel needs to know its header first, which is
within the first page of the header with fixed location for a magic
number (identifier for binary handler e.g. ELF handler which further
loads its other sections by reading section table). Note that there
are multiple binary format handles within the kernel e.g. ELF, A.OUT
which are tried sequentially to identify the file format.

From the file system perspective, mmap does not use vfs_read or
vfs_write calls at all, thats why you don't see them. It directly
works on address space operations of an inode (file) to populate data
in page-cache. For a mmapped region, if you don't see a page in
memory, kenel page faults and tries to read-in the page using readpage
method of address_space_operations. Similarly when you modify a page,
writepage method is called, but since executables are accessed
read-only, you won't see writepage method getting called either.

Hope this makes it clearer.
Excellent, thank you!  I find calls to readpages on file
/lib/libc-2.11.2.so now.  That may be the missing reads.

Any ideas how get offset and length (like with vfs_read) for a certain
page passed to readpage(file, page) ?

Best,



Sebastian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help