From 4c47b5c170baa189d9a4983f050856a226b6553e Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Wed, 6 Aug 2025 14:17:21 +0300 Subject: T7678: Move "vpp settings host-resources" to "system option host-resources" --- src/conf_mode/system_option.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src') 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: -- cgit v1.2.3 From ebb4b887f888ba71afd8c52d17520de4bcc53889 Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Tue, 12 Aug 2025 18:48:05 +0300 Subject: T7678: Remove host-resources from CLI It will be configured in section "system option host-resources" --- .../include/vpp_host_resources.xml.i | 35 ---------------------- interface-definitions/vpp.xml.in | 1 - python/vyos/vpp/config_resource_checks/memory.py | 8 ----- python/vyos/vpp/config_verify.py | 15 ---------- src/conf_mode/vpp.py | 26 ---------------- 5 files changed, 85 deletions(-) delete mode 100644 interface-definitions/include/vpp_host_resources.xml.i (limited to 'src') diff --git a/interface-definitions/include/vpp_host_resources.xml.i b/interface-definitions/include/vpp_host_resources.xml.i deleted file mode 100644 index 1706c8c87..000000000 --- a/interface-definitions/include/vpp_host_resources.xml.i +++ /dev/null @@ -1,35 +0,0 @@ - - - - Host resources control - - - - - Maximum number of memory map areas a process may have - - u32:65535-2147483647 - Areas count - - - - - - 65535 - - - - Maximum shared memory segment size that can be created - - u32:0-18446744073709551612 - Size in bytes - - - - - - 2147483648 - - - - diff --git a/interface-definitions/vpp.xml.in b/interface-definitions/vpp.xml.in index dff56a228..a0cd0be45 100644 --- a/interface-definitions/vpp.xml.in +++ b/interface-definitions/vpp.xml.in @@ -449,7 +449,6 @@ - #include Interface diff --git a/python/vyos/vpp/config_resource_checks/memory.py b/python/vyos/vpp/config_resource_checks/memory.py index bce2df2bb..66b9fd9a3 100644 --- a/python/vyos/vpp/config_resource_checks/memory.py +++ b/python/vyos/vpp/config_resource_checks/memory.py @@ -51,14 +51,6 @@ def get_total_hugepages_memory() -> int: return hugepage_size * hugepages_total -def get_total_hugepages_count() -> int: - """ - Returns the total count of hugepages - """ - info = get_hugepages_info() - return info.get('HugePages_Total') - - def get_numa_count(): """ Run `numactl --hardware` and parse the 'available:' line. diff --git a/python/vyos/vpp/config_verify.py b/python/vyos/vpp/config_verify.py index 1beb3141b..9c56c8b95 100644 --- a/python/vyos/vpp/config_verify.py +++ b/python/vyos/vpp/config_verify.py @@ -19,7 +19,6 @@ import psutil from vyos import ConfigError -from vyos.base import Warning from vyos.utils.cpu import get_core_count as total_core_count from vyos.vpp.control_host import get_eth_driver @@ -391,17 +390,3 @@ def verify_vpp_interfaces_dpdk_num_queues(qtype: str, num_queues: int, workers: f'The number of {qtype} queues cannot be greater than the number of configured VPP workers: ' f'workers: {workers}, queues: {num_queues}' ) - - -def verify_vpp_host_resources(config: dict): - max_map_count = int(config['settings']['host_resources']['max_map_count']) - - # Get HugePages total count - hugepages = mem_checks.get_total_hugepages_count() - - if max_map_count < 2 * hugepages: - Warning( - 'The max-map-count should be greater than or equal to (2 * HugePages_Total) ' - 'or VPP could work not properly. Please set up ' - f'"vpp settings host-resources max-map-count" to {2 * hugepages} or higher' - ) diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py index 6e02f9593..ace3c9f9f 100755 --- a/src/conf_mode/vpp.py +++ b/src/conf_mode/vpp.py @@ -35,7 +35,6 @@ from vyos.ifconfig import Section from vyos.template import render from vyos.utils.boot import boot_configuration_complete from vyos.utils.process import call -from vyos.utils.system import sysctl_read, sysctl_apply from vyos.vpp import VPPControl from vyos.vpp import control_host @@ -53,7 +52,6 @@ from vyos.vpp.config_verify import ( verify_vpp_memory, verify_vpp_statseg_size, verify_vpp_interfaces_dpdk_num_queues, - verify_vpp_host_resources, ) from vyos.vpp.config_filter import iface_filter_eth from vyos.vpp.utils import EthtoolGDrvinfo @@ -362,9 +360,6 @@ def verify(config): # Check if available memory is enough for current VPP config verify_vpp_memory(config) - if 'max_map_count' in config['settings'].get('host_resources', {}): - verify_vpp_host_resources(config) - if 'statseg' in config['settings']: verify_vpp_statseg_size(config['settings']) @@ -475,27 +470,6 @@ def generate(config): render(service_conf, 'vpp/startup.conf.j2', config['settings']) render(systemd_override, 'vpp/override.conf.j2', config) - # apply sysctl values - # default: https://github.com/FDio/vpp/blob/v23.10/src/vpp/conf/80-vpp.conf - # vm.nr_hugepages are now configured in section - # 'set system option kernel memory hugepage-size 2M hugepage-count ' - sysctl_config: dict[str, str] = { - 'vm.max_map_count': config['settings']['host_resources']['max_map_count'], - 'vm.hugetlb_shm_group': '0', - 'kernel.shmmax': config['settings']['host_resources']['shmmax'], - } - # we do not want to lower current values - for sysctl_key, sysctl_value in sysctl_config.items(): - # perform check only for quantitative params - if sysctl_key == 'vm.hugetlb_shm_group': - pass - current_value = sysctl_read(sysctl_key) - if int(current_value) > int(sysctl_value): - sysctl_config[sysctl_key] = current_value - - if not sysctl_apply(sysctl_config): - raise ConfigError('Cannot configure sysctl parameters for VPP') - return None -- cgit v1.2.3 From 5fa2ba9bae1f3f86ad9aa5c13eefa0aff49fd7f4 Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Tue, 19 Aug 2025 17:28:44 +0300 Subject: T7678: Change node name to resource-limits --- interface-definitions/system_option.xml.in | 4 ++-- smoketest/scripts/cli/test_vpp.py | 4 ++-- src/conf_mode/system_option.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/interface-definitions/system_option.xml.in b/interface-definitions/system_option.xml.in index fad894153..e6a2b0b65 100644 --- a/interface-definitions/system_option.xml.in +++ b/interface-definitions/system_option.xml.in @@ -32,9 +32,9 @@ Must be ignore, reboot, or poweroff - + - Sysctl parameters for host resources + Resource limits diff --git a/smoketest/scripts/cli/test_vpp.py b/smoketest/scripts/cli/test_vpp.py index cfb159e9a..b55db9e49 100755 --- a/smoketest/scripts/cli/test_vpp.py +++ b/smoketest/scripts/cli/test_vpp.py @@ -1418,10 +1418,10 @@ class TestVPP(VyOSUnitTestSHIM.TestCase): self.cli_delete(base_sflow) self.cli_commit() - def test_19_host_resources(self): + def test_19_resource_limits(self): max_map_count = '100000' shmmax = '55555555555555' - hr_path = ['system', 'option', 'host-resources'] + hr_path = ['system', 'option', 'resource-limits'] # Check if max-map-count has default auto calculated value # but not less than '65530' diff --git a/src/conf_mode/system_option.py b/src/conf_mode/system_option.py index 92f644437..303557412 100755 --- a/src/conf_mode/system_option.py +++ b/src/conf_mode/system_option.py @@ -267,7 +267,7 @@ def apply(options): else: write_file(kernel_dynamic_debug, f'module {module} -p') - if 'host_resources' in options: + if 'resource_limits' in options: unit_map = {'M': 1 << 20, 'G': 1 << 30} total_pages = 0 @@ -283,8 +283,8 @@ def apply(options): 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') + max_map_count_conf = options['resource_limits'].get('max_map_count', 'auto') + shmmax_conf = options['resource_limits'].get('shmmax', 'auto') parameters = { 'vm.max_map_count': ( -- cgit v1.2.3