Gem5

Gem5 #

SimpleSSD #

  • Install dependencies: use git clone instead of .tar.gz release because of submodules
  • Build: scons build/ARM/gem5.opt --force-lto --verbose -j 8 --ignore-style --gold-linker
    • optionally, build with HDF5: USE_HDF5=1
  • Run (upstream pre-made files download here):
./build/X86/gem5.opt --debug-flag=M5Print --debug-file=debug.txt \
    ./configs/example/fs.py --kernel=upstream-images/binaries/x86_64-vmlinux-4.9.92 \
    --disk-image=./upstream-images/disks/x86root.img \
    --num-cpu=4 --cpu-clock=2GHz --caches --l2cache --cpu-type=AtomicSimpleCPU \
    --mem-size=2GB --mem-type=DDR4_2400_8x8 \
    --ssd-interface=nvme --ssd-config=./src/dev/storage/simplessd/config/sample.cfg

Notes #

  • Upstream’s kernel boot parameter to disable all kinds of security: ... noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off mitigations=off
  • Run buildroot’s kernel:
gem5.fast --debug-file trace.txt --listener-mode on \
	--outdir m5out gem5/configs/example/fs.py \
	--kernel vmlinux --num-cpus 1 --script readfile \
    --disk-image images/rootfs.ext2 \
    --command-line "earlyprintk=ttyS0 root=/dev/sda console_msg_format=syslog nokaslr norandmaps panic=-1 rw console=ttyS0" \
    --cpu-type=AtomicSimpleCPU --mem-size=2GB \
    --mem-type=DDR4_2400_8x8

Access console by: telnet localhost 3456 or through m5term.

fio test: fio --name=test --ioengine=libaio --iodepth=4 --rw=randrw --bs=32k --direct=0 --size=64m --numjobs=1 --filename=something (20200408: fio shows illegal instruction on AtomicSimpleCPU …) (fio doc)

Speedup #

Gem5’s simulation speed is way behind normal KVM-based VM. Possible ways for speedup:

  • Modify rcS to run just the necessary processes on boot (ref), can be done by Buildroot’s overlay.
  • Checkpoint
    • run m5 checkpoint command in the script or in the bash shell
    • periodic checkpoint: --take-checkpoints=<M,N>: take checkpoints at tick M and every N ticks thereafter
    • see cirosantilli’s checkpoint guide
Calendar Last modified: April 25, 2020