summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNataliia Solomko <natalirs1985@gmail.com>2025-02-12 16:52:14 +0200
committerNataliia Solomko <natalirs1985@gmail.com>2025-02-12 17:01:14 +0200
commit91db3ecddac289ccbf2cf7d9b43129599602ecea (patch)
tree20ed782a50881d30121e84771a7aece40bc97adc
parentaa244309c5ff0c436cd24476367d8bc5b61bbccf (diff)
downloadvyos-1x-91db3ecddac289ccbf2cf7d9b43129599602ecea.tar.gz
vyos-1x-91db3ecddac289ccbf2cf7d9b43129599602ecea.zip
T7072: VPP CPU skip-cores should be verified
-rwxr-xr-xsmoketest/scripts/cli/test_vpp.py13
-rwxr-xr-xsrc/conf_mode/vpp.py18
2 files changed, 28 insertions, 3 deletions
diff --git a/smoketest/scripts/cli/test_vpp.py b/smoketest/scripts/cli/test_vpp.py
index f504d2d95..03ee68beb 100755
--- a/smoketest/scripts/cli/test_vpp.py
+++ b/smoketest/scripts/cli/test_vpp.py
@@ -986,8 +986,9 @@ class TestVPP(VyOSUnitTestSHIM.TestCase):
self.assertIn(f'{option} {value}', config)
def test_11_vpp_cpu_settings(self):
- main_core = '0'
+ main_core = '2'
workers = '2'
+ skip_cores = '1'
self.cli_set(base_path + ['settings', 'cpu', 'workers', workers])
@@ -998,9 +999,19 @@ class TestVPP(VyOSUnitTestSHIM.TestCase):
self.cli_set(base_path + ['settings', 'cpu', 'main-core', main_core])
+ self.cli_set(base_path + ['settings', 'cpu', 'skip-cores', '99'])
+
+ # "cpu skip-cores" cannot be more than number of available CPUs - 1
+ # expect raise ConfigError
+ with self.assertRaises(ConfigSessionError):
+ self.cli_commit()
+
+ self.cli_set(base_path + ['settings', 'cpu', 'skip-cores', skip_cores])
+
self.cli_commit()
config_entries = (
+ f'skip-cores {skip_cores}',
f'main-core {main_core}',
f'workers {workers}',
'dev 0000:00:00.0',
diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py
index 421556d07..bbdffa524 100755
--- a/src/conf_mode/vpp.py
+++ b/src/conf_mode/vpp.py
@@ -383,11 +383,23 @@ def verify(config):
raise ConfigError('"cpu main-core" is required but not set!')
cpus = int(get_core_count())
+ skip_cores = 0
+
+ if 'skip_cores' in config['settings']['cpu']:
+ skip_cores = int(config['settings']['cpu']['skip_cores'])
+ # the number of skipped cores should not be more than all CPUs - 1 (for main core)
+ if skip_cores > cpus - 1:
+ raise ConfigError(
+ f'The system does not have enough available CPUs to skip '
+ f'(reduce "cpu skip-cores" to {cpus - 1} or less)'
+ )
+
if 'workers' in config['settings']['cpu']:
# number of worker threads must be not more than
- # available CPUs in the system - 2 (1 for main thread and at least 1 for system processes)
+ # available CPUs in the system - 1 for main thread - number of skipped cores
+ # or - 1 (at least) for system processes
workers = int(config['settings']['cpu']['workers'])
- available_workers = cpus - 2
+ available_workers = cpus - 1 - (skip_cores or 1)
if workers > available_workers:
raise ConfigError(
f'The system does not have enough CPUs for {workers} VPP workers '
@@ -395,6 +407,8 @@ def verify(config):
)
cpus_available = list(map(lambda el: el['cpu'], get_available_cpus()))
+ # available CPUs are all CPUs without first N skipped cores that will not be used
+ cpus_available = cpus_available[skip_cores:]
if 'main_core' in config['settings']['cpu']:
main_core = int(config['settings']['cpu']['main_core'])