From 18c1c823feda65f8b54cd38e261c282eee01ed9f Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sun, 17 Jun 2018 12:05:00 +0100 Subject: [PATCH] gem5: integrate fs_bigLITTLE.py into run --- README.adoc | 18 +++++--- fs-biglittle | 13 ------ run | 52 ++++++++++++++++++----- run-usage.adoc | 111 ++++++++++++++++++++++++++----------------------- 4 files changed, 112 insertions(+), 82 deletions(-) delete mode 100755 fs-biglittle diff --git a/README.adoc b/README.adoc index 404f7c1..b0b16a4 100644 --- a/README.adoc +++ b/README.adoc @@ -6390,9 +6390,9 @@ The out of build tree is required, because otherwise Buildroot would copy the ou === gem5 fs_bigLITTLE -TODO integrate into `run`. There is no way to pass command line arguments except by hacking the script, this is a pre-requisite for good integration. +By default, we use `configs/example/fs.py` script. -This system is more representative of ARM, which almost always has the big little cluster. +The `-X-b` option enables the alternative `configs/example/arm/fs_bigLITTLE.py` script instead. First apply: @@ -6418,14 +6418,20 @@ index 7d66c03a6..d71e714fe 100644 then: .... -./fs-biglittle +./run -aA -g -X-b .... -Source: link:fs-biglittle[] +Advantages over `fs.py`: -Boot messages start at 5 minutes, boot finishes at 10 minutes and gives a shell. +* more representative of mobile ARM SoCs, which almost always have big little cluster +* simpler than `fs.py`, and therefore easier to understand and modify -`cat /proc/cpuinfo` shows 4 identical CPUs instead of 2 of two different types, likely because gem5 does not expose some informational register much like the caches: https://www.mail-archive.com/gem5-users@gem5.org/msg15426.html `config.ini` does show that the two big ones are `DerivO3CPU` and the small ones are `MinorCPU`. +Disadvantages over `fs.py`: + +* only works for ARM, not other archs +* not as many configuration options as `fs.py`, many things are hardcoded + +We setup 2 big and 2 small CPUs, but `cat /proc/cpuinfo` shows 4 identical CPUs instead of 2 of two different types, likely because gem5 does not expose some informational register much like the caches: https://www.mail-archive.com/gem5-users@gem5.org/msg15426.html `config.ini` does show that the two big ones are `DerivO3CPU` and the small ones are `MinorCPU`. TODO: why is the `--dtb` required despite `fs_bigLITTLE.py` having a DTB generation capability? Without it, nothing shows on terminal, and the simulation terminates with `simulate() limit reached @ 18446744073709551615`. The magic `vmlinux.vexpress_gem5_v1.20170616` works however without a DTB. diff --git a/fs-biglittle b/fs-biglittle deleted file mode 100755 index 6ecbfc9..0000000 --- a/fs-biglittle +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -. common -set_common_vars -L "${common_linux_variant}" -M "${common_gem5_variant}" aarch64 true -M5_PATH="${common_gem5_system_dir}" \ - "${common_gem5_build_dir}/ARM/gem5.opt" \ - "${common_gem5_default_src_dir}/configs/example/arm/fs_bigLITTLE.py" \ - --big-cpus=2 \ - --caches \ - --disk="${common_images_dir}/rootfs.ext2" \ - --dtb "${common_gem5_system_dir}/arm/dt/armv8_gem5_v1_big_little_2_2.dtb" \ - --kernel="${common_vmlinux}" \ - --little-cpus=2 \ -; diff --git a/run b/run index f7fc7d3..85dd820 100755 --- a/run +++ b/run @@ -18,8 +18,10 @@ extra_append='console_msg_format=syslog nokaslr norandmaps printk.devkmsg=on pri extra_append_after_dash= extra_flags= extra_flags_qemu= +extra_opts= gem5=false gem5opts= +gem5_fsbiglittle=false lkmc_eval= initrd=false initramfs=false @@ -34,7 +36,7 @@ trace_enabled=false # just to prevent QEMU from emitting a warning that '' is not valid. trace_type=pr_manager_run vnc= -while getopts a:c:DdE:e:F:f:G:ghIiKkL:M:m:n:PT:U:uVx OPT; do +while getopts a:c:DdE:e:F:f:G:ghIiKkL:M:m:n:PT:U:uVX:x OPT; do case "$OPT" in a) arch="$OPTARG" @@ -114,6 +116,9 @@ while getopts a:c:DdE:e:F:f:G:ghIiKkL:M:m:n:PT:U:uVx OPT; do u) tmux=true ;; + X) + extra_opts="${extra_opts} ${OPTARG}" + ;; x) nographic=false ;; @@ -128,6 +133,17 @@ while getopts a:c:DdE:e:F:f:G:ghIiKkL:M:m:n:PT:U:uVx OPT; do done shift "$(($OPTIND - 1))" extra_flags="$extra_flags $@" +OPTIND=1 +while getopts b OPT "$extra_opts"; do + case "$OPT" in + b) + gem5_fsbiglittle=true + ;; + ?) + exit 2 + ;; + esac +done set_common_vars -L "$common_linux_variant" -M "$common_gem5_variant" -n "$common_run_id" "$arch" "$gem5" if "$debug" && "$kvm"; then echo 'error: -d and -K are incompatible' 1>&2 @@ -176,6 +192,21 @@ ${debug_vm} \ --debug-file=trace.txt \\ ${gem5opts} \ -d '${common_m5out_dir}' \\ +" + if "$gem5_fsbiglittle"; then + cmd="${gem5_common} \ +"${common_gem5_default_src_dir}/configs/example/arm/fs_bigLITTLE.py" \ +--big-cpus=2 \\ +--cpu-type=atomic \\ +--disk="${common_images_dir}/rootfs.ext2" \\ +--dtb "${common_gem5_system_dir}/arm/dt/armv8_gem5_v1_big_little_2_2.dtb" \\ +--kernel="${common_vmlinux}" \\ +--little-cpus=2 \\ +${extra_flags} \\ +" + else + gem5_common="\ +${gem5_common} \ '${common_gem5_src_dir}/configs/example/fs.py' \\ --disk-image='${common_images_dir}/rootfs.ext2' \\ --kernel='${common_vmlinux}' \\ @@ -183,24 +214,25 @@ ${gem5opts} \ --num-cpus='${cpus}' \\ --script='${readfile_file}' \\ " - if [ "$arch" = x86_64 ]; then - if "$kvm"; then - extra_flags="$extra_flags --cpu-type=X86KvmCPU" - fi - cmd="\ + if [ "$arch" = x86_64 ]; then + if "$kvm"; then + extra_flags="$extra_flags --cpu-type=X86KvmCPU" + fi + cmd="\ ${gem5_common} \ --command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/sda ${extra_append}' \\ ${extra_flags} \ " - elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then - # TODO why is it mandatory to pass mem= here? Not true for QEMU. - # Anything smaller than physical blows up as expected, but why can't it auto-detect the right value? - cmd="${gem5_common} \ + elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then + # TODO why is it mandatory to pass mem= here? Not true for QEMU. + # Anything smaller than physical blows up as expected, but why can't it auto-detect the right value? + cmd="${gem5_common} \ --command-line='earlyprintk=pl011,0x1c090000 console=ttyAMA0 lpj=19988480 rw loglevel=8 mem=${memory} root=/dev/sda ${extra_append}' \\ --dtb-file='${common_gem5_system_dir}/arm/dt/$([ "$arch" = arm ] && echo "armv7_gem5_v1_${cpus}cpu" || echo "armv8_gem5_v1_${cpus}cpu").dtb' \\ --machine-type=VExpress_GEM5_V1 \\ ${extra_flags} \ " + fi fi else mkdir -p "$common_qemu_run_dir" diff --git a/run-usage.adoc b/run-usage.adoc index d39e7fc..1167231 100644 --- a/run-usage.adoc +++ b/run-usage.adoc @@ -6,57 +6,62 @@ [options="header"] |=== -|Name |Argument name |Description -|`-a` |`ARCH` |Run architecture `ARCH`. -|`-c` |`NCPUS` |Emulate `NCPUS` guest CPUs. -|`-D` | |Run GDB on the emulator itself. -|`-d` | |Wait for GDB to connect before starting execution. -|`-E` |`CMDSTR` |Replace the normal init with a minimal init that just evals - with given `CMDSTR` bash command string. Example: - `-E 'insmod /hello.ko;'` -|`-e` |`CLI_OPTIONS` |Pass an extra Linux kernel command line options, - and place them before the dash separator `-`. - Only options that come before the `-`, i.e. "standard" - options, should be passed with this option. - Example: `./run -a arm -e 'init=/poweroff.out'` -|`-F` |`CMDSTR` |Much like `-f`, but base64 encodes the string. - Mnemonic: `-F` is to `-f` what `-E` is to `-e`. -|`-f` |`CLI_OPTIONS` |Pass an extra Linux kernel command line options, - add a dash `-` separator, and place the options after the dash. - Intended for custom options understood by our `init` scripts, - most of which are prefixed by `lkmc_`, e.g.: - `./run -f 'lkmc_eval="wget google.com" lkmc_lala=y'` - Mnenomic: comes after `-e`. -|`-G` | |Pass extra options to the gem5 executable. - Do not confuse with the arguments passed to config scripts, - like `fs.py`. Example: `./run -G '--debug-flags=Exec --debug' -g` -|`-g` | |Use gem5 instead of QEMU. -|`-h` | |Show this help message. -|`-I` | |Run with initramfs. -|`-i` | |Run with initrd. -|`-K` | |Use KVM. Only works if guest arch == host arch. -|`-k` | |Enable KGDB. -|`-L` | |Linux kernel build variant. -|`-m` | |Set the memory size of the guest. E.g.: `-m 512M`. Default: `256M`. - The default is the minimum amount that boots all archs without extra - options added. Anything lower will lead some arch to fail to boot. - Any -|`-n` | |Run ID. -|`-P` | |Run the downloaded prebuilt images. -|`-T` |`TRACE_TYPES` |Set trace events to be enabled. - If not given, gem5 tracing is completely disabled, while QEMU tracing - is enabled but uses default traces that are very rare and don't affect - performance. `./configure --enable-trace-backends=simple` seems to enable - some traces by default, e.g. `pr_manager_run`, and I don't know how to - get rid of them. -|`-U` | |Pass extra parameters to the program running on the `-u` tmux split. -|`-u` | |Create a tmUx split the window. - You must already be inside of a `tmux` session to use this option. - * on the main window, run the emulator as usual - * on the split: - ** if on QEMU and `-d` is given, GDB - ** if on gem5, the gem5 terminal -|`-V` | |Run QEMU with VNC instead of the default SDL. - Connect to it with: `vinagre localhost:5900`. -|`-x` | |Run in graphic mode. Mnemonic: X11. +|Name |Argument name |Description +|`-a` |`ARCH` |Run architecture `ARCH`. +|`-c` |`NCPUS` |Emulate `NCPUS` guest CPUs. +|`-D` | |Run GDB on the emulator itself. +|`-d` | |Wait for GDB to connect before starting execution. +|`-E` |`CMDSTR` |Replace the normal init with a minimal init that just evals + with given `CMDSTR` bash command string. Example: + `-E 'insmod /hello.ko;'` +|`-e` |`CLI_OPTIONS` |Pass an extra Linux kernel command line options, + and place them before the dash separator `-`. + Only options that come before the `-`, i.e. "standard" + options, should be passed with this option. + Example: `./run -a arm -e 'init=/poweroff.out'` +|`-F` |`CMDSTR` |Much like `-f`, but base64 encodes the string. + Mnemonic: `-F` is to `-f` what `-E` is to `-e`. +|`-f` |`CLI_OPTIONS` |Pass an extra Linux kernel command line options, + add a dash `-` separator, and place the options after the dash. + Intended for custom options understood by our `init` scripts, + most of which are prefixed by `lkmc_`, e.g.: + `./run -f 'lkmc_eval="wget google.com" lkmc_lala=y'` + Mnenomic: comes after `-e`. +|`-G` | |Pass extra options to the gem5 executable. + Do not confuse with the arguments passed to config scripts, + like `fs.py`. Example: `./run -G '--debug-flags=Exec --debug' -g` +|`-g` | |Use gem5 instead of QEMU. +|`-h` | |Show this help message. +|`-I` | |Run with initramfs. +|`-i` | |Run with initrd. +|`-K` | |Use KVM. Only works if guest arch == host arch. +|`-k` | |Enable KGDB. +|`-L` | |Linux kernel build variant. +|`-m` | |Set the memory size of the guest. E.g.: `-m 512M`. Default: `256M`. + The default is the minimum amount that boots all archs without extra + options added. Anything lower will lead some arch to fail to boot. + Any +|`-n` | |Run ID. +|`-P` | |Run the downloaded prebuilt images. +|`-T` |`TRACE_TYPES` |Set trace events to be enabled. + If not given, gem5 tracing is completely disabled, while QEMU tracing + is enabled but uses default traces that are very rare and don't affect + performance. `./configure --enable-trace-backends=simple` seems to enable + some traces by default, e.g. `pr_manager_run`, and I don't know how to + get rid of them. +|`-U` | |Pass extra parameters to the program running on the `-u` tmux split. +|`-u` | |Create a tmUx split the window. + You must already be inside of a `tmux` session to use this option. + * on the main window, run the emulator as usual + * on the split: + ** if on QEMU and `-d` is given, GDB + ** if on gem5, the gem5 terminal +|`-V` | |Run QEMU with VNC instead of the default SDL. + Connect to it with: `vinagre localhost:5900`. +|`-X` |`EXTRA_OPTS` |Extra options that did not fit into `A-z`! + This string is parsed by `getopt` on a separate parse step with different + meanings for each flag. +|`-X-b` | |Use `fs_bigLITTLE.py` instead of `fs.py` on gem5 simulation. + Ignored by QEMU. +|`-x` | |Run in graphic mode. Mnemonic: X11. |===