<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> I am working on a project to copy (page aligned) the buffer content of one process to the buffer of other process.<br>
<br>
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>
<br>
I read some articles about, COW, 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>
<br>
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">
pte_t *src_pte, *dst_pte;<br></blockquote><blockquote style="margin-right: 0px;" dir="ltr">
src_pte = getpte(src_task);<br>
dst_pte = getpte(dst_task);<br>
free_pte(dst_pte); /*to free the page referenced by this PTE */<br>
*dst_pte = *src_pte; /*copy source PTE to destination PTE */<br>
<br></blockquote><div dir="ltr">
And here is code added to the kernel:<br>
-------------------------------------------------------------------------------------------------------------<br>
len = PAGE_SIZE;<br><span lang="ES-AR">
src_vma=find_vma_intersection(src_proc->p_task->mm,src_addr,src_addr+len);<br>
dst_vma=find_vma_intersection(dst_proc->p_task->mm,dst_addr,dst_addr+len);<br>
<br>
src_pgd=pgd_offset(src_proc->p_task->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->p_task->mm, src_pmd,(unsigned long) src_addr, &src_ptl);<br>
<br>
dst_pgd=pgd_offset(dst_proc->p_task->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->p_task->mm, dst_pmd,(unsigned long) dst_addr, &dst_ptl);<br>
<br>
pte_free(dst_proc->p_task->mm, dst_pte);<br>
<br>
copy_pte_range(dst_proc->p_task->mm, src_proc->p_task->mm, dst_pmd, src_pmd, <br>
dst_vma, (unsigned long) dst_addr, ((unsigned long)dst_addr+PAGE_SIZE));<br>
<br>
spin_unlock(src_ptl);<br>spin_unlock(dst_ptl);</span></div><div dir="ltr"><span lang="ES-AR"><br></span>
-------------------------------------------------------------------------------------------------------------<br>
<br>
There are a lots of kernel functions that are not well documented or they have been changed.<br>
<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 modify their buffers<span>?</span></span><br>
<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 English.</span></span><br>
<span lang="en" class="ecxshort_text"><span class="ecxhps"></span></span> <br>
Pablo Pessolani<br>
PD: once finishing with that code, some issues about page protection will be considered.<br>
<br>
<br>
<br></div>
                                           </div></div>                                            </div></div>                                            </div></body>
</html>