I meant &#39;file holes&#39; not &#39;wholes&#39; in last mail... my bad in shooting mails :(<br><br>Rajat<br><br><div class="gmail_quote">On Fri, Jan 7, 2011 at 11:56 AM, Rajat Sharma <span dir="ltr">&lt;<a href="mailto:fs.rajat@gmail.com">fs.rajat@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">&gt; Add your stats hooks to do_mmap or mmap_region() ???<br><br></div>mmap is one time call to initialize virtual address space of current process with corresponding region on file&#39;s disk image. Once this setting is done, this the actual calls to read data from file is accomplish through memory area&#39;s (vma) page fault handlers which in turn call readpage address space operation of an inode:<br>

<br>inode-&gt;i_mapping-&gt;a_ops-&gt;readpage(file, page).<br><br>so, suitable position is to add hooks on readpage a_op. And of-course for doing that, you may have to capture various path thorugh which inode can come in memory, e.g. lookup and create directory inode operation (for regular files). For your worst nightmare, NFS implements its readdir with an additional feature with v3 protocol called READDIR PLUS, which not only gives you name of children of a directory, but also initializes their inodes in memory, so you may have to hook readdir as well and trap aops of all regular file child after nfs_readdir is finished.<br>

<br>As far as offset and length of I/O are concerned, page-&gt;index gives you its index in the page cache which in turn is equivalent to file offset (page-&gt;index &lt;&lt; PAGE_SHIFT). readpage is invoked to bring in complete page in memory. It may so happen that page is a partial page (e.g. last page of file), in that case your I/O lenght will be inode-&gt;i_size &amp; ~PAGE_MASK, otherwise it can be PAGE_SIZE. don&#39;t worry about file wholes, that is taken care by filesystem&#39;s original readpage method.<br>

<br>Having said above, it will still be better if you can state what you want to achieve in little layman language.<br><font color="#888888"><br>Rajat</font><div><div></div><div class="h5"><br><br>On Fri, Jan 7, 2011 at 5:39 AM, Manish Katiyar <span dir="ltr">&lt;<a href="mailto:mkatiyar@gmail.com" target="_blank">mkatiyar@gmail.com</a>&gt;</span> wrote:<br>

<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div>On Thu, Jan 6, 2011 at 3:49 PM, Sebastian Pipping &lt;<a href="mailto:sebastian@pipping.org" target="_blank">sebastian@pipping.org</a>&gt; wrote:<br>


&gt; On 01/06/11 07:53, Rajat Sharma wrote:<br>
&gt;&gt; Hi Sebastian,<br>
&gt;&gt;<br>
&gt;&gt; you guess for ELF header seems to be valid to me. When executables or<br>
&gt;&gt; binaries are loaded memory, it is done through mmap call to the file,<br>
&gt;&gt; and to understand what file is and what binary handler in kernel can<br>
&gt;&gt; handle its section, kernel needs to know its header first, which is<br>
&gt;&gt; within the first page of the header with fixed location for a magic<br>
&gt;&gt; number (identifier for binary handler e.g. ELF handler which further<br>
&gt;&gt; loads its other sections by reading section table). Note that there<br>
&gt;&gt; are multiple binary format handles within the kernel e.g. ELF, A.OUT<br>
&gt;&gt; which are tried sequentially to identify the file format.<br>
&gt;&gt;<br>
&gt;&gt; From the file system perspective, mmap does not use vfs_read or<br>
&gt;&gt; vfs_write calls at all, thats why you don&#39;t see them. It directly<br>
&gt;&gt; works on address space operations of an inode (file) to populate data<br>
&gt;&gt; in page-cache. For a mmapped region, if you don&#39;t see a page in<br>
&gt;&gt; memory, kenel page faults and tries to read-in the page using readpage<br>
&gt;&gt; method of address_space_operations. Similarly when you modify a page,<br>
&gt;&gt; writepage method is called, but since executables are accessed<br>
&gt;&gt; read-only, you won&#39;t see writepage method getting called either.<br>
&gt;&gt;<br>
&gt;&gt; Hope this makes it clearer.<br>
&gt;<br>
&gt; Excellent, thank you!  I find calls to readpages on file<br>
&gt; /lib/<a href="http://libc-2.11.2.so" target="_blank">libc-2.11.2.so</a> now.  That may be the missing reads.<br>
&gt;<br>
&gt; Any ideas how get offset and length (like with vfs_read) for a certain<br>
&gt; page passed to readpage(file, page) ?<br>
<br>
</div></div>Add your stats hooks to do_mmap or mmap_region() ???<br>
<font color="#888888"><br>
--<br>
Thanks -<br>
Manish<br>
==================================<br>
[$\*.^ -- I miss being one of them<br>
==================================<br>
</font></blockquote></div><br>
</div></div></blockquote></div><br>