summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNataliia S. <81954790+natali-rs1985@users.noreply.github.com>2025-07-08 16:44:42 +0200
committerGitHub <noreply@github.com>2025-07-08 15:44:42 +0100
commit5d0f6aad265f2fa10c7d822e1d135072a6feaf4f (patch)
tree6bfc2270009ab2ba8804d21bd877592468922bd7
parentfce4f84c69e3cb6e130fbe486154134bd62cd5f6 (diff)
downloadvyos-1x-5d0f6aad265f2fa10c7d822e1d135072a6feaf4f.tar.gz
vyos-1x-5d0f6aad265f2fa10c7d822e1d135072a6feaf4f.zip
T7607: Remove "set vpp settings host-resources nr_hugepages <N>" setting (#43)
-rw-r--r--interface-definitions/include/vpp_host_resources.xml.i13
-rw-r--r--python/vyos/vpp/config_resource_checks/memory.py21
-rw-r--r--python/vyos/vpp/config_verify.py12
-rwxr-xr-xsrc/conf_mode/vpp.py17
4 files changed, 35 insertions, 28 deletions
diff --git a/interface-definitions/include/vpp_host_resources.xml.i b/interface-definitions/include/vpp_host_resources.xml.i
index 109982bef..6fee0f2f3 100644
--- a/interface-definitions/include/vpp_host_resources.xml.i
+++ b/interface-definitions/include/vpp_host_resources.xml.i
@@ -4,19 +4,6 @@
<help>Host resources control</help>
</properties>
<children>
- <leafNode name="nr-hugepages">
- <properties>
- <help>Number of pre-allocated huge pages of the default size</help>
- <valueHelp>
- <format>u32:0-4294967295</format>
- <description>Pages count</description>
- </valueHelp>
- <constraint>
- <validator name="numeric" argument="--range 0-4294967295"/>
- </constraint>
- </properties>
- <defaultValue>2048</defaultValue>
- </leafNode>
<leafNode name="max-map-count">
<properties>
<help>Maximum number of memory map areas a process may have</help>
diff --git a/python/vyos/vpp/config_resource_checks/memory.py b/python/vyos/vpp/config_resource_checks/memory.py
index f5c7286bc..64fdf9abe 100644
--- a/python/vyos/vpp/config_resource_checks/memory.py
+++ b/python/vyos/vpp/config_resource_checks/memory.py
@@ -26,10 +26,10 @@ from vyos.vpp.utils import (
from vyos.vpp.config_resource_checks.resource_defaults import default_resource_map
-def get_total_hugepages_free_memory() -> int:
+def get_hugepages_info() -> dict:
"""
- Returns the total amount of hugepage-backed free memory (in bytes)
- as reported by /proc/meminfo
+ Returns the information about HugePages
+ retrieved from /proc/meminfo
"""
info = {}
with open('/proc/meminfo', 'r') as meminfo:
@@ -37,13 +37,28 @@ def get_total_hugepages_free_memory() -> int:
if line.startswith('Huge'):
key, value, *_ = line.strip().split()
info[key.rstrip(':')] = int(value)
+ return info
+
+def get_total_hugepages_free_memory() -> int:
+ """
+ Returns the total amount of hugepage-backed free memory (in bytes)
+ """
+ info = get_hugepages_info()
hugepages_free = info.get('HugePages_Free')
hugepage_size = info.get('Hugepagesize') * 1024
return hugepage_size * hugepages_free
+def get_hugepages_total() -> 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 cda5cf012..65dfac91a 100644
--- a/python/vyos/vpp/config_verify.py
+++ b/python/vyos/vpp/config_verify.py
@@ -389,3 +389,15 @@ 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_hugepages_total()
+
+ if max_map_count < 2 * hugepages:
+ raise ConfigError(
+ 'The max_map_count must be greater than or equal to (2 * HugePages_Total)'
+ )
diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py
index 757904dd5..9b9a3466b 100755
--- a/src/conf_mode/vpp.py
+++ b/src/conf_mode/vpp.py
@@ -49,6 +49,7 @@ 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
@@ -353,17 +354,8 @@ def verify(config):
# Check if available memory is enough for current VPP config
verify_vpp_memory(config)
- if 'host_resources' in config['settings']:
- if (
- 'nr_hugepages' in config['settings']['host_resources']
- and 'max_map_count' in config['settings']['host_resources']
- ):
- if int(config['settings']['host_resources']['max_map_count']) < 2 * int(
- config['settings']['host_resources']['nr_hugepages']
- ):
- raise ConfigError(
- 'The max_map_count must be greater than or equal to (2 * nr_hugepages)'
- )
+ 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'])
@@ -477,8 +469,9 @@ def generate(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 <count>'
sysctl_config: dict[str, str] = {
- 'vm.nr_hugepages': config['settings']['host_resources']['nr_hugepages'],
'vm.max_map_count': config['settings']['host_resources']['max_map_count'],
'vm.hugetlb_shm_group': '0',
'kernel.shmmax': config['settings']['host_resources']['shmmax'],