<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>

Hi:<br>&nbsp;&nbsp;&nbsp; I am working on a project to copy (page aligned) the buffer&nbsp;content of&nbsp;one&nbsp;process to the buffer of other process.<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;Now I resolved this issue using copy_page() but, analizing performance with different buffer sizes, the "copy_page" becames the critical time component and limiting factor.<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; I read some articles about, COW, &nbsp;zero copy and page flipping and I wrote a kernel code to implement page "transfer" (only copy page references), but that code fail and hang. The kernel I use is 2.6.32.<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; The pseudocode I think is:<br><span lang="ES-AR">
</span><BR><div><div dir="ltr"><div><div dir="ltr"><blockquote style="margin-right: 0px;" dir="ltr">
&nbsp;&nbsp;&nbsp;&nbsp; pte_t *src_pte, *dst_pte;<br></blockquote><blockquote style="margin-right: 0px;" dir="ltr">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src_pte =&nbsp; getpte(src_task);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dst_pte =&nbsp; getpte(dst_task);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free_pte(dst_pte);&nbsp;&nbsp;&nbsp; /*to free the page referenced by this PTE */<br>
&nbsp;&nbsp;&nbsp;&nbsp; *dst_pte =&nbsp;*src_pte; /*copy source PTE to destination PTE */<br>
&nbsp;<br></blockquote><div dir="ltr">
And here is&nbsp;code added to the kernel:<br>
-------------------------------------------------------------------------------------------------------------<br>
len = PAGE_SIZE;<br><span lang="ES-AR">
src_vma=find_vma_intersection(src_proc-&gt;p_task-&gt;mm,src_addr,src_addr+len);<br>
dst_vma=find_vma_intersection(dst_proc-&gt;p_task-&gt;mm,dst_addr,dst_addr+len);<br>
&nbsp;<br>
src_pgd=pgd_offset(src_proc-&gt;p_task-&gt;mm, (unsigned long) src_addr);<br>
src_pud=pud_offset(src_pgd,(unsigned long) src_addr);<br>
src_pmd=pmd_offset(src_pud,(unsigned long) src_addr);<br>
src_pte=pte_offset_map_lock(src_proc-&gt;p_task-&gt;mm, src_pmd,(unsigned long) src_addr, &amp;src_ptl);<br>
&nbsp;<br>
dst_pgd=pgd_offset(dst_proc-&gt;p_task-&gt;mm, (unsigned long) dst_addr);<br>
dst_pud=pud_offset(dst_pgd,(unsigned long) dst_addr);<br>
dst_pmd=pmd_offset(dst_pud,(unsigned long) dst_addr);<br>
dst_pte=pte_offset_map_lock(dst_proc-&gt;p_task-&gt;mm, dst_pmd,(unsigned long) dst_addr, &amp;dst_ptl);<br>
&nbsp;<br>
pte_free(dst_proc-&gt;p_task-&gt;mm, dst_pte);<br>
&nbsp;<br>
copy_pte_range(dst_proc-&gt;p_task-&gt;mm, src_proc-&gt;p_task-&gt;mm, dst_pmd, src_pmd, <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dst_vma, (unsigned long) dst_addr, ((unsigned long)dst_addr+PAGE_SIZE));<br>
&nbsp;<br>
spin_unlock(src_ptl);<br>spin_unlock(dst_ptl);</span></div><div dir="ltr"><span lang="ES-AR"><br></span>
-------------------------------------------------------------------------------------------------------------<br>
&nbsp;<br>
There are a lots of kernel functions that are not well documented or they have been changed.<br>
&nbsp;<br>
Can anybody help me with this issue? Does COW (Copy On Write) <span id="ecxresult_box" lang="en"><span class="ecxhps">will</span> <span class="ecxhps">make the</span> <span class="ecxhps">copy when</span> the processes will&nbsp;modify&nbsp;their buffers<span>?</span></span><br>
&nbsp;<br>
I am not suscribed to the mailing list, please CC: the answers to this email account.<br>
Thanks in Advance.<br>
<span id="ecxresult_box" lang="en" class="ecxshort_text"><span class="ecxhps">I apologize for</span> <span class="ecxhps">my basic&nbsp;English.</span></span><br>
<span lang="en" class="ecxshort_text"><span class="ecxhps"></span></span>&nbsp;<br>
Pablo Pessolani<br>
PD: once finishing with that code, some issues&nbsp;about&nbsp;page protection&nbsp;will be considered.<br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br></div>
                                               </div></div>                                               </div></div>                                               </div></body>
</html>