Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion smoketest/scripts/cli/test_vpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,9 @@ def test_10_vpp_driver_options(self):
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])

Expand All @@ -998,9 +999,19 @@ def test_11_vpp_cpu_settings(self):

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',
Expand Down
18 changes: 16 additions & 2 deletions src/conf_mode/vpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,18 +383,32 @@ 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 '
f'(reduce to {available_workers} or less)'
)

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'])
Expand Down