From 8ecc258d3f9f2bf49c846a88d238b198b5e7268c Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 9 Mar 2021 18:18:14 +0100 Subject: [PATCH] sculpt: introduce runtime priorities This patch adds 4 priority levels to the runtime subsystem. The highest priority is used for components that are critical for the operation of Sculpt, in particular the Leitzentrale GUI. All regularly deployed components are assigned the lowest priority by default. With priorities available in the runtime subsystem, this patch flattens the priority levels at the top-level init to only two levels and overlays the priority bands of the drivers, leitzentrale, and runtime subsystems into one priority band. This has three benenfits: - This change prevents the starvation of the Leitzentrale GUI from a spinning high-priority driver (issue #3997). - The change will also ease the hosting of latency-critical components in the runtime subsystem that are prioritized higher than regular components, the storage stack, and the network stack. - The Leitzentrale GUI remains always perfectly responsive regardless of the workloads deployed from packages. In the previous version, the runtime graph was sometimes stuttering on high system load. Issue #4045 --- .../raw/drivers_managed-pc/drivers.config | 20 ++--- repos/gems/run/sculpt.run | 20 ++--- repos/gems/src/app/depot_deploy/child.h | 82 +++++++++++++------ repos/gems/src/app/depot_deploy/children.h | 4 +- repos/gems/src/app/depot_deploy/main.cc | 8 +- repos/gems/src/app/sculpt_manager/deploy.cc | 5 +- repos/gems/src/app/sculpt_manager/deploy.h | 11 ++- repos/gems/src/app/sculpt_manager/main.cc | 8 +- .../gems/src/app/sculpt_manager/menu_view.cc | 2 +- .../app/sculpt_manager/model/child_state.h | 7 +- .../app/sculpt_manager/model/ram_fs_state.h | 9 +- .../app/sculpt_manager/model/storage_device.h | 3 +- .../sculpt_manager/model/usb_storage_device.h | 3 +- .../src/app/sculpt_manager/runtime/chroot.cc | 4 +- .../app/sculpt_manager/runtime/depot_query.cc | 3 +- .../src/app/sculpt_manager/runtime/e2fs.cc | 3 +- .../app/sculpt_manager/runtime/file_system.cc | 3 +- .../src/app/sculpt_manager/runtime/fs_tool.cc | 3 +- .../app/sculpt_manager/runtime/gpt_write.cc | 3 +- .../sculpt_manager/runtime/inspect_view.cc | 19 +++-- .../sculpt_manager/runtime/launcher_query.cc | 3 +- .../src/app/sculpt_manager/runtime/nic_drv.cc | 5 +- .../app/sculpt_manager/runtime/nic_router.cc | 3 +- .../src/app/sculpt_manager/runtime/prepare.cc | 16 +++- .../src/app/sculpt_manager/runtime/update.cc | 4 +- .../app/sculpt_manager/runtime/wifi_drv.cc | 4 +- repos/gems/src/app/sculpt_manager/types.h | 13 +++ repos/gems/src/app/sculpt_manager/xml.h | 4 +- 28 files changed, 191 insertions(+), 81 deletions(-) diff --git a/repos/gems/recipes/raw/drivers_managed-pc/drivers.config b/repos/gems/recipes/raw/drivers_managed-pc/drivers.config index 14c68b4e76..27997ac861 100644 --- a/repos/gems/recipes/raw/drivers_managed-pc/drivers.config +++ b/repos/gems/recipes/raw/drivers_managed-pc/drivers.config @@ -1,4 +1,4 @@ - + @@ -79,7 +79,7 @@ - + @@ -131,7 +131,7 @@ - + @@ -150,7 +150,7 @@ - + @@ -168,7 +168,7 @@ - + @@ -184,7 +184,7 @@ - + @@ -198,7 +198,7 @@ - + @@ -209,7 +209,7 @@ - + @@ -225,7 +225,7 @@ - + @@ -243,7 +243,7 @@ - + diff --git a/repos/gems/run/sculpt.run b/repos/gems/run/sculpt.run index b107f01a69..a9641255fb 100644 --- a/repos/gems/run/sculpt.run +++ b/repos/gems/run/sculpt.run @@ -25,7 +25,7 @@ proc nic_drv {} { } install_config { - + @@ -49,13 +49,13 @@ install_config { - + - + @@ -81,14 +81,14 @@ install_config { - + - + @@ -272,7 +272,7 @@ install_config { - + @@ -376,7 +376,7 @@ install_config { - + @@ -388,7 +388,7 @@ install_config { - + @@ -401,7 +401,7 @@ install_config { - + @@ -438,7 +438,7 @@ install_config { - + diff --git a/repos/gems/src/app/depot_deploy/child.h b/repos/gems/src/app/depot_deploy/child.h index 19a96e10fc..a68443608c 100644 --- a/repos/gems/src/app/depot_deploy/child.h +++ b/repos/gems/src/app/depot_deploy/child.h @@ -37,6 +37,16 @@ class Depot_deploy::Child : public List_model::Element typedef String<32> Depot_rom_server; typedef String<100> Launcher_name; + struct Prio_levels + { + unsigned value; + + int min_priority() const + { + return (value > 0) ? -(int)(value - 1) : 0; + } + }; + private: Allocator &_alloc; @@ -296,6 +306,7 @@ class Depot_deploy::Child : public List_model::Element * is assumed to be mutable */ inline void gen_start_node(Xml_generator &, Xml_node common, + Prio_levels prio_levels, Depot_rom_server const &cached_depot_rom, Depot_rom_server const &uncached_depot_rom) const; @@ -317,6 +328,7 @@ class Depot_deploy::Child : public List_model::Element void Depot_deploy::Child::gen_start_node(Xml_generator &xml, Xml_node common, + Prio_levels prio_levels, Depot_rom_server const &cached_depot_rom, Depot_rom_server const &uncached_depot_rom) const { @@ -331,27 +343,44 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml, Xml_node common, return; } + Xml_node const launcher_xml = (_defined_by_launcher()) + ? _launcher_xml->xml() : Xml_node(""); + + Xml_node const start_xml = _start_xml->xml(); + xml.node("start", [&] () { xml.attribute("name", _name); - unsigned long caps = _pkg_cap_quota; - if (_defined_by_launcher()) - caps = _launcher_xml->xml().attribute_value("caps", caps); - caps = _start_xml->xml().attribute_value("caps", caps); + { + unsigned long caps = _pkg_cap_quota; + if (_defined_by_launcher()) + caps = launcher_xml.attribute_value("caps", caps); + caps = start_xml.attribute_value("caps", caps); + xml.attribute("caps", caps); + } - xml.attribute("caps", caps); + { + typedef String<64> Version; + Version const version = _start_xml->xml().attribute_value("version", Version()); + if (version.valid()) + xml.attribute("version", version); + } - typedef String<64> Version; - Version const version = _start_xml->xml().attribute_value("version", Version()); - if (version.valid()) - xml.attribute("version", version); + { + long priority = prio_levels.min_priority(); + if (_defined_by_launcher()) + priority = launcher_xml.attribute_value("priority", priority); + priority = start_xml.attribute_value("priority", priority); + if (priority) + xml.attribute("priority", priority); + } bool shim_reroute = false; /* lookup if PD/CPU service is configured and use shim in such cases */ - if (_start_xml->xml().has_sub_node("route")) { - Xml_node const route = _start_xml->xml().sub_node("route"); + if (start_xml.has_sub_node("route")) { + Xml_node const route = start_xml.sub_node("route"); route.for_each_sub_node("service", [&] (Xml_node const &service) { if (service.attribute_value("name", Name()) == "PD" || @@ -366,8 +395,8 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml, Xml_node common, Number_of_bytes ram = _pkg_ram_quota; if (_defined_by_launcher()) - ram = _launcher_xml->xml().attribute_value("ram", ram); - ram = _start_xml->xml().attribute_value("ram", ram); + ram = launcher_xml.attribute_value("ram", ram); + ram = start_xml.attribute_value("ram", ram); xml.node("resource", [&] () { xml.attribute("name", "RAM"); @@ -376,8 +405,8 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml, Xml_node common, unsigned long cpu_quota = _pkg_cpu_quota; if (_defined_by_launcher()) - cpu_quota = _launcher_xml->xml().attribute_value("cpu", cpu_quota); - cpu_quota = _start_xml->xml().attribute_value("cpu", cpu_quota); + cpu_quota = launcher_xml.attribute_value("cpu", cpu_quota); + cpu_quota = start_xml.attribute_value("cpu", cpu_quota); xml.node("resource", [&] () { xml.attribute("name", "CPU"); @@ -386,20 +415,20 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml, Xml_node common, /* affinity-location handling */ bool const affinity_from_launcher = _defined_by_launcher() - && _launcher_xml->xml().has_sub_node("affinity"); + && launcher_xml.has_sub_node("affinity"); - bool const affinity_from_start = _start_xml->xml().has_sub_node("affinity"); + bool const affinity_from_start = start_xml.has_sub_node("affinity"); if (affinity_from_start || affinity_from_launcher) { Affinity::Location location { }; if (affinity_from_launcher) - _launcher_xml->xml().with_sub_node("affinity", [&] (Xml_node node) { + launcher_xml.with_sub_node("affinity", [&] (Xml_node node) { location = Affinity::Location::from_xml(node); }); if (affinity_from_start) - _start_xml->xml().with_sub_node("affinity", [&] (Xml_node node) { + start_xml.with_sub_node("affinity", [&] (Xml_node node) { location = Affinity::Location::from_xml(node); }); xml.node("affinity", [&] () { @@ -416,20 +445,21 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml, Xml_node common, /* * Insert inline '' node if provided by the start node. */ - if (_start_xml->xml().has_sub_node("heartbeat")) { - _gen_copy_of_sub_node(xml, _start_xml->xml(), "heartbeat"); - } + if (start_xml.has_sub_node("heartbeat")) + _gen_copy_of_sub_node(xml, start_xml, "heartbeat"); /* * Insert inline '' node if provided by the start node, * the launcher definition (if a launcher is user), or the * blueprint. The former is preferred over the latter. */ - if (_start_xml->xml().has_sub_node("config")) { - _gen_copy_of_sub_node(xml, _start_xml->xml(), "config"); + if (start_xml.has_sub_node("config")) { + _gen_copy_of_sub_node(xml, start_xml, "config"); + } else { - if (_defined_by_launcher() && _launcher_xml->xml().has_sub_node("config")) { - _gen_copy_of_sub_node(xml, _launcher_xml->xml(), "config"); + + if (_defined_by_launcher() && launcher_xml.has_sub_node("config")) { + _gen_copy_of_sub_node(xml, launcher_xml, "config"); } else { if (runtime.has_sub_node("config")) _gen_copy_of_sub_node(xml, runtime, "config"); diff --git a/repos/gems/src/app/depot_deploy/children.h b/repos/gems/src/app/depot_deploy/children.h index 04fcbc24d0..971f02d3b0 100644 --- a/repos/gems/src/app/depot_deploy/children.h +++ b/repos/gems/src/app/depot_deploy/children.h @@ -114,11 +114,13 @@ class Depot_deploy::Children } void gen_start_nodes(Xml_generator &xml, Xml_node common, + Child::Prio_levels prio_levels, Child::Depot_rom_server const &cached_depot_rom, Child::Depot_rom_server const &uncached_depot_rom) const { _children.for_each([&] (Child const &child) { - child.gen_start_node(xml, common, cached_depot_rom, uncached_depot_rom); }); + child.gen_start_node(xml, common, prio_levels, cached_depot_rom, + uncached_depot_rom); }); } void gen_queries(Xml_generator &xml) const diff --git a/repos/gems/src/app/depot_deploy/main.cc b/repos/gems/src/app/depot_deploy/main.cc index 63dacc4f5b..21cfdfa4d3 100644 --- a/repos/gems/src/app/depot_deploy/main.cc +++ b/repos/gems/src/app/depot_deploy/main.cc @@ -66,6 +66,9 @@ struct Depot_deploy::Main _children.apply_config(config); _children.apply_blueprint(_blueprint.xml()); + Child::Prio_levels const prio_levels { + config.attribute_value("prio_levels", 0U) }; + /* determine CPU architecture of deployment */ typedef String<16> Arch; Arch const arch = config.attribute_value("arch", Arch()); @@ -75,6 +78,9 @@ struct Depot_deploy::Main /* generate init config containing all configured start nodes */ _init_config_reporter.generate([&] (Xml_generator &xml) { + if (prio_levels.value) + xml.attribute("prio_levels", prio_levels.value); + Xml_node static_config = config.sub_node("static"); static_config.with_raw_content([&] (char const *start, size_t length) { xml.append(start, length); }); @@ -123,7 +129,7 @@ struct Depot_deploy::Main Child::Depot_rom_server const parent { }; _children.gen_start_nodes(xml, config.sub_node("common_routes"), - parent, parent); + prio_levels, parent, parent); }); /* update query for blueprints of all unconfigured start nodes */ diff --git a/repos/gems/src/app/sculpt_manager/deploy.cc b/repos/gems/src/app/sculpt_manager/deploy.cc index a0e8f980b3..569ba2356f 100644 --- a/repos/gems/src/app/sculpt_manager/deploy.cc +++ b/repos/gems/src/app/sculpt_manager/deploy.cc @@ -148,7 +148,8 @@ void Sculpt::Deploy::handle_deploy() } -void Sculpt::Deploy::gen_runtime_start_nodes(Xml_generator &xml) const +void Sculpt::Deploy::gen_runtime_start_nodes(Xml_generator &xml, + Prio_levels prio_levels) const { /* depot-ROM instance for regular (immutable) depot content */ xml.node("start", [&] () { @@ -175,5 +176,5 @@ void Sculpt::Deploy::gen_runtime_start_nodes(Xml_generator &xml) const /* generate start nodes for deployed packages */ if (managed_deploy.has_sub_node("common_routes")) _children.gen_start_nodes(xml, managed_deploy.sub_node("common_routes"), - "depot_rom", "dynamic_depot_rom"); + prio_levels, "depot_rom", "dynamic_depot_rom"); } diff --git a/repos/gems/src/app/sculpt_manager/deploy.h b/repos/gems/src/app/sculpt_manager/deploy.h index 161a665e3e..0c7c760984 100644 --- a/repos/gems/src/app/sculpt_manager/deploy.h +++ b/repos/gems/src/app/sculpt_manager/deploy.h @@ -35,6 +35,8 @@ namespace Sculpt { struct Deploy; } struct Sculpt::Deploy { + typedef Depot_deploy::Child::Prio_levels Prio_levels; + Env &_env; Allocator &_alloc; @@ -58,10 +60,12 @@ struct Sculpt::Deploy Arch _arch { }; Child_state cached_depot_rom_state { - _child_states, "depot_rom", Ram_quota{24*1024*1024}, Cap_quota{200} }; + _child_states, "depot_rom", Priority::STORAGE, + Ram_quota{24*1024*1024}, Cap_quota{200} }; Child_state uncached_depot_rom_state { - _child_states, "dynamic_depot_rom", Ram_quota{8*1024*1024}, Cap_quota{200} }; + _child_states, "dynamic_depot_rom", Priority::STORAGE, + Ram_quota{8*1024*1024}, Cap_quota{200} }; /* * Report written to '/config/managed/deploy' @@ -139,6 +143,7 @@ struct Sculpt::Deploy copy_attribute("caps"); copy_attribute("ram"); copy_attribute("cpu"); + copy_attribute("priority"); copy_attribute("pkg"); /* copy start-node content */ @@ -227,7 +232,7 @@ struct Sculpt::Deploy void gen_child_diagnostics(Xml_generator &xml) const; - void gen_runtime_start_nodes(Xml_generator &) const; + void gen_runtime_start_nodes(Xml_generator &, Prio_levels) const; Signal_handler _managed_deploy_handler { _env.ep(), *this, &Deploy::_handle_managed_deploy }; diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index 1fdeb40b73..3f0fd7ae51 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -298,6 +298,8 @@ struct Sculpt::Main : Input_event_handler, ** Deploy ** ************/ + Deploy::Prio_levels const _prio_levels { 4 }; + Attached_rom_dataspace _launcher_listing_rom { _env, "report -> /runtime/launcher_query/listing" }; @@ -789,6 +791,7 @@ struct Sculpt::Main : Input_event_handler, Start_name const start_name(name, ".query"); _file_browser_state.fs_query.construct(_child_states, start_name, + Priority::LEITZENTRALE, Ram_quota{8*1024*1024}, Cap_quota{200}); Label const rom_label("report -> /runtime/", start_name, "/listing"); @@ -851,6 +854,7 @@ struct Sculpt::Main : Input_event_handler, } else { Start_name const start_name("editor"); _file_browser_state.text_area.construct(_child_states, start_name, + Priority::LEITZENTRALE, Ram_quota{16*1024*1024}, Cap_quota{250}); } } @@ -1632,6 +1636,8 @@ void Sculpt::Main::_generate_runtime_config(Xml_generator &xml) const { xml.attribute("verbose", "yes"); + xml.attribute("prio_levels", _prio_levels.value); + xml.node("report", [&] () { xml.attribute("init_ram", "yes"); xml.attribute("init_caps", "yes"); @@ -1728,7 +1734,7 @@ void Sculpt::Main::_generate_runtime_config(Xml_generator &xml) const xml.node("start", [&] () { gen_launcher_query_start_content(xml); }); - _deploy.gen_runtime_start_nodes(xml); + _deploy.gen_runtime_start_nodes(xml, _prio_levels); } } diff --git a/repos/gems/src/app/sculpt_manager/menu_view.cc b/repos/gems/src/app/sculpt_manager/menu_view.cc index 9aac73bdb5..d774a19dad 100644 --- a/repos/gems/src/app/sculpt_manager/menu_view.cc +++ b/repos/gems/src/app/sculpt_manager/menu_view.cc @@ -51,7 +51,7 @@ Menu_view::Menu_view(Env &env, Registry ®istry, Session_label const &hover_rom_name) : _dialog(dialog), - _child_state(registry, name, ram_quota, cap_quota), + _child_state(registry, name, Priority::LEITZENTRALE, ram_quota, cap_quota), _dialog_reporter(env, "dialog", dialog_report_name.string()), _hover_rom(env, hover_rom_name.string()), _hover_handler(env.ep(), *this, &Menu_view::_handle_hover) diff --git a/repos/gems/src/app/sculpt_manager/model/child_state.h b/repos/gems/src/app/sculpt_manager/model/child_state.h index 751733e67b..5ec1bd344f 100644 --- a/repos/gems/src/app/sculpt_manager/model/child_state.h +++ b/repos/gems/src/app/sculpt_manager/model/child_state.h @@ -35,6 +35,8 @@ struct Sculpt::Child_state : Noncopyable Start_name const _name; + Priority const _priority; + Ram_quota const _initial_ram_quota; Cap_quota const _initial_cap_quota; @@ -52,10 +54,10 @@ struct Sculpt::Child_state : Noncopyable * \param cap_quota initial capability quota */ Child_state(Registry ®istry, Start_name const &name, - Ram_quota ram_quota, Cap_quota cap_quota) + Priority priority, Ram_quota ram_quota, Cap_quota cap_quota) : _element(registry, *this), - _name(name), + _name(name), _priority(priority), _initial_ram_quota(ram_quota), _initial_cap_quota(cap_quota) { } @@ -79,6 +81,7 @@ struct Sculpt::Child_state : Noncopyable gen_start_node_version(xml); xml.attribute("caps", _cap_quota.value); + xml.attribute("priority", (int)_priority); gen_named_node(xml, "resource", "RAM", [&] () { Number_of_bytes const bytes(_ram_quota.value); xml.attribute("quantum", String<64>(bytes)); }); diff --git a/repos/gems/src/app/sculpt_manager/model/ram_fs_state.h b/repos/gems/src/app/sculpt_manager/model/ram_fs_state.h index 85d7bd852b..0288f3340c 100644 --- a/repos/gems/src/app/sculpt_manager/model/ram_fs_state.h +++ b/repos/gems/src/app/sculpt_manager/model/ram_fs_state.h @@ -26,9 +26,16 @@ namespace Sculpt { struct Ram_fs_state; } struct Sculpt::Ram_fs_state : Child_state, File_system { + /* + * Use Priority::LEITZENTRALE for the RAM file system to make the + * inspect view available even in conditions when a malfunctioning + * high-priority driver is spinning. + */ + Ram_fs_state(Registry ®istry, Start_name const &name) : - Child_state(registry, name, Ram_quota{1024*1024}, Cap_quota{300}), + Child_state(registry, name, Priority::LEITZENTRALE, + Ram_quota{1024*1024}, Cap_quota{300}), File_system(File_system::UNKNOWN) { } }; diff --git a/repos/gems/src/app/sculpt_manager/model/storage_device.h b/repos/gems/src/app/sculpt_manager/model/storage_device.h index dcf5d6af43..badb5f5507 100644 --- a/repos/gems/src/app/sculpt_manager/model/storage_device.h +++ b/repos/gems/src/app/sculpt_manager/model/storage_device.h @@ -215,7 +215,8 @@ void Sculpt::Storage_device::gen_part_block_start_content(Xml_generator &xml, xml.attribute("version", _part_block_version); gen_common_start_content(xml, Label(label, ".part_block"), - Cap_quota{100}, Ram_quota{8*1024*1024}); + Cap_quota{100}, Ram_quota{8*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "part_block"); diff --git a/repos/gems/src/app/sculpt_manager/model/usb_storage_device.h b/repos/gems/src/app/sculpt_manager/model/usb_storage_device.h index a17ba269f0..54829ee974 100644 --- a/repos/gems/src/app/sculpt_manager/model/usb_storage_device.h +++ b/repos/gems/src/app/sculpt_manager/model/usb_storage_device.h @@ -111,7 +111,8 @@ struct Sculpt::Usb_storage_device : List_model::Element, void Sculpt::Usb_storage_device::gen_usb_block_drv_start_content(Xml_generator &xml) const { gen_common_start_content(xml, usb_block_drv_name(), - Cap_quota{100}, Ram_quota{6*1024*1024}); + Cap_quota{100}, Ram_quota{6*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "usb_block_drv"); diff --git a/repos/gems/src/app/sculpt_manager/runtime/chroot.cc b/repos/gems/src/app/sculpt_manager/runtime/chroot.cc index 716c7d9779..923b920e8c 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/chroot.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/chroot.cc @@ -16,7 +16,9 @@ void Sculpt::gen_chroot_start_content(Xml_generator &xml, Start_name const &name, Path const &path, Writeable writable) { - gen_common_start_content(xml, name, Cap_quota{100}, Ram_quota{2*1024*1024}); + gen_common_start_content(xml, name, + Cap_quota{100}, Ram_quota{2*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "chroot"); diff --git a/repos/gems/src/app/sculpt_manager/runtime/depot_query.cc b/repos/gems/src/app/sculpt_manager/runtime/depot_query.cc index 92f00188b4..133ff1e43a 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/depot_query.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/depot_query.cc @@ -16,7 +16,8 @@ void Sculpt::gen_depot_query_start_content(Xml_generator &xml) { gen_common_start_content(xml, "depot_query", - Cap_quota{200}, Ram_quota{2*1024*1024}); + Cap_quota{200}, Ram_quota{2*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "depot_query"); diff --git a/repos/gems/src/app/sculpt_manager/runtime/e2fs.cc b/repos/gems/src/app/sculpt_manager/runtime/e2fs.cc index 00bced3a9f..6024bd5659 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/e2fs.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/e2fs.cc @@ -34,7 +34,8 @@ void Sculpt::gen_e2fs_start_content(Xml_generator &xml, GEN_ARGS_FN const &gen_args_fn) { gen_common_start_content(xml, String<64>(target.label(), ".", tool), - Cap_quota{500}, Ram_quota{100*1024*1024}); + Cap_quota{500}, Ram_quota{100*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", tool); diff --git a/repos/gems/src/app/sculpt_manager/runtime/file_system.cc b/repos/gems/src/app/sculpt_manager/runtime/file_system.cc index 06c2700fd9..57a6c5856b 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/file_system.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/file_system.cc @@ -18,7 +18,8 @@ void Sculpt::gen_fs_start_content(Xml_generator &xml, File_system::Type fs_type) { gen_common_start_content(xml, target.fs(), - Cap_quota{400}, Ram_quota{64*1024*1024}); + Cap_quota{400}, Ram_quota{64*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "vfs"); diff --git a/repos/gems/src/app/sculpt_manager/runtime/fs_tool.cc b/repos/gems/src/app/sculpt_manager/runtime/fs_tool.cc index fdf54ecbea..c9ce3a3f79 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/fs_tool.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/fs_tool.cc @@ -19,7 +19,8 @@ void Sculpt::gen_fs_tool_start_content(Xml_generator &xml, Fs_tool_version versi { xml.attribute("version", version.value); - gen_common_start_content(xml, "fs_tool", Cap_quota{200}, Ram_quota{5*1024*1024}); + gen_common_start_content(xml, "fs_tool", Cap_quota{200}, Ram_quota{5*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "fs_tool"); diff --git a/repos/gems/src/app/sculpt_manager/runtime/gpt_write.cc b/repos/gems/src/app/sculpt_manager/runtime/gpt_write.cc index c7893dee28..7277f9fd82 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/gpt_write.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/gpt_write.cc @@ -27,7 +27,8 @@ void Sculpt::_gen_gpt_write_start_content(Xml_generator &xml, Start_name const &name, GEN_ACTIONS_FN const &fn) { - gen_common_start_content(xml, name, Cap_quota{100}, Ram_quota{2*1024*1024}); + gen_common_start_content(xml, name, Cap_quota{100}, Ram_quota{2*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "gpt_write"); diff --git a/repos/gems/src/app/sculpt_manager/runtime/inspect_view.cc b/repos/gems/src/app/sculpt_manager/runtime/inspect_view.cc index d9fc48f967..71eb8405c7 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/inspect_view.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/inspect_view.cc @@ -28,7 +28,9 @@ static void for_each_inspected_storage_target(Storage_devices const &devices, FN static void gen_terminal_start(Xml_generator &xml) { - gen_common_start_content(xml, "terminal", Cap_quota{110}, Ram_quota{18*1024*1024}); + gen_common_start_content(xml, "terminal", + Cap_quota{110}, Ram_quota{18*1024*1024}, + Priority::LEITZENTRALE); gen_provides(xml); @@ -50,7 +52,9 @@ static void gen_vfs_start(Xml_generator &xml, Storage_devices const &devices, Ram_fs_state const &ram_fs_state) { - gen_common_start_content(xml, "vfs", Cap_quota{200}, Ram_quota{5*1024*1024}); + gen_common_start_content(xml, "vfs", + Cap_quota{200}, Ram_quota{5*1024*1024}, + Priority::LEITZENTRALE); gen_provides<::File_system::Session>(xml); @@ -129,7 +133,9 @@ static void gen_vfs_start(Xml_generator &xml, static void gen_fs_rom_start(Xml_generator &xml) { - gen_common_start_content(xml, "vfs_rom", Cap_quota{100}, Ram_quota{15*1024*1024}); + gen_common_start_content(xml, "vfs_rom", + Cap_quota{100}, Ram_quota{15*1024*1024}, + Priority::LEITZENTRALE); gen_named_node(xml, "binary", "cached_fs_rom", [&] () { }); @@ -148,7 +154,9 @@ static void gen_fs_rom_start(Xml_generator &xml) static void gen_bash_start(Xml_generator &xml) { - gen_common_start_content(xml, "bash", Cap_quota{400}, Ram_quota{15*1024*1024}); + gen_common_start_content(xml, "bash", + Cap_quota{400}, Ram_quota{15*1024*1024}, + Priority::LEITZENTRALE); gen_named_node(xml, "binary", "/bin/bash", [&] () { }); @@ -206,7 +214,8 @@ void Sculpt::gen_inspect_view(Xml_generator &xml, xml.attribute("version", version.value); gen_common_start_content(xml, "inspect", - Cap_quota{1000}, Ram_quota{76*1024*1024}); + Cap_quota{1000}, Ram_quota{76*1024*1024}, + Priority::LEITZENTRALE); gen_named_node(xml, "binary", "init", [&] () { }); diff --git a/repos/gems/src/app/sculpt_manager/runtime/launcher_query.cc b/repos/gems/src/app/sculpt_manager/runtime/launcher_query.cc index fbd66edd43..867e6314f7 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/launcher_query.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/launcher_query.cc @@ -16,7 +16,8 @@ void Sculpt::gen_launcher_query_start_content(Xml_generator &xml) { gen_common_start_content(xml, "launcher_query", - Cap_quota{200}, Ram_quota{2*1024*1024}); + Cap_quota{200}, Ram_quota{2*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "fs_query"); diff --git a/repos/gems/src/app/sculpt_manager/runtime/nic_drv.cc b/repos/gems/src/app/sculpt_manager/runtime/nic_drv.cc index b1748ac67a..f36e3ce468 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/nic_drv.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/nic_drv.cc @@ -16,7 +16,10 @@ void Sculpt::gen_nic_drv_start_content(Xml_generator &xml) { - gen_common_start_content(xml, "nic_drv", Cap_quota{300}, Ram_quota{16*1024*1024}); + gen_common_start_content(xml, "nic_drv", + Cap_quota{300}, Ram_quota{16*1024*1024}, + Priority::NETWORK); + gen_named_node(xml, "resource", "CPU", [&] () { xml.attribute("quantum", "50"); }); xml.node("config", [&] () { xml.attribute("mode", "uplink_client"); }); diff --git a/repos/gems/src/app/sculpt_manager/runtime/nic_router.cc b/repos/gems/src/app/sculpt_manager/runtime/nic_router.cc index 56ef5ce652..c2e063109b 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/nic_router.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/nic_router.cc @@ -21,7 +21,8 @@ void Sculpt::gen_nic_router_start_content(Xml_generator &xml) { gen_common_start_content(xml, "nic_router", - Cap_quota{300}, Ram_quota{10*1024*1024}); + Cap_quota{300}, Ram_quota{10*1024*1024}, + Priority::NETWORK); xml.node("provides", [&] () { xml.node("service", [&] () { diff --git a/repos/gems/src/app/sculpt_manager/runtime/prepare.cc b/repos/gems/src/app/sculpt_manager/runtime/prepare.cc index 003d0f86d8..887ddfb214 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/prepare.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/prepare.cc @@ -23,7 +23,9 @@ namespace Sculpt { void Sculpt::gen_prepare_vfs_start(Xml_generator &xml) { - gen_common_start_content(xml, "vfs", Cap_quota{200}, Ram_quota{5*1024*1024}); + gen_common_start_content(xml, "vfs", + Cap_quota{200}, Ram_quota{5*1024*1024}, + Priority::STORAGE); char const * const script = "export VERSION=`cat /VERSION`\n" @@ -79,7 +81,9 @@ void Sculpt::gen_prepare_vfs_start(Xml_generator &xml) void Sculpt::gen_prepare_fs_rom_start(Xml_generator &xml) { - gen_common_start_content(xml, "vfs_rom", Cap_quota{100}, Ram_quota{15*1024*1024}); + gen_common_start_content(xml, "vfs_rom", + Cap_quota{100}, Ram_quota{15*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "fs_rom", [&] () { }); @@ -98,7 +102,9 @@ void Sculpt::gen_prepare_fs_rom_start(Xml_generator &xml) void Sculpt::gen_prepare_bash_start(Xml_generator &xml) { - gen_common_start_content(xml, "bash", Cap_quota{400}, Ram_quota{15*1024*1024}); + gen_common_start_content(xml, "bash", + Cap_quota{400}, Ram_quota{15*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "/bin/bash", [&] () { }); @@ -152,7 +158,9 @@ void Sculpt::gen_prepare_start_content(Xml_generator &xml, Prepare_version versi { xml.attribute("version", version.value); - gen_common_start_content(xml, "prepare", Cap_quota{800}, Ram_quota{100*1024*1024}); + gen_common_start_content(xml, "prepare", + Cap_quota{800}, Ram_quota{100*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "init"); diff --git a/repos/gems/src/app/sculpt_manager/runtime/update.cc b/repos/gems/src/app/sculpt_manager/runtime/update.cc index 76f117a931..c5f582ba47 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/update.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/update.cc @@ -15,7 +15,9 @@ void Sculpt::gen_update_start_content(Xml_generator &xml) { - gen_common_start_content(xml, "update", Cap_quota{2000}, Ram_quota{64*1024*1024}); + gen_common_start_content(xml, "update", + Cap_quota{2000}, Ram_quota{64*1024*1024}, + Priority::STORAGE); gen_named_node(xml, "binary", "init"); diff --git a/repos/gems/src/app/sculpt_manager/runtime/wifi_drv.cc b/repos/gems/src/app/sculpt_manager/runtime/wifi_drv.cc index 1bd9c2e414..40e773a42d 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/wifi_drv.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/wifi_drv.cc @@ -15,7 +15,9 @@ void Sculpt::gen_wifi_drv_start_content(Xml_generator &xml) { - gen_common_start_content(xml, "wifi_drv", Cap_quota{200}, Ram_quota{32*1024*1024}); + gen_common_start_content(xml, "wifi_drv", + Cap_quota{200}, Ram_quota{32*1024*1024}, + Priority::NETWORK); xml.node("config", [&] () { diff --git a/repos/gems/src/app/sculpt_manager/types.h b/repos/gems/src/app/sculpt_manager/types.h index c1ecb46592..5fdb3b7883 100644 --- a/repos/gems/src/app/sculpt_manager/types.h +++ b/repos/gems/src/app/sculpt_manager/types.h @@ -47,6 +47,19 @@ namespace Sculpt { typedef Gui::Area Area; enum Writeable { WRITEABLE, READ_ONLY }; + + /* + * CPU priorities used within the runtime subsystem + */ + enum class Priority { + BACKGROUND = -3, + DEFAULT = -2, + NETWORK = DEFAULT, + STORAGE = DEFAULT, + MULTIMEDIA = -1, + DRIVER = 0, + LEITZENTRALE = 0 /* only for latency-critical drivers */ + }; } #endif /* _TYPES_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/xml.h b/repos/gems/src/app/sculpt_manager/xml.h index 04b9811449..7c3421269c 100644 --- a/repos/gems/src/app/sculpt_manager/xml.h +++ b/repos/gems/src/app/sculpt_manager/xml.h @@ -97,10 +97,12 @@ namespace Sculpt { static inline void gen_common_start_content(Xml_generator &xml, Rom_name const &name, Cap_quota const caps, - Ram_quota const ram) + Ram_quota const ram, + Priority const priority) { xml.attribute("name", name); xml.attribute("caps", caps.value); + xml.attribute("priority", (int)priority); gen_named_node(xml, "resource", "RAM", [&] () { xml.attribute("quantum", String<64>(Number_of_bytes(ram.value))); }); }