Hi,<div><br></div><div>Are there any progresses on this issue? I&#39;ve been tracing kernel&#39;s page fault path for a while but found no clue yet. It&#39;s quite frustrating since this bug has prevented me doing any kind of benchmarks that has double/float data type...</div>

<div><br></div><div>Jinghao</div><div><br><br><div class="gmail_quote">On Wed, Dec 5, 2012 at 5:52 AM, Andrew Baumann <span dir="ltr">&lt;<a href="mailto:Andrew.Baumann@microsoft.com" target="_blank">Andrew.Baumann@microsoft.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">That’s interesting… to my knowledge there’s very little code that’s unique to SCC and not shared with x86_32.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">One likely the culprit is fpu_save and fpu_restore (from /include/arch/x86_32/barrelfish_kpi/asm_inlines_arch.h) which do fxsave and fxrstor on x86_32 but fnsave
 and frstror on SCC. Are we sure the two are equivalent?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">It might also be helpful if someone could test on real x86_32 hardware, just to rule out qemu.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Andrew<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;"> <a href="mailto:jhshi89@gmail.com" target="_blank">jhshi89@gmail.com</a> [mailto:<a href="mailto:jhshi89@gmail.com" target="_blank">jhshi89@gmail.com</a>]
<b>On Behalf Of </b>Shi Jinghao<br>
<b>Sent:</b> Tuesday, 4 December 2012 02:16<br>
<b>To:</b> Simon Peter<br>
<b>Cc:</b> Andrew Baumann; <a href="mailto:barrelfish-users@lists.inf.ethz.ch" target="_blank">barrelfish-users@lists.inf.ethz.ch</a><br>
<b>Subject:</b> Re: [Barrelfish-users] A Weird Bug about Page Fault<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hi Simon,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Yes, I think so. But this bug didn&#39;t occur on sccLinux running on SCC (see write_fault.c). So I suspect that some code in Barrelfish that deals with exception don&#39;t behave right. But I really have no idea where to debug...<u></u><u></u></p>


</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Can someone in the community who has access to SCC test the code? Many thanks.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Jinghao<u></u><u></u></p>
<div>
<p class="MsoNormal">On Tue, Dec 4, 2012 at 4:45 PM, Simon Peter &lt;<a href="mailto:speter@inf.ethz.ch" target="_blank">speter@inf.ethz.ch</a>&gt; wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Hi Jinghao,<br>
<br>
It seems this is SCC specific. I just ran your test-case on QEMU on both x86-64 and -32 platforms and it seems to work just fine (i.e. I get the &quot;all good&quot; output).<br>
<br>
Simon<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
On 12/03/2012 12:47 AM, Shi Jinghao wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">Hi Andrew,<br>
<br>
Thanks for your reply. The two different exceptions you mentioned is<br>
insightful I tried your suggestion. But that does not help. The NaN<br>
errors still occur. I also tried to put extra dummy float point<br>
operations in page fault handler. And that does not help, either.<br>
<br>
Thanks,<br>
Jinghao<br>
<br>
On Sun, Dec 2, 2012 at 2:06 AM, Andrew Baumann<u></u><u></u></p>
</div>
<p class="MsoNormal">&lt;<a href="mailto:Andrew.Baumann@microsoft.com" target="_blank">Andrew.Baumann@microsoft.com</a> &lt;mailto:<a href="mailto:Andrew.Baumann@microsoft.com" target="_blank">Andrew.Baumann@microsoft.com</a>&gt;&gt; wrote:<br>


<br>
    Hi Jinghao,____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    I notice that the first time you use floating point in this program<br>
    is when writing to the array. There should be two different<br>
    exceptions raised and handled here: one for the page fault, and one<br>
    for the first use of the floating point hardware (which we lazily<br>
    context-switch). My guess is that the page-fault path, which is not<br>
    heavily exercised, does not interact well with the floating point<u></u><u></u></p>
</div>
<p class="MsoNormal">    save/restore code.____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    If you initialise the floating point hardware by doing some other<br>
    floating point operations (or writing to a statically allocated<u></u><u></u></p>
</div>
<p class="MsoNormal">    variable) beforehand, does the problem go away?____<br>
<br>
    __ __<br>
<br>
    Andrew____<br>
<br>
    __ __<br>
<br>
    *From:* Shi Jinghao [mailto:<a href="mailto:jhshi@cs.hku.hk" target="_blank">jhshi@cs.hku.hk</a> &lt;mailto:<a href="mailto:jhshi@cs.hku.hk" target="_blank">jhshi@cs.hku.hk</a>&gt;]<br>
    *Sent:* Saturday, 1 December 2012 02:20<br>
    *To:* <a href="mailto:barrelfish-users@lists.inf.ethz.ch" target="_blank">barrelfish-users@lists.inf.ethz.ch</a><br>
    &lt;mailto:<a href="mailto:barrelfish-users@lists.inf.ethz.ch" target="_blank">barrelfish-users@lists.inf.ethz.ch</a>&gt;<br>
    *Subject:* [Barrelfish-users] A Weird Bug about Page Fault____<br>
<br>
    __ __<br>
<br>
    Hi,____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    I&#39;ve been developing a memory management library on Barrelfish<br>
    (SCC). Recently I bumped into a very weird bug about page fault. I<br>
    attached a minimal case (pgfault_test.tgz) that can reproduce this<u></u><u></u></p>
</div>
<p class="MsoNormal">    bug.____<br>
<br>
    __ __<br>
<br>
    The work flow of the test case is as simple as following:____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    1) Allocate an array of doubles as read-only, using frame_alloc and<u></u><u></u></p>
</div>
<p class="MsoNormal">    vspace_map_one_frame_attr (or pmap-&gt;f.map, this doesn&#39;t matter)____<br>
<br>
    __ __<br>
<br>
    2) Initiate the array, this will generate page fault____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    3) In page fault handler, remap the faulted page as read-write,<u></u><u></u></p>
</div>
<p class="MsoNormal">    using pmap-&gt;f.modify_flags____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    The weird thing is: the first touch of this array will not result in<u></u><u></u></p>
</div>
<p class="MsoNormal">    a proper value, but just NaN!____<br>
<br>
    __ __<br>
<br>
    I&#39;ve conducted several runs and found the following:____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    1) This bug will occur when the array type is double or float.<u></u><u></u></p>
</div>
<p class="MsoNormal">    Everything is fine if it&#39;s a integer array.____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    2) Only the item that caused the page fault will end in a NaN value,<br>
    others items are just fine. And this applies when the faulted be<u></u><u></u></p>
</div>
<p class="MsoNormal">    anywhere within that page, not just the page start.____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    3) If you assign each array value with a constant value (say 1.0),<br>
    or a int/double variable, then all items will end up with a right<br>
    value. It seems only when we assign a[i] with i (or any expression<u></u><u></u></p>
</div>
<p class="MsoNormal">    contains i) will produce this bug.____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    I tested the attached code in release2012-05-25 (the revision I work<u></u><u></u></p>
</div>
<p class="MsoNormal">    on) and the latest revision (release2012-10-03).____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    I&#39;ve also composed a minimal test case in sccLinux (write_fault.c).<u></u><u></u></p>
</div>
<p class="MsoNormal">    It turns out that everything is all good. No annoying NaN values.____<br>
<br>
    __ __<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
    This bug has bothered me for quite a few days. Really appreciate if<u></u><u></u></p>
</div>
<p class="MsoNormal">    someone can give a hint on this.____<br>
<br>
    __ __<br>
<br>
    Thanks,____<br>
<br>
    Jinghao____<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Barrelfish-users mailing list<br>
<a href="mailto:Barrelfish-users@lists.inf.ethz.ch" target="_blank">Barrelfish-users@lists.inf.ethz.ch</a><br>
<a href="https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users" target="_blank">https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users</a><u></u><u></u></p>
</blockquote>
<p class="MsoNormal"><u></u> <u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>