genode/repos/os/run/cpu_balancer.run
2023-12-13 12:28:52 +01:00

179 lines
5.0 KiB
Plaintext

build {
core init timer lib/ld
server/cpu_balancer app/cpu_burner app/top server/dynamic_rom
}
if {![have_include "power_on/qemu"]} {
puts "Run script is not supported on this platform"
exit 0
}
# foc in principle supports migration, but due to bug #4357 foc is not tested
if {![have_spec nova] && ![have_spec sel4]} {
puts "Run script is not supported on this platform"
exit 0
}
set cpu_width 4
set cpu_height 1
set report_config "yes"
set use_trace "yes"
proc report_rom_start_node { } {
global report_config
if {$report_config != "yes"} {
return { } }
return {
<start name="report_rom">
<binary name="report_rom"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="Report"/> <service name="ROM"/> </provides>
<config verbose="yes"/>
<route>
<any-service> <parent/> </any-service>
</route>
</start>
}
}
create_boot_directory
import_from_depot [depot_user]/src/report_rom \
[depot_user]/src/shim
install_config {
<config prio_levels="2" verbose="yes">
<affinity-space width="} $cpu_width {" height="} $cpu_height {"/>
<parent-provides>
<service name="LOG"/>
<service name="CPU"/>
<service name="ROM"/>
<service name="PD"/>
<service name="IO_PORT"/> <!-- timer on some kernels -->
<service name="IRQ"/> <!-- timer on some kernels -->
<service name="TRACE"/>
</parent-provides>
<default-route>
<service name="LOG"> <parent/> </service>
<service name="PD"> <parent/> </service>
<service name="ROM"> <parent/> </service>
</default-route>
<default caps="100"/>
<start name="timer">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
<route>
<any-service> <parent/> </any-service>
</route>
</start>
} [report_rom_start_node] {
<start name="dynamic_rom">
<resource name="RAM" quantum="4M"/>
<provides><service name="ROM"/> </provides>
<config verbose="yes">
<rom name="cpu_balancer.config">
<inline>
<config interval_us="2000000"
report="} $report_config {"
trace="} $use_trace {"
verbose="no">
<component label="cpu_burner -> " default_policy="none">
<!--
<thread name="signal handler" policy="pin" xpos="1" ypos="0"/>
<thread name="signal handler" policy="max-utilize"/>
-->
<thread name="burn_0x0" policy="round-robin"/>
<thread name="burn_1x0" policy="round-robin"/>
</component>
</config>
</inline>
<sleep milliseconds="2000"/>
<inline>
<config interval_us="2000000"
report="} $report_config {"
trace="} $use_trace {"
verbose="no">
<component label="cpu_burner -> " default_policy="none">
<thread name="signal handler" policy="pin" xpos="1" ypos="0"/>
<!--
<thread name="signal handler" policy="max-utilize"/>
-->
<thread name="burn_0x0" policy="round-robin"/>
<thread name="burn_1x0" policy="round-robin"/>
<thread name="not_existent" policy="round-robin"/>
</component>
</config>
</inline>
<sleep milliseconds="2000"/>
</rom>
</config>
<route>
<service name="Timer"> <child name="timer"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
<start name="cpu_balancer" caps="120">
<resource name="RAM" quantum="2M"/>
<provides>
<service name="PD"/>
<service name="CPU"/>
</provides>
<route>
<service name="ROM" label="config">
<child name="dynamic_rom" label="cpu_balancer.config"/>
</service>
<service name="Timer"> <child name="timer"/> </service>
<service name="Report"> <child name="report_rom"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
<start name="cpu_burner" priority="-1" caps="120">
<binary name="shim"/>
<affinity xpos="1" ypos="0" width="2" height="1"/>
<resource name="RAM" quantum="3M"/>
<config percent="95"/>
<route>
<!-- by shim binary -->
<service name="PD" unscoped_label="cpu_burner"> <parent/> </service>
<service name="CPU" unscoped_label="cpu_burner"> <parent/> </service>
<!-- by child of shim -->
<service name="PD"> <child name="cpu_balancer"/> </service>
<service name="CPU"> <child name="cpu_balancer"/> </service>
<service name="ROM" label="binary"> <parent label="cpu_burner"/> </service>
<service name="Timer"> <child name="timer"/> </service>
<service name="LOG"> <parent/> </service>
<service name="ROM"> <parent/> </service>
</route>
</start>
<!--
<start name="top">
<resource name="RAM" quantum="2M"/>
<route>
<service name="Timer"> <child name="timer"/> </service>
<service name="CPU"> <child name="cpu_balancer"/> </service>
<service name="TRACE"> <parent label=""/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
-->
</config>}
build_boot_image [build_artifacts]
append qemu_args " -nographic"
append qemu_args " -smp [expr $cpu_width * $cpu_height],cores=$cpu_width,threads=$cpu_height"
run_genode_until {.*thread xpos="[1-9]" ypos="0" name="signal handler" policy="pin".*\n} 60