diff options
| author | Nataliia Solomko <natalirs1985@gmail.com> | 2025-08-06 14:17:21 +0300 |
|---|---|---|
| committer | Nataliia Solomko <natalirs1985@gmail.com> | 2025-08-13 14:17:55 +0300 |
| commit | 4c47b5c170baa189d9a4983f050856a226b6553e (patch) | |
| tree | 9f3331162a370b6e13d169a941c6ca597275957f | |
| parent | 471441d9d6541401c5236399da0b7a56a7dd0ead (diff) | |
| download | vyos-1x-4c47b5c170baa189d9a4983f050856a226b6553e.tar.gz vyos-1x-4c47b5c170baa189d9a4983f050856a226b6553e.zip | |
T7678: Move "vpp settings host-resources" to "system option host-resources"
| -rw-r--r-- | interface-definitions/system_option.xml.in | 43 | ||||
| -rwxr-xr-x | src/conf_mode/system_option.py | 36 |
2 files changed, 79 insertions, 0 deletions
diff --git a/interface-definitions/system_option.xml.in b/interface-definitions/system_option.xml.in index 5d385e3d0..fad894153 100644 --- a/interface-definitions/system_option.xml.in +++ b/interface-definitions/system_option.xml.in @@ -32,6 +32,49 @@ <constraintErrorMessage>Must be ignore, reboot, or poweroff</constraintErrorMessage> </properties> </leafNode> + <node name="host-resources"> + <properties> + <help>Sysctl parameters for host resources</help> + </properties> + <children> + <leafNode name="max-map-count"> + <properties> + <help>Maximum number of memory map areas a process may have</help> + <valueHelp> + <format>u32:65530-2147483647</format> + <description>Areas count</description> + </valueHelp> + <valueHelp> + <format>auto</format> + <description>Auto calculate areas count based on number of hugepages</description> + </valueHelp> + <constraint> + <regex>(auto)</regex> + <validator name="numeric" argument="--range 65530-2147483647"/> + </constraint> + </properties> + <defaultValue>auto</defaultValue> + </leafNode> + <leafNode name="shmmax"> + <properties> + <help>Maximum shared memory segment size that can be created</help> + <valueHelp> + <format>u64:8589934592-18446744073709551615</format> + <description>Size in bytes</description> + </valueHelp> + <valueHelp> + <format>auto</format> + <description>Auto calculate shared memory based on number of hugepages</description> + </valueHelp> + <constraint> + <regex>(auto)</regex> + <validator name="numeric" argument="--range 8589934592-18446744073709551615"/> + </constraint> + </properties> + <defaultValue>auto</defaultValue> + </leafNode> + </children> + </node> <node name="kernel"> <properties> <help>Kernel boot parameters</help> diff --git a/src/conf_mode/system_option.py b/src/conf_mode/system_option.py index fbe7231df..92f644437 100755 --- a/src/conf_mode/system_option.py +++ b/src/conf_mode/system_option.py @@ -33,6 +33,7 @@ from vyos.utils.process import cmd from vyos.utils.process import is_systemd_service_running from vyos.utils.network import is_addr_assigned from vyos.utils.network import is_intf_addr_assigned +from vyos.utils.system import sysctl_write from vyos.configdep import set_dependents from vyos.configdep import call_dependents from vyos import ConfigError @@ -266,6 +267,41 @@ def apply(options): else: write_file(kernel_dynamic_debug, f'module {module} -p') + if 'host_resources' in options: + unit_map = {'M': 1 << 20, 'G': 1 << 30} + + total_pages = 0 + total_bytes = 0 + + hp_sizes = options.get('kernel', {}).get('memory', {}).get('hugepage_size', {}) + for size_str, hp_config in hp_sizes.items(): + pages = int(hp_config.get('hugepage_count', 0)) + total_pages += pages + total_bytes += pages * int(size_str[:-1]) * unit_map[size_str[-1]] + + # Minimum recommended system values + max_map_count_min = 65530 # ensures large workload compatibility + shmmax_min = 8589934592 # 8 GiB safe default for large allocations + + max_map_count_conf = options['host_resources'].get('max_map_count', 'auto') + shmmax_conf = options['host_resources'].get('shmmax', 'auto') + + parameters = { + 'vm.max_map_count': ( + max(total_pages * 2, max_map_count_min) + if max_map_count_conf == 'auto' + else int(max_map_count_conf) + ), + 'kernel.shmmax': ( + max(total_bytes, shmmax_min) + if shmmax_conf == 'auto' + else int(shmmax_conf) + ), + } + + for parameter, value in parameters.items(): + sysctl_write(parameter, value) + if __name__ == '__main__': try: |
