]> git.ipfire.org Git - thirdparty/qemu.git/commit
contrib/plugins: add Instructions Per Second (IPS) example for cost modeling
authorPierrick Bouvier <pierrick.bouvier@linaro.org>
Thu, 20 Jun 2024 15:22:18 +0000 (16:22 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Mon, 24 Jun 2024 09:15:10 +0000 (10:15 +0100)
commit72db6d54a4a9203736261fc63f32f6cd3486b7e4
treed549b30e42fcd6926436269d28c571a77e15aaa0
parent508036532c5ee1c72896f6b950e8629cf334e485
contrib/plugins: add Instructions Per Second (IPS) example for cost modeling

This plugin uses the new time control interface to make decisions
about the state of time during the emulation. The algorithm is
currently very simple. The user specifies an ips rate which applies
per core. If the core runs ahead of its allocated execution time the
plugin sleeps for a bit to let real time catch up. Either way time is
updated for the emulation as a function of total executed instructions
with some adjustments for cores that idle.

Examples
--------

Slow down execution of /bin/true:
$ num_insn=$(./build/qemu-x86_64 -plugin ./build/tests/plugin/libinsn.so -d plugin /bin/true |& grep total | sed -e 's/.*: //')
$ time ./build/qemu-x86_64 -plugin ./build/contrib/plugins/libips.so,ips=$(($num_insn/4)) /bin/true
real 4.000s

Boot a Linux kernel simulating a 250MHz cpu:
$ /build/qemu-system-x86_64 -kernel /boot/vmlinuz-6.1.0-21-amd64 -append "console=ttyS0" -plugin ./build/contrib/plugins/libips.so,ips=$((250*1000*1000)) -smp 1 -m 512
check time until kernel panic on serial0

Tested in system mode by booting a full debian system, and using:
$ sysbench cpu run
Performance decrease linearly with the given number of ips.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240530220610.1245424-7-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240620152220.2192768-11-alex.bennee@linaro.org>
contrib/plugins/Makefile
contrib/plugins/ips.c [new file with mode: 0644]