This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-08-05 00:00:00 +00:00
parent 251d82c8e0
commit 305deb8d7b

View File

@@ -1126,60 +1126,63 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</ul>
</li>
<li><a href="#pass-extra-options-to-gem5">18.6. Pass extra options to gem5</a></li>
<li><a href="#gem5-exit-after-a-number-of-instructions">18.7. gem5 exit after a number of instructions</a></li>
<li><a href="#m5ops">18.8. m5ops</a>
<li><a href="#m5ops">18.7. m5ops</a>
<ul class="sectlevel3">
<li><a href="#m5">18.8.1. m5</a>
<li><a href="#m5">18.7.1. m5</a>
<ul class="sectlevel4">
<li><a href="#m5-exit">18.8.1.1. m5 exit</a></li>
<li><a href="#m5-fail">18.8.1.2. m5 fail</a></li>
<li><a href="#m5-writefile">18.8.1.3. m5 writefile</a></li>
<li><a href="#m5-readfile">18.8.1.4. m5 readfile</a></li>
<li><a href="#m5-initparam">18.8.1.5. m5 initparam</a></li>
<li><a href="#m5-execfile">18.8.1.6. m5 execfile</a></li>
<li><a href="#m5-exit">18.7.1.1. m5 exit</a></li>
<li><a href="#m5-fail">18.7.1.2. m5 fail</a></li>
<li><a href="#m5-writefile">18.7.1.3. m5 writefile</a></li>
<li><a href="#m5-readfile">18.7.1.4. m5 readfile</a></li>
<li><a href="#m5-initparam">18.7.1.5. m5 initparam</a></li>
<li><a href="#m5-execfile">18.7.1.6. m5 execfile</a></li>
</ul>
</li>
<li><a href="#m5ops-instructions">18.8.2. m5ops instructions</a>
<li><a href="#m5ops-instructions">18.7.2. m5ops instructions</a>
<ul class="sectlevel4">
<li><a href="#m5ops-instructions-interface">18.8.2.1. m5ops instructions interface</a></li>
<li><a href="#m5op-annotations">18.8.2.2. m5op annotations</a></li>
<li><a href="#m5ops-instructions-interface">18.7.2.1. m5ops instructions interface</a></li>
<li><a href="#m5op-annotations">18.7.2.2. m5op annotations</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#gem5-arm-linux-kernel-patches">18.9. gem5 arm Linux kernel patches</a>
<li><a href="#gem5-arm-linux-kernel-patches">18.8. gem5 arm Linux kernel patches</a>
<ul class="sectlevel3">
<li><a href="#gem5-arm-linux-kernel-patches-boot-speedup">18.9.1. gem5 arm Linux kernel patches boot speedup</a></li>
<li><a href="#gem5-arm-linux-kernel-patches-boot-speedup">18.8.1. gem5 arm Linux kernel patches boot speedup</a></li>
</ul>
</li>
<li><a href="#m5out-directory">18.10. m5out directory</a>
<li><a href="#m5out-directory">18.9. m5out directory</a>
<ul class="sectlevel3">
<li><a href="#system-terminal">18.10.1. system.terminal</a></li>
<li><a href="#gem5-stats-txt">18.10.2. gem5 stats.txt</a>
<li><a href="#gem5-m5out-system-terminal-file">18.9.1. gem5 m5out/system.terminal file</a></li>
<li><a href="#gem5-m5out-stats-txt-file">18.9.2. gem5 m5out/stats.txt file</a>
<ul class="sectlevel4">
<li><a href="#gem5-only-dump-selected-stats">18.10.2.1. gem5 only dump selected stats</a></li>
<li><a href="#gem5-only-dump-selected-stats">18.9.2.1. gem5 only dump selected stats</a></li>
</ul>
</li>
<li><a href="#config-ini">18.10.3. config.ini</a></li>
<li><a href="#gem5-config-ini">18.9.3. gem5 config.ini</a></li>
</ul>
</li>
<li><a href="#m5term">18.11. m5term</a></li>
<li><a href="#gem5-python-scripts-without-rebuild">18.12. gem5 Python scripts without rebuild</a></li>
<li><a href="#gem5-fs_biglittle">18.13. gem5 fs_bigLITTLE</a></li>
<li><a href="#gem5-unit-tests">18.14. gem5 unit tests</a></li>
<li><a href="#gem5-simulate-limit-reached">18.15. gem5 simulate() limit reached</a></li>
<li><a href="#gem5-build-options">18.16. gem5 build options</a>
<li><a href="#m5term">18.10. m5term</a></li>
<li><a href="#gem5-python-scripts-without-rebuild">18.11. gem5 Python scripts without rebuild</a></li>
<li><a href="#gem5-fs_biglittle">18.12. gem5 fs_bigLITTLE</a></li>
<li><a href="#gem5-unit-tests">18.13. gem5 unit tests</a></li>
<li><a href="#gem5-simulate-limit-reached">18.14. gem5 simulate() limit reached</a></li>
<li><a href="#gem5-build-options">18.15. gem5 build options</a>
<ul class="sectlevel3">
<li><a href="#gem5-debug-build">18.16.1. gem5 debug build</a></li>
<li><a href="#gem5-clang-build">18.16.2. gem5 clang build</a></li>
<li><a href="#gem5-sanitation-build">18.16.3. gem5 sanitation build</a></li>
<li><a href="#gem5-debug-build">18.15.1. gem5 debug build</a></li>
<li><a href="#gem5-clang-build">18.15.2. gem5 clang build</a></li>
<li><a href="#gem5-sanitation-build">18.15.3. gem5 sanitation build</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#buildroot">19. Buildroot</a>
<ul class="sectlevel2">
<li><a href="#introduction-to-buildroot">19.1. Introduction to Buildroot</a></li>
<li><a href="#introduction-to-buildroot">19.1. Introduction to Buildroot</a>
<ul class="sectlevel3">
<li><a href="#gem5-ruby-build">19.1.1. gem5 Ruby build</a></li>
</ul>
</li>
<li><a href="#custom-buildroot-configs">19.2. Custom Buildroot configs</a>
<ul class="sectlevel3">
<li><a href="#enable-buildroot-compiler-optimizations">19.2.1. Enable Buildroot compiler optimizations</a></li>
@@ -9419,7 +9422,7 @@ CONFIG_IKCONFIG_PROC=y</pre>
<div class="ulist">
<ul>
<li>
<p><code>arm</code> and <code>aarch64</code> configs present in the official ARM gem5 Linux kernel fork as described at: <a href="#gem5-arm-linux-kernel-patches">Section 18.9, &#8220;gem5 arm Linux kernel patches&#8221;</a>. Some of the configs present there are added by the patches.</p>
<p><code>arm</code> and <code>aarch64</code> configs present in the official ARM gem5 Linux kernel fork as described at: <a href="#gem5-arm-linux-kernel-patches">Section 18.8, &#8220;gem5 arm Linux kernel patches&#8221;</a>. Some of the configs present there are added by the patches.</p>
</li>
<li>
<p>Jason&#8217;s magic <code>x86_64</code> config: <a href="http://web.archive.org/web/20171229121642/http://www.lowepower.com/jason/files/config" class="bare">http://web.archive.org/web/20171229121642/http://www.lowepower.com/jason/files/config</a> which is referenced at: <a href="http://web.archive.org/web/20171229121525/http://www.lowepower.com/jason/setting-up-gem5-full-system.html" class="bare">http://web.archive.org/web/20171229121525/http://www.lowepower.com/jason/setting-up-gem5-full-system.html</a>. QEMU boots with that by removing <code># CONFIG_VIRTIO_PCI is not set</code>.</p>
@@ -15265,7 +15268,7 @@ ps</pre>
<p>TODO how to make gem5 disk writes persistent?</p>
</div>
<div class="paragraph">
<p>As of cadb92f2df916dbb47f428fd1ec4932a2e1f0f48 there are some <code>read_only</code> entries in the <a href="#config-ini">config.ini</a> under cow sections, but hacking them to true did not work:</p>
<p>As of cadb92f2df916dbb47f428fd1ec4932a2e1f0f48 there are some <code>read_only</code> entries in the <a href="#gem5-config-ini">gem5 config.ini</a> under cow sections, but hacking them to true did not work:</p>
</div>
<div class="literalblock">
<div class="content">
@@ -17205,7 +17208,11 @@ root</pre>
</div>
</li>
<li>
<p>disadvantage of gem5: slower than QEMU, see: <a href="#benchmark-linux-kernel-boot">Section 28.2.1, &#8220;Benchmark Linux kernel boot&#8221;</a></p>
<p>disadvantages of gem5:</p>
<div class="ulist">
<ul>
<li>
<p>slower than QEMU, see: <a href="#benchmark-linux-kernel-boot">Section 28.2.1, &#8220;Benchmark Linux kernel boot&#8221;</a></p>
<div class="paragraph">
<p>This implies that the user base is much smaller, since no Android devs.</p>
</div>
@@ -17239,6 +17246,31 @@ root</pre>
<p>On the other hand, the chip makers tend to upstream less, and the project becomes more crappy in average :-)</p>
</div>
</li>
<li>
<p>gem5 is way more complex and harder to modify and maintain</p>
<div class="paragraph">
<p>The only hairy thing in QEMU is the binary code generation.</p>
</div>
<div class="paragraph">
<p>gem5 however has tended towards intensive code generation in order to support all its different hardware types:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>lots of magic happen on top of pybind11, which is already magic, to more automatically glue the C++ and Python worlds</p>
</li>
<li>
<p>.isa code which describes most of the instructions</p>
</li>
<li>
<p><a href="#gem5-ruby-build">Ruby</a> for memory systems</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
@@ -17369,7 +17401,7 @@ cat out/gem5-bench-dhrystone.txt</pre>
</ul>
</div>
<div class="paragraph">
<p>To find out why your program is slow, a good first step is to have a look at <a href="#gem5-stats-txt">gem5 stats.txt</a> file.</p>
<p>To find out why your program is slow, a good first step is to have a look at the <a href="#gem5-m5out-stats-txt-file">gem5 m5out/stats.txt file</a>.</p>
</div>
<div class="sect3">
<h4 id="skip-extra-benchmark-instructions"><a class="anchor" href="#skip-extra-benchmark-instructions"></a><a class="link" href="#skip-extra-benchmark-instructions">18.2.1. Skip extra benchmark instructions</a></h4>
@@ -17939,7 +17971,7 @@ xdg-open bst_vs_heap_vs_hashmap_gem5.tmp.png</pre>
<p>The cache sizes were chosen to match the host <a href="#p51">P51</a> to improve the comparison. Ideally we should also use the same standard library.</p>
</div>
<div class="paragraph">
<p>Note that this will take a long time, and will produce a humongous ~40Gb stats file as explained at: <a href="#gem5-only-dump-selected-stats">Section 18.10.2.1, &#8220;gem5 only dump selected stats&#8221;</a></p>
<p>Note that this will take a long time, and will produce a humongous ~40Gb stats file as explained at: <a href="#gem5-only-dump-selected-stats">Section 18.9.2.1, &#8220;gem5 only dump selected stats&#8221;</a></p>
</div>
<div class="paragraph">
<p>Sources:</p>
@@ -18645,7 +18677,23 @@ expect eof</pre>
<div class="sect2">
<h3 id="pass-extra-options-to-gem5"><a class="anchor" href="#pass-extra-options-to-gem5"></a><a class="link" href="#pass-extra-options-to-gem5">18.6. Pass extra options to gem5</a></h3>
<div class="paragraph">
<p>Pass options to the <code>fs.py</code> script:</p>
<p>Remember that in the gem5 command line, we can either pass options to the script being run as in:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>build/X86/gem5.opt configs/examples/fs.py --some-option</pre>
</div>
</div>
<div class="paragraph">
<p>or to the gem5 executable itself:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>build/X86/gem5.opt --some-option configs/examples/fs.py</pre>
</div>
</div>
<div class="paragraph">
<p>Pass options to the script in our setup use:</p>
</div>
<div class="ulist">
<ul>
@@ -18668,7 +18716,7 @@ expect eof</pre>
</ul>
</div>
<div class="paragraph">
<p>Pass options to the <code>gem5</code> executable itself:</p>
<p>To pass options to the <code>gem5</code> executable we expose the <code>--gem5-exe-args</code> option:</p>
</div>
<div class="ulist">
<ul>
@@ -18684,32 +18732,7 @@ expect eof</pre>
</div>
</div>
<div class="sect2">
<h3 id="gem5-exit-after-a-number-of-instructions"><a class="anchor" href="#gem5-exit-after-a-number-of-instructions"></a><a class="link" href="#gem5-exit-after-a-number-of-instructions">18.7. gem5 exit after a number of instructions</a></h3>
<div class="paragraph">
<p>Quit the simulation after <code>1024</code> instructions:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>./run --emulator gem5 -- -I 1024</pre>
</div>
</div>
<div class="paragraph">
<p>Can be nicely checked with <a href="#gem5-tracing">gem5 tracing</a>.</p>
</div>
<div class="paragraph">
<p>Cycles instead of instructions:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>./run --emulator gem5 -- --memory 1024</pre>
</div>
</div>
<div class="paragraph">
<p>Otherwise the simulation runs forever by default.</p>
</div>
</div>
<div class="sect2">
<h3 id="m5ops"><a class="anchor" href="#m5ops"></a><a class="link" href="#m5ops">18.8. m5ops</a></h3>
<h3 id="m5ops"><a class="anchor" href="#m5ops"></a><a class="link" href="#m5ops">18.7. m5ops</a></h3>
<div class="paragraph">
<p>m5ops are magic instructions which lead gem5 to do magic things, like quitting or dumping stats.</p>
</div>
@@ -18749,7 +18772,7 @@ expect eof</pre>
</ul>
</div>
<div class="sect3">
<h4 id="m5"><a class="anchor" href="#m5"></a><a class="link" href="#m5">18.8.1. m5</a></h4>
<h4 id="m5"><a class="anchor" href="#m5"></a><a class="link" href="#m5">18.7.1. m5</a></h4>
<div class="paragraph">
<p><code>m5</code> is a guest command line utility that is installed and run on the guest, that serves as a CLI front-end for the <a href="#m5ops">m5ops</a></p>
</div>
@@ -18760,7 +18783,7 @@ expect eof</pre>
<p>It is possible to guess what most tools do from the corresponding <a href="#m5ops">m5ops</a>, but let&#8217;s at least document the less obvious ones here.</p>
</div>
<div class="sect4">
<h5 id="m5-exit"><a class="anchor" href="#m5-exit"></a><a class="link" href="#m5-exit">18.8.1.1. m5 exit</a></h5>
<h5 id="m5-exit"><a class="anchor" href="#m5-exit"></a><a class="link" href="#m5-exit">18.7.1.1. m5 exit</a></h5>
<div class="paragraph">
<p>End the simulation.</p>
</div>
@@ -18769,7 +18792,7 @@ expect eof</pre>
</div>
</div>
<div class="sect4">
<h5 id="m5-fail"><a class="anchor" href="#m5-fail"></a><a class="link" href="#m5-fail">18.8.1.2. m5 fail</a></h5>
<h5 id="m5-fail"><a class="anchor" href="#m5-fail"></a><a class="link" href="#m5-fail">18.7.1.2. m5 fail</a></h5>
<div class="paragraph">
<p>End the simulation with a failure exit event:</p>
</div>
@@ -18808,7 +18831,7 @@ expect eof</pre>
</div>
</div>
<div class="sect4">
<h5 id="m5-writefile"><a class="anchor" href="#m5-writefile"></a><a class="link" href="#m5-writefile">18.8.1.3. m5 writefile</a></h5>
<h5 id="m5-writefile"><a class="anchor" href="#m5-writefile"></a><a class="link" href="#m5-writefile">18.7.1.3. m5 writefile</a></h5>
<div class="paragraph">
<p>Send a guest file to the host. <a href="#9p">9P</a> is a more advanced alternative.</p>
</div>
@@ -18839,7 +18862,7 @@ m5 writefile myfileguest myfilehost</pre>
</div>
</div>
<div class="sect4">
<h5 id="m5-readfile"><a class="anchor" href="#m5-readfile"></a><a class="link" href="#m5-readfile">18.8.1.4. m5 readfile</a></h5>
<h5 id="m5-readfile"><a class="anchor" href="#m5-readfile"></a><a class="link" href="#m5-readfile">18.7.1.4. m5 readfile</a></h5>
<div class="paragraph">
<p>Read a host file pointed to by the <code>fs.py --script</code> option to stdout.</p>
</div>
@@ -18867,7 +18890,7 @@ m5 writefile myfileguest myfilehost</pre>
</div>
</div>
<div class="sect4">
<h5 id="m5-initparam"><a class="anchor" href="#m5-initparam"></a><a class="link" href="#m5-initparam">18.8.1.5. m5 initparam</a></h5>
<h5 id="m5-initparam"><a class="anchor" href="#m5-initparam"></a><a class="link" href="#m5-initparam">18.7.1.5. m5 initparam</a></h5>
<div class="paragraph">
<p>Ermm, just another <a href="#m5-readfile">m5 readfile</a> that only takes integers and only from CLI options? Is this software so redundant?</p>
</div>
@@ -18893,7 +18916,7 @@ m5 writefile myfileguest myfilehost</pre>
</div>
</div>
<div class="sect4">
<h5 id="m5-execfile"><a class="anchor" href="#m5-execfile"></a><a class="link" href="#m5-execfile">18.8.1.6. m5 execfile</a></h5>
<h5 id="m5-execfile"><a class="anchor" href="#m5-execfile"></a><a class="link" href="#m5-execfile">18.7.1.6. m5 execfile</a></h5>
<div class="paragraph">
<p>Trivial combination of <code>m5 readfile</code> + execute the script.</p>
</div>
@@ -18928,7 +18951,7 @@ m5 execfile</pre>
</div>
</div>
<div class="sect3">
<h4 id="m5ops-instructions"><a class="anchor" href="#m5ops-instructions"></a><a class="link" href="#m5ops-instructions">18.8.2. m5ops instructions</a></h4>
<h4 id="m5ops-instructions"><a class="anchor" href="#m5ops-instructions"></a><a class="link" href="#m5ops-instructions">18.7.2. m5ops instructions</a></h4>
<div class="paragraph">
<p>gem5 allocates some magic instructions on unused instruction encodings for convenient guest instrumentation.</p>
</div>
@@ -19007,7 +19030,7 @@ m5 execfile</pre>
</ul>
</div>
<div class="sect4">
<h5 id="m5ops-instructions-interface"><a class="anchor" href="#m5ops-instructions-interface"></a><a class="link" href="#m5ops-instructions-interface">18.8.2.1. m5ops instructions interface</a></h5>
<h5 id="m5ops-instructions-interface"><a class="anchor" href="#m5ops-instructions-interface"></a><a class="link" href="#m5ops-instructions-interface">18.7.2.1. m5ops instructions interface</a></h5>
<div class="paragraph">
<p>Let&#8217;s study how <a href="#m5">m5</a> uses them:</p>
</div>
@@ -19121,7 +19144,7 @@ m5_fail(ints[1], ints[0]);</pre>
</div>
</div>
<div class="sect4">
<h5 id="m5op-annotations"><a class="anchor" href="#m5op-annotations"></a><a class="link" href="#m5op-annotations">18.8.2.2. m5op annotations</a></h5>
<h5 id="m5op-annotations"><a class="anchor" href="#m5op-annotations"></a><a class="link" href="#m5op-annotations">18.7.2.2. m5op annotations</a></h5>
<div class="paragraph">
<p><code>include/gem5/asm/generic/m5ops.h</code> also describes some annotation instructions.</p>
</div>
@@ -19132,7 +19155,7 @@ m5_fail(ints[1], ints[0]);</pre>
</div>
</div>
<div class="sect2">
<h3 id="gem5-arm-linux-kernel-patches"><a class="anchor" href="#gem5-arm-linux-kernel-patches"></a><a class="link" href="#gem5-arm-linux-kernel-patches">18.9. gem5 arm Linux kernel patches</a></h3>
<h3 id="gem5-arm-linux-kernel-patches"><a class="anchor" href="#gem5-arm-linux-kernel-patches"></a><a class="link" href="#gem5-arm-linux-kernel-patches">18.8. gem5 arm Linux kernel patches</a></h3>
<div class="paragraph">
<p><a href="https://gem5.googlesource.com/arm/linux/" class="bare">https://gem5.googlesource.com/arm/linux/</a> contains an ARM Linux kernel forks with a few gem5 specific Linux kernel patches on top of mainline created by ARM Holdings on top of a few upstream kernel releases.</p>
</div>
@@ -19217,7 +19240,7 @@ git -C "$(./getvar linux_source_dir)" checkout -
<p>Tested on 649d06d6758cefd080d04dc47fd6a5a26a620874 + 1.</p>
</div>
<div class="sect3">
<h4 id="gem5-arm-linux-kernel-patches-boot-speedup"><a class="anchor" href="#gem5-arm-linux-kernel-patches-boot-speedup"></a><a class="link" href="#gem5-arm-linux-kernel-patches-boot-speedup">18.9.1. gem5 arm Linux kernel patches boot speedup</a></h4>
<h4 id="gem5-arm-linux-kernel-patches-boot-speedup"><a class="anchor" href="#gem5-arm-linux-kernel-patches-boot-speedup"></a><a class="link" href="#gem5-arm-linux-kernel-patches-boot-speedup">18.8.1. gem5 arm Linux kernel patches boot speedup</a></h4>
<div class="paragraph">
<p>We have observed that with the kernel patches, boot is 2x faster, falling from 1m40s to 50s.</p>
</div>
@@ -19235,7 +19258,7 @@ git -C "$(./getvar linux_source_dir)" checkout -
</div>
</div>
<div class="sect2">
<h3 id="m5out-directory"><a class="anchor" href="#m5out-directory"></a><a class="link" href="#m5out-directory">18.10. m5out directory</a></h3>
<h3 id="m5out-directory"><a class="anchor" href="#m5out-directory"></a><a class="link" href="#m5out-directory">18.9. m5out directory</a></h3>
<div class="paragraph">
<p>When you run gem5, it generates an <code>m5out</code> directory at:</p>
</div>
@@ -19251,7 +19274,7 @@ git -C "$(./getvar linux_source_dir)" checkout -
<p>The files in that directory contains some very important information about the run, and you should become familiar with every one of them.</p>
</div>
<div class="sect3">
<h4 id="system-terminal"><a class="anchor" href="#system-terminal"></a><a class="link" href="#system-terminal">18.10.1. system.terminal</a></h4>
<h4 id="gem5-m5out-system-terminal-file"><a class="anchor" href="#gem5-m5out-system-terminal-file"></a><a class="link" href="#gem5-m5out-system-terminal-file">18.9.1. gem5 m5out/system.terminal file</a></h4>
<div class="paragraph">
<p>Contains UART output, both from the Linux kernel or from the baremetal system.</p>
</div>
@@ -19260,7 +19283,7 @@ git -C "$(./getvar linux_source_dir)" checkout -
</div>
</div>
<div class="sect3">
<h4 id="gem5-stats-txt"><a class="anchor" href="#gem5-stats-txt"></a><a class="link" href="#gem5-stats-txt">18.10.2. gem5 stats.txt</a></h4>
<h4 id="gem5-m5out-stats-txt-file"><a class="anchor" href="#gem5-m5out-stats-txt-file"></a><a class="link" href="#gem5-m5out-stats-txt-file">18.9.2. gem5 m5out/stats.txt file</a></h4>
<div class="paragraph">
<p>This file contains important statistics about the run:</p>
</div>
@@ -19293,7 +19316,7 @@ system.cpu.dtb.inst_hits</pre>
<p>For x86, it is interesting to try and correlate <code>numCycles</code> with:</p>
</div>
<div class="sect4">
<h5 id="gem5-only-dump-selected-stats"><a class="anchor" href="#gem5-only-dump-selected-stats"></a><a class="link" href="#gem5-only-dump-selected-stats">18.10.2.1. gem5 only dump selected stats</a></h5>
<h5 id="gem5-only-dump-selected-stats"><a class="anchor" href="#gem5-only-dump-selected-stats"></a><a class="link" href="#gem5-only-dump-selected-stats">18.9.2.1. gem5 only dump selected stats</a></h5>
<div class="paragraph">
<p>TODO</p>
</div>
@@ -19306,9 +19329,9 @@ system.cpu.dtb.inst_hits</pre>
</div>
</div>
<div class="sect3">
<h4 id="config-ini"><a class="anchor" href="#config-ini"></a><a class="link" href="#config-ini">18.10.3. config.ini</a></h4>
<h4 id="gem5-config-ini"><a class="anchor" href="#gem5-config-ini"></a><a class="link" href="#gem5-config-ini">18.9.3. gem5 config.ini</a></h4>
<div class="paragraph">
<p>The <code>config.ini</code> file, contains a very good high level description of the system:</p>
<p>The <code>m5out/config.ini</code> file, contains a very good high level description of the system:</p>
</div>
<div class="literalblock">
<div class="content">
@@ -19389,7 +19412,7 @@ clock=500</pre>
</div>
</div>
<div class="sect2">
<h3 id="m5term"><a class="anchor" href="#m5term"></a><a class="link" href="#m5term">18.11. m5term</a></h3>
<h3 id="m5term"><a class="anchor" href="#m5term"></a><a class="link" href="#m5term">18.10. m5term</a></h3>
<div class="paragraph">
<p>We use the <code>m5term</code> in-tree executable to connect to the terminal instead of a direct <code>telnet</code>.</p>
</div>
@@ -19414,7 +19437,7 @@ clock=500</pre>
</div>
</div>
<div class="sect2">
<h3 id="gem5-python-scripts-without-rebuild"><a class="anchor" href="#gem5-python-scripts-without-rebuild"></a><a class="link" href="#gem5-python-scripts-without-rebuild">18.12. gem5 Python scripts without rebuild</a></h3>
<h3 id="gem5-python-scripts-without-rebuild"><a class="anchor" href="#gem5-python-scripts-without-rebuild"></a><a class="link" href="#gem5-python-scripts-without-rebuild">18.11. gem5 Python scripts without rebuild</a></h3>
<div class="paragraph">
<p>We have made a crazy setup that allows you to just <code>cd</code> into <code>submodules/gem5</code>, and edit Python scripts directly there.</p>
</div>
@@ -19448,7 +19471,7 @@ clock=500</pre>
</div>
</div>
<div class="sect2">
<h3 id="gem5-fs_biglittle"><a class="anchor" href="#gem5-fs_biglittle"></a><a class="link" href="#gem5-fs_biglittle">18.13. gem5 fs_bigLITTLE</a></h3>
<h3 id="gem5-fs_biglittle"><a class="anchor" href="#gem5-fs_biglittle"></a><a class="link" href="#gem5-fs_biglittle">18.12. gem5 fs_bigLITTLE</a></h3>
<div class="paragraph">
<p>By default, we use <code>configs/example/fs.py</code> script.</p>
</div>
@@ -19498,7 +19521,7 @@ clock=500</pre>
</ul>
</div>
<div class="paragraph">
<p>We setup 2 big and 2 small CPUs, but <code>cat /proc/cpuinfo</code> shows 4 identical CPUs instead of 2 of two different types, likely because gem5 does not expose some informational register much like the caches: <a href="https://www.mail-archive.com/gem5-users@gem5.org/msg15426.html" class="bare">https://www.mail-archive.com/gem5-users@gem5.org/msg15426.html</a> <a href="#config-ini">config.ini</a> does show that the two big ones are <code>DerivO3CPU</code> and the small ones are <code>MinorCPU</code>.</p>
<p>We setup 2 big and 2 small CPUs, but <code>cat /proc/cpuinfo</code> shows 4 identical CPUs instead of 2 of two different types, likely because gem5 does not expose some informational register much like the caches: <a href="https://www.mail-archive.com/gem5-users@gem5.org/msg15426.html" class="bare">https://www.mail-archive.com/gem5-users@gem5.org/msg15426.html</a> <a href="#gem5-config-ini">gem5 config.ini</a> does show that the two big ones are <code>DerivO3CPU</code> and the small ones are <code>MinorCPU</code>.</p>
</div>
<div class="paragraph">
<p>TODO: why is the <code>--dtb</code> required despite <code>fs_bigLITTLE.py</code> having a DTB generation capability? Without it, nothing shows on terminal, and the simulation terminates with <code>simulate() limit reached @ 18446744073709551615</code>. The magic <code>vmlinux.vexpress_gem5_v1.20170616</code> works however without a DTB.</p>
@@ -19508,7 +19531,7 @@ clock=500</pre>
</div>
</div>
<div class="sect2">
<h3 id="gem5-unit-tests"><a class="anchor" href="#gem5-unit-tests"></a><a class="link" href="#gem5-unit-tests">18.14. gem5 unit tests</a></h3>
<h3 id="gem5-unit-tests"><a class="anchor" href="#gem5-unit-tests"></a><a class="link" href="#gem5-unit-tests">18.13. gem5 unit tests</a></h3>
<div class="paragraph">
<p><a href="https://stackoverflow.com/questions/52279971/how-to-run-the-gem5-unit-tests" class="bare">https://stackoverflow.com/questions/52279971/how-to-run-the-gem5-unit-tests</a></p>
</div>
@@ -19577,7 +19600,7 @@ clock=500</pre>
</div>
</div>
<div class="sect2">
<h3 id="gem5-simulate-limit-reached"><a class="anchor" href="#gem5-simulate-limit-reached"></a><a class="link" href="#gem5-simulate-limit-reached">18.15. gem5 simulate() limit reached</a></h3>
<h3 id="gem5-simulate-limit-reached"><a class="anchor" href="#gem5-simulate-limit-reached"></a><a class="link" href="#gem5-simulate-limit-reached">18.14. gem5 simulate() limit reached</a></h3>
<div class="paragraph">
<p>This error happens when the following instruction limits are reached:</p>
</div>
@@ -19628,6 +19651,21 @@ Exiting @ tick 3000 because all threads reached the max instruction count</pre>
</div>
</div>
<div class="paragraph">
<p>The exact same can be achieved with the older hardcoded <code>--maxinsts</code> mechanism present in <code>se.py</code> and <code>fs.py</code>:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>./run \
--emulator gem5 \
--static \
--userland \userland/arch/x86_64/freestanding/linux/hello.S \
--trace-insts-stdout \
-- \
--maxinsts 3
;</pre>
</div>
</div>
<div class="paragraph">
<p>The message also shows on <a href="#user-mode-simulation">User mode simulation</a> deadlocks, for example in <a href="https://github.com/cirosantilli/linux-kernel-module-cheat/blob/master/userland/posix/pthread_deadlock.c">userland/posix/pthread_deadlock.c</a>:</p>
</div>
<div class="literalblock">
@@ -19691,12 +19729,12 @@ Exiting @ tick 18446744073709551615 because simulate() limit reached</pre>
</div>
</div>
<div class="sect2">
<h3 id="gem5-build-options"><a class="anchor" href="#gem5-build-options"></a><a class="link" href="#gem5-build-options">18.16. gem5 build options</a></h3>
<h3 id="gem5-build-options"><a class="anchor" href="#gem5-build-options"></a><a class="link" href="#gem5-build-options">18.15. gem5 build options</a></h3>
<div class="paragraph">
<p>In order to use different build options, you might also want to use <a href="#gem5-build-variants">gem5 build variants</a> to keep the build outputs separate from one another.</p>
</div>
<div class="sect3">
<h4 id="gem5-debug-build"><a class="anchor" href="#gem5-debug-build"></a><a class="link" href="#gem5-debug-build">18.16.1. gem5 debug build</a></h4>
<h4 id="gem5-debug-build"><a class="anchor" href="#gem5-debug-build"></a><a class="link" href="#gem5-debug-build">18.15.1. gem5 debug build</a></h4>
<div class="paragraph">
<p>The <code>gem5.debug</code> executable has optimizations turned off unlike the default <code>gem5.opt</code>, and provides a much better <a href="#debug-the-emulator">debug experience</a>:</p>
</div>
@@ -19726,7 +19764,7 @@ Exiting @ tick 18446744073709551615 because simulate() limit reached</pre>
</div>
</div>
<div class="sect3">
<h4 id="gem5-clang-build"><a class="anchor" href="#gem5-clang-build"></a><a class="link" href="#gem5-clang-build">18.16.2. gem5 clang build</a></h4>
<h4 id="gem5-clang-build"><a class="anchor" href="#gem5-clang-build"></a><a class="link" href="#gem5-clang-build">18.15.2. gem5 clang build</a></h4>
<div class="paragraph">
<p>TODO test properly, benchmark vs GCC.</p>
</div>
@@ -19739,7 +19777,7 @@ Exiting @ tick 18446744073709551615 because simulate() limit reached</pre>
</div>
</div>
<div class="sect3">
<h4 id="gem5-sanitation-build"><a class="anchor" href="#gem5-sanitation-build"></a><a class="link" href="#gem5-sanitation-build">18.16.3. gem5 sanitation build</a></h4>
<h4 id="gem5-sanitation-build"><a class="anchor" href="#gem5-sanitation-build"></a><a class="link" href="#gem5-sanitation-build">18.15.3. gem5 sanitation build</a></h4>
<div class="paragraph">
<p>If there gem5 appears to have a C++ undefined behaviour bug, which is often very difficult to track down, you can try to build it with the following extra SCons options:</p>
</div>
@@ -19866,6 +19904,56 @@ qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -smp 1 -kernel output/ima
</li>
</ul>
</div>
<div class="sect3">
<h4 id="gem5-ruby-build"><a class="anchor" href="#gem5-ruby-build"></a><a class="link" href="#gem5-ruby-build">19.1.1. gem5 Ruby build</a></h4>
<div class="paragraph">
<p>Ruby is a system that includes the SLICC domain specific language to describe memory systems: <a href="http://gem5.org/Ruby" class="bare">http://gem5.org/Ruby</a></p>
</div>
<div class="paragraph">
<p>It seems to have usage outside of gem5, but the naming overload with the <a href="https://en.wikipedia.org/wiki/Ruby_(programming_language)">Ruby programming language</a>, which also has <a href="https://thoughtbot.com/blog/writing-a-domain-specific-language-in-ruby">domain specific languages</a> as a concept, makes it impossible to google anything about it!</p>
</div>
<div class="paragraph">
<p>Ruby is activated at compile time with the <code>PROTOCOL</code> flag, which specifies the desired memory system time.</p>
</div>
<div class="paragraph">
<p>For example, to use a two level <a href="https://en.wikipedia.org/wiki/MESI_protocol">MESI</a> <a href="https://en.wikipedia.org/wiki/Cache_coherence">cache coherence protocol</a>, we can do:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>./build-gem5 --arch aarch64 --gem5-build-id ruby -- PROTOCOL=MESI_Two_Level</pre>
</div>
</div>
<div class="paragraph">
<p>and during build we see a humongous line of type:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>[ SLICC] src/mem/protocol/MESI_Two_Level.slicc -&gt; ARM/mem/protocol/AccessPermission.cc, ARM/mem/protocol/AccessPermission.hh, ...</pre>
</div>
</div>
<div class="paragraph">
<p>which shows that dozens of C++ files are being generated from Ruby SLICC.</p>
</div>
<div class="paragraph">
<p>TODO observe it doing something during a run.</p>
</div>
<div class="paragraph">
<p>The relevant source files live in the source tree under:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>src/mem/protocol/MESI_Two_Level*</pre>
</div>
</div>
<div class="paragraph">
<p>We already pass the <code>SLICC_HTML</code> flag by default to the build, which generates an HTML summary of each memory protocol under:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>xdg-open "$(./getvar --arch aarch64 --gem5-build-id ruby gem5_build_build_dir)/ARM/mem/protocol/html/index.html"</pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="custom-buildroot-configs"><a class="anchor" href="#custom-buildroot-configs"></a><a class="link" href="#custom-buildroot-configs">19.2. Custom Buildroot configs</a></h3>
@@ -23372,7 +23460,7 @@ pop %rbp</pre>
<p>TODO: review this section, make a more controlled userland experiment with <a href="#m5ops">m5ops</a> instrumentation.</p>
</div>
<div class="paragraph">
<p>Let&#8217;s have some fun and try to correlate the gem5 <a href="#gem5-stats-txt">gem5 stats.txt</a> <code>system.cpu.numCycles</code> cycle count with the <a href="https://en.wikipedia.org/wiki/Time_Stamp_Counter">x86 RDTSC instruction</a> that is supposed to do the same thing:</p>
<p>Let&#8217;s have some fun and try to correlate the <a href="#gem5-m5out-stats-txt-file">gem5 m5out/stats.txt file</a> <code>system.cpu.numCycles</code> cycle count with the <a href="https://en.wikipedia.org/wiki/Time_Stamp_Counter">x86 RDTSC instruction</a> that is supposed to do the same thing:</p>
</div>
<div class="literalblock">
<div class="content">
@@ -28699,7 +28787,7 @@ less "$(./getvar --arch aarch64 --emulator gem5 --run-id 1 termout_file)"</pre>
<li>
<p>gem5 automatically increments ports until it finds a free one.</p>
<div class="paragraph">
<p>gem5 60600f09c25255b3c8f72da7fb49100e2682093a does not seem to expose a way to set the terminal and VNC ports from <code>fs.py</code>, so we just let gem5 assign the ports itself, and use <code>-n</code> only to match what it assigned. Those ports both appear on <a href="#config-ini">config.ini</a>.</p>
<p>gem5 60600f09c25255b3c8f72da7fb49100e2682093a does not seem to expose a way to set the terminal and VNC ports from <code>fs.py</code>, so we just let gem5 assign the ports itself, and use <code>-n</code> only to match what it assigned. Those ports both appear on <a href="#gem5-config-ini">gem5 config.ini</a>.</p>
</div>
<div class="paragraph">
<p>The GDB port can be assigned on <code>gem5.opt --remote-gdb-port</code>, but it does not appear on <code>config.ini</code>.</p>