qemu/contrib/plugins
Pierrick Bouvier 72db6d54a4 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>
2024-06-24 10:15:10 +01:00
..
cache.c plugins: remove previous n_vcpus functions from API 2024-02-28 09:11:34 +00:00
drcov.c contrib/plugins/drcov: Fix string format 2023-09-07 12:54:17 +02:00
execlog.c plugins: Copy memory in qemu_plugin_insn_data 2024-05-15 08:55:18 +02:00
hotblocks.c contrib/plugins/hotblocks: migrate to new per_vcpu API 2024-03-06 12:35:38 +00:00
hotpages.c plugins: fix memory leak while parsing options 2023-07-03 12:51:58 +01:00
howvec.c plugins: Copy memory in qemu_plugin_insn_data 2024-05-15 08:55:18 +02:00
hwprofile.c plugins: fix memory leak while parsing options 2023-07-03 12:51:58 +01:00
ips.c contrib/plugins: add Instructions Per Second (IPS) example for cost modeling 2024-06-24 10:15:10 +01:00
lockstep.c contrib/plugins: Close file descriptor on error return 2023-10-31 14:10:21 +00:00
Makefile contrib/plugins: add Instructions Per Second (IPS) example for cost modeling 2024-06-24 10:15:10 +01:00
win32_linker.c plugins: make test/example plugins work on windows 2023-11-08 15:15:23 +00:00