From d282759944f5bcb788af3210625e09b92ba56e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 29 Oct 2019 00:00:00 +0000 Subject: [PATCH] ./gem5.sh: document better --- README.adoc | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- run | 5 ++++- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/README.adoc b/README.adoc index d82c6a2..460dab6 100644 --- a/README.adoc +++ b/README.adoc @@ -11526,7 +11526,7 @@ So we can do it like: .... # Boot, checkpoint and exit. printf 'echo "setup run";m5 exit' > "$(./getvar gem5_readfile_file)" -./run --emulator gem5 --eval 'm5 checkpoint;m5 readfile > a.sh;sh a.sh' +./run --emulator gem5 --eval 'm5 checkpoint;m5 readfile | sh' # Restore and run the first benchmark. printf 'echo "first benchmark";m5 exit' > "$(./getvar gem5_readfile_file)" @@ -11543,12 +11543,57 @@ printf 'sh' > "$(./getvar gem5_readfile_file)" Since this is such a common setup, we provide the following helpers for this operation: +* `./run --gem5-readfile` is a convenient way to set the `m5 readfile` file contents from a string in the command line, e.g.: ++ +.... +# Boot, checkpoint and exit. +./run --emulator gem5 --eval './gem5.sh' --gem5-readfile 'echo "setup run"' + +# Restore and run the first benchmark. +./run --emulator gem5 --gem5-restore 1 --gem5-readfile 'echo "first benchmark"' + +# Restore and run the second benchmark. +./run --emulator gem5 --gem5-restore 1 --gem5-readfile 'echo "second benchmark"' +.... * link:rootfs_overlay/lkmc/gem5.sh[]. This script is analogous to gem5's in-tree https://github.com/gem5/gem5/blob/2b4b94d0556c2d03172ebff63f7fc502c3c26ff8/configs/boot/hack_back_ckpt.rcS[hack_back_ckpt.rcS], but with less noise. -* `./run --gem5-readfile` is a convenient way to set the `m5 readfile` ++ +Usage: ++ +.... +# Boot, checkpoint and exit. +./run --emulator gem5 --eval './gem5.sh' --gem5-readfile 'echo "setup run"' -Their usage us exemplified at <>. +# Restore and run the first benchmark. +./run --emulator gem5 --gem5-restore 1 --gem5-readfile 'echo "first benchmark"' -Other loophole possibilities include: +# Restore and run the second benchmark. +./run --emulator gem5 --gem5-restore 1 --gem5-readfile 'echo "second benchmark"' +.... + +Their usage is also exemplified at <>. + +If you forgot to use an appropriate `--eval` for your boot and the simulation is already running, link:rootfs_overlay/lkmc/gem5.sh[] can be used directly from an interactive guest shell. + +First we reset the readfile to something that runs quickly: + +.... +printf 'echo "first benchmark"' > "$(./getvar gem5_readfile_file)" +.... + +and then in the guest, take a checkpoint and exit: + +.... +./gem5.sh +.... + +Now the guest is in a state where readfile will be executed automatically without interactive intervention: + +.... +./run --emulator gem5 --gem5-restore 1 --gem5-readfile 'echo "first benchmark"' +./run --emulator gem5 --gem5-restore 1 --gem5-readfile 'echo "second benchmark"' +.... + +Other loophole possibilities to execute different benchmarks non-interactively include: * <<9p>> * <> diff --git a/run b/run index cfaec32..d0daf4f 100755 --- a/run +++ b/run @@ -121,7 +121,10 @@ See: https://cirosantilli.com/linux-kernel-module-cheat#gdb self.add_argument( '--gem5-readfile', default='', - help='Set the contents of m5 readfile to this string.' + help='''\ +Set the contents of m5 readfile to this string. +https://cirosantilli.com/linux-kernel-module-cheat#gem5-restore-new-script +''' ) self.add_argument( '--gem5-restore',