<div dir="ltr">Hi,<div><br></div><div>Recently we've worked on the bug <a href="https://jira.whamcloud.com/browse/LU-14346">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">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"> 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">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">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">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><br></div><div><br></div><div><br></div><div><div dir="ltr" class="gmail_signature" data-smartmail="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></div></div>