<div dir="ltr">Hi  Andreas,<div><br></div><div>Great! Thanks for that info, will take a look at that.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 12 Mar 2022 at 08:02, Andreas Dilger <<a href="mailto:adilger@whamcloud.com">adilger@whamcloud.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div style="overflow-wrap: break-word;">
Kevin, 
<div>Qian  has a patch <a href="https://review.whamcloud.com/40092" target="_blank">https://review.whamcloud.com/40092</a> "<a href="https://jira.whamcloud.com/browse/LU-14003" target="_blank">LU-14003</a> pcc: rework PCC mmap implementation" that is changing the
 PCC MMAP code significantly, but is waiting for the 2.16.0 feature landing window to open.  It needs to be refreshed, but it would be helpful if you could take a look through that patch to see if it would resolve the issue you are seeing.<br>
<div><br>
<blockquote type="cite">
<div>On Mar 11, 2022, at 01:18, Kevin Zhao via lustre-devel <<a href="mailto:lustre-devel@lists.lustre.org" target="_blank">lustre-devel@lists.lustre.org</a>> wrote:</div>
<br>
<div>
<div dir="ltr">Hi,
<div><br>
</div>
<div>Recently we've worked on the bug <a href="https://jira.whamcloud.com/browse/LU-14346" target="_blank">https://jira.whamcloud.com/browse/LU-14346</a>. This bug will make the
<b>mmap write</b> hang forever. This one is first occurring on Aarch64, but if we do a
<a href="https://github.com/kevinzs2048/devbox/blob/master/notes/lustre/pcc_sanity-pcc-7a-analysis.md#reproduced-on-x86_64-with-a-small-change" target="_blank">
small change</a>, we <b>can easily reproduce it on X86_64</b>. For more details analysis of this bug, you can also<a href="https://github.com/kevinzs2048/devbox/blob/master/notes/lustre/pcc_sanity-pcc-7a-analysis.md" target="_blank"> check the link</a>.</div>
<div><br>
</div>
<div>The <a href="https://github.com/lustre/lustre-release/blob/master/lustre/tests/multiop.c#L725" target="_blank">
hang location is here</a> as below:<br>
==============<br>
    case 'W':<br>
        for (i = 0; i < mmap_len && mmap_ptr; i += 4096)<br>
            mmap_ptr[i] += junk++;<br>
        break;<br>
===============</div>
<div><br>
</div>
<div><b>Bug Analysis - different behavior when run </b><b>mmap_ptr[i] += junk++ on different platform.</b></div>
<div>Traditionally, this process is:<br>
1. read from mmap_ptr[i]first(Execute the read page fault)<br>
2. Write a value to the same page(execute the page_mkwrite to change the page to writable).<br>
<br>
But on different platforms, it executes quite differently.<br>
On aarch64 platform: do_page_fault, no FAULT_FLAG_WRITE set, so handle_pte_fault will call do_read_fault
<ul>
<li>do_read_fault:<br>
            __do_fault -> call ll_fault, get a page from pcc_fault<br>
            finish_fault(map the returned page to page tables)<br>
            unlock_page<br>
            vmf->flags is VM_FAULT_LOCKED</li><li>call do_wp_page --> do_page_mkwrite --> ll_page_mkwrite</li></ul>
On X86_64 platform, the mechanism is different. On X86_64, do_page_fault, with <b>
FAULT_FLAG_WRITE set</b>, so handle_pte_fault will call <b>do_shared_fault</b>.
<ul>
<li>do_shared_fault</li><ul>
<li> __do_fault -> call ll_fault, get a page from pcc_fault</li><li>do_page_mkwrite-> call ll_page_mkwrite</li><li>finish_fault(map the returned page to page tables)</li><li>fault_dirty_shared_page</li></ul>
</ul>
</div>
<div><b>Bug Analysis: why hang forever:</b></div>
<div>Also can check: <a href="https://github.com/kevinzs2048/devbox/blob/master/notes/lustre/pcc_sanity-pcc-7a-analysis.md#kernel-do_page_fault-process-analysis" target="_blank">https://github.com/kevinzs2048/devbox/blob/master/notes/lustre/pcc_sanity-pcc-7a-analysis.md#kernel-do_page_fault-process-analysis</a>
 for more details.</div>
<div><br>
</div>
<div>do_page_mkwrite--->ll_page_mkwrite.<br>
    Insert the issue 0x1412 OBD_FAIL_LLITE_PCC_DETACH_MKWRITE.<br>
    Return with VM_FAULT_RETRY | VM_FAULT_NOPAGE<br>
    RETRY again, due to PTE is not NULL, vmf->flags FAULT_FLAG_WRITE, will call do_wp_page again.<br>
So that next time we will enter into do_page_mkwrite again. hanging forever.<br>
</div>
<div><br>
</div>
<div><b>Seek a good solution</b></div>
As the above code snippet shows, <b>we want to let the kernel retry the mmap write (->fault() and ->page_mkwrite).</b><br>
In handle_pte_fault, if there is no page or the page is not mapped(no PTE found), then<br>
 __do_page_fault will try the memory fault handling. <br>
<br>
The easy fix here is to<b> remove the page and page table entry when we do fail injection in pcc_page_mkwrite.</b> But I don't find a good method to execute this, so list the info here and ask for community help.<br>
<br>
Some tried fix is:<br>
<div>add function: <b>generic_error_remove_page</b>, but the mapped page still can not be unmapped successfully.
<a href="https://github.com/kevinzs2048/devbox/blob/master/notes/lustre/pcc_sanity-pcc-7a-analysis.md#solution" target="_blank">
The error log is here</a>.<br>
</div>
<div><br>
</div>
<div>Since I'm a newbie to Lustre and not quite familiar with the memory management process, so please give some advice on this bug fix. Thanks in advance.</div>
</div>
</div>
</blockquote>
</div>
<br>
<div>
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div>Cheers, Andreas</div>
<div>--</div>
<div>Andreas Dilger</div>
<div>Lustre Principal Architect</div>
<div>Whamcloud</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</div>
<br>
<br>
</div>
<br>
</div>
</div>

</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><b>Best Regards</b><div><div style="margin:0px;padding:0px 0px 20px;width:1262px"><div><div style="margin:8px 0px 0px;padding:0px"><div><div dir="ltr"><font><div dir="ltr"><div dir="ltr"><p class="MsoNormal" style="color:rgb(136,136,136);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><b><span style="font-size:11pt"><font color="#38761d">Kevin Zhao</font></span></b></p><p class="MsoNormal" style="color:rgb(136,136,136);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><font color="#757b80"><span style="font-size:14.6667px">Tech Lead, LDCG Cloud Infrastructure</span></font></p><p class="MsoNormal" style="color:rgb(136,136,136);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><font color="#757b80"><span style="font-size:14.6667px">Linaro Vertical Technologies</span></font></p><p class="MsoNormal" style="color:rgb(136,136,136);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><font color="#757b80"><span style="font-size:14.6667px">IRC(freenode): kevinz</span></font></p><p class="MsoNormal"><font color="#757b80"><font color="#888888" face="Roboto, RobotoDraft, Helvetica, Arial, sans-serif"><span style="font-size:14.6667px">Slack(</span></font><font face="Roboto, RobotoDraft, Helvetica, Arial, sans-serif"><span style="font-size:14.6667px"><a href="http://kubernetes.slack.com" target="_blank">kubernetes.slack.com</a>)</span></font><font color="#888888" face="Roboto, RobotoDraft, Helvetica, Arial, sans-serif"><span style="font-size:14.6667px">: kevinz</span></font></font></p><p class="MsoNormal" style="color:rgb(136,136,136);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><font color="#757b80"><span style="font-size:14.6667px"><a href="mailto:kevin.zhao@linaro.org" target="_blank"><span>kevin.zhao@linaro.org</span></a> | Mobile/Direct/Wechat:  +86 18818270915</span></font><span style="color:rgb(117,123,128);font-size:11pt"> </span><br></p><div style="color:rgb(136,136,136);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><span style="color:rgb(117,123,128);font-size:11pt"><br></span></div></div></div></font></div><div style="font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"></div></div></div><div style="font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"></div></div></div></div></div></div></div></div></div></div></div>