Skip to content

Commit 0a63089

Browse files
authored
Merge pull request #1680 from zdc/vpp-current
VPP: Kernel Tuning and Cosmetic Fixes
2 parents 7bf883d + 7e02e4f commit 0a63089

File tree

4 files changed

+357
-46
lines changed

4 files changed

+357
-46
lines changed

docs/vpp/configuration/dataplane/cpu.rst

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:lastproofread: 2025-09-04
1+
:lastproofread: 2025-09-05
22

33
.. _vpp_config_dataplane_cpu:
44

@@ -12,18 +12,30 @@ VPP can utilize multiple CPU cores to enhance packet processing performance. Pro
1212

1313
There are several parameters that can be configured to optimize CPU usage for VPP.
1414

15+
.. important::
16+
17+
Please read carefully the system configuration settings page before making any changes to CPU settings: :doc:`system`.
18+
19+
If CPU settings are not configured, VPP will start a single main thread on core 1 (``main-core``), without any additional worker threads.
20+
1521
CPU Configuration Parameters
1622
============================
1723

18-
main-core
19-
^^^^^^^^^
24+
Mandatory settings
25+
------------------
2026

21-
The main core is responsible for handling control plane operations and managing worker threads. It should be set to a core that is not heavily utilized by other processes. If not set, VPP will automatically select a core `1`.
27+
``main-core``
28+
^^^^^^^^^^^^^
29+
30+
The main core is responsible for handling control plane operations, managing worker threads, and processing packets. It should be set to a core that is not heavily utilized by other processes. The option should be always set if you apply any other CPU settings.
2231

2332
.. cfgcmd:: set vpp settings cpu main-core <core-number>
2433

25-
corelist-workers
26-
^^^^^^^^^^^^^^^^
34+
Manual cores selection
35+
----------------------
36+
37+
``corelist-workers``
38+
^^^^^^^^^^^^^^^^^^^^
2739

2840
This parameter specifies the list of CPU cores that will be used as worker threads for packet processing.
2941

@@ -36,17 +48,17 @@ Automatic cores selection
3648

3749
There is a possibility to let VPP select CPU cores automatically. This can be done by configuring the following two parameters:
3850

39-
skip-cores
40-
^^^^^^^^^^
51+
``skip-cores``
52+
^^^^^^^^^^^^^^
4153

4254
This parameter allows you to specify number of first CPU cores that should be excluded from being used for main or worker threads. The main thread will be assigned to the first available core after the skipped ones, and worker threads will be assigned to subsequent cores.
4355

4456
.. cfgcmd:: set vpp settings cpu skip-cores <cores>
4557

4658
Exclude cores that are reserved for other critical system processes to ensure that VPP does not interfere with their operation.
4759

48-
workers
49-
^^^^^^^
60+
``workers``
61+
^^^^^^^^^^^
5062

5163
This parameter allows you to specify the number of worker threads that should be created. Each worker thread will be assigned to a separate CPU core after the skipped and main ones.
5264

docs/vpp/configuration/dataplane/lcp.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ Pay attention that disabling this option leads to loss of connectivity to destin
2626

2727
Other configuration section crucial for integration between VPP and Kernel is netlink settings. It allows to configure how VPP management listen to netlink events and how it processes them.
2828

29-
.. cfgcmd:: set vpp settings lcp batch-delay-ms <value>
29+
.. cfgcmd:: set vpp settings lcp netlink batch-delay-ms <value>
3030

3131
This parameter specifies the delay in milliseconds between processing batch netlink messages. If you expect to get frequent and intensive netlink events, you may need to decrease this value to ensure that VPP processes netlink events in a timely manner.
3232

33-
.. cfgcmd:: set vpp settings lcp batch-size <value>
33+
.. cfgcmd:: set vpp settings lcp netlink batch-size <value>
3434

3535
This parameter specifies the maximum number of netlink messages to process in a single batch. If you have a high volume of netlink events, increasing this value can improve throughput by allowing more messages to be processed at once. However, setting it too high may increase latency for individual messages.
3636

37-
.. cfgcmd:: set vpp settings lcp rx-buffer-size <value>
37+
.. cfgcmd:: set vpp settings lcp netlink rx-buffer-size <value>
3838

3939
This parameter specifies the size of the receive buffer for netlink messages. Increasing this value can help accommodate bursts of netlink messages, but setting it too high may lead to increased memory usage.
4040

docs/vpp/configuration/dataplane/system.rst

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,115 @@ Both settings are automatically calculated based on configured hugepages.
5252
Kernel Tuning
5353
=============
5454

55+
VPP performance greatly benefits from proper kernel tuning, especially CPU isolation and disabling unnecessary kernel features. These optimizations ensure dedicated CPU cores are available exclusively for VPP dataplane processing without interference from the kernel scheduler or other system processes.
56+
57+
.. warning::
58+
59+
Kernel tuning changes require a system reboot to take effect.
60+
61+
Improper CPU isolation can lead to system instability if essential system processes are starved of CPU resources.
62+
63+
CPU Isolation and Optimization
64+
-------------------------------
65+
66+
CPU isolation is crucial for VPP performance as it dedicates specific CPU cores exclusively to VPP dataplane processing. The isolated cores are removed from the kernel scheduler and will not run regular system processes.
67+
68+
**Disable NMI Watchdog**
69+
70+
The NMI (Non-Maskable Interrupt) watchdog can interfere with VPP performance by generating interrupts on isolated cores and is not compatible with nohz-full mode:
71+
72+
.. cfgcmd:: set system option kernel cpu disable-nmi-watchdog
73+
74+
Disables the NMI watchdog for detecting hard CPU lockups. This prevents unnecessary interrupts on VPP worker cores.
75+
76+
**CPU Core Isolation**
77+
78+
.. cfgcmd:: set system option kernel cpu isolate-cpus <cpu-range>
79+
80+
Isolates specified CPUs from the kernel scheduler. Isolated cores will not run regular system processes and are dedicated to applications like VPP.
81+
82+
The ``<cpu-range>`` can be:
83+
84+
* Single core: ``2``
85+
* Range: ``2-5``
86+
* Mixed: ``1,3-5,7``
87+
88+
..important::
89+
90+
Always reserve at least 1-2 cores for the operating system to ensure system stability. For example, on a 4-core system, isolate cores 2-3 for VPP and leave cores 0-1 for the OS.
91+
92+
Assign the first isolated core as the VPP main core and the remaining isolated cores as VPP worker cores. Ensure that VPP CPU assignments match the isolated CPU range.
93+
94+
**Adaptive-Tick Mode**
95+
96+
.. cfgcmd:: set system option kernel cpu nohz-full <cpu-range>
97+
98+
Enables adaptive-tick mode (NO_HZ_FULL) for specified CPUs. This causes the kernel to avoid sending scheduling-clock interrupts to CPUs that have only one runnable task, significantly reducing interrupt overhead for dedicated workloads like VPP.
99+
100+
Use the same CPU range as configured for ``isolate-cpus``.
101+
102+
**RCU Callback Offloading**
103+
104+
.. cfgcmd:: set system option kernel cpu rcu-no-cbs <cpu-range>
105+
106+
Offloads Read-Copy-Update (RCU) callback processing from specified CPUs. This ensures that RCU callbacks do not prevent the specified CPUs from entering dyntick-idle or adaptive-tick mode, which is essential for nohz-full functionality.
107+
108+
Use the same CPU range as configured for ``isolate-cpus``.
109+
110+
System Optimization
111+
--------------------
112+
113+
Additional kernel optimizations can further improve VPP performance by disabling unnecessary features and reducing system overhead.
114+
115+
**Disable High Precision Event Timer**
116+
117+
.. cfgcmd:: set system option kernel disable-hpet
118+
119+
Disables the High Precision Event Timer (HPET). HPET can cause additional interrupts and overhead that may impact VPP performance.
120+
121+
**Disable Machine Check Exceptions**
122+
123+
.. cfgcmd:: set system option kernel disable-mce
124+
125+
Disables Machine Check Exception (MCE) reporting and handling. While MCE provides hardware error detection, it can introduce latency in high-performance scenarios.
126+
127+
**Disable CPU Power Saving**
128+
129+
.. cfgcmd:: set system option kernel disable-power-saving
130+
131+
Disables CPU power saving mechanisms (C-states). This keeps CPU cores at maximum performance levels, eliminating latency from power state transitions.
132+
133+
**Disable Soft Lockup Detection**
134+
135+
.. cfgcmd:: set system option kernel disable-softlockup
136+
137+
Disables the soft lockup detector for kernel threads. This prevents false positives when VPP worker threads are busy processing packets.
138+
139+
**Disable CPU Mitigations**
140+
141+
.. cfgcmd:: set system option kernel disable-mitigations
142+
143+
Disables all optional CPU mitigations for security vulnerabilities (e.g., Spectre, Meltdown). This may improve performance on some platforms.
144+
145+
Optimal Configuration Example
146+
-----------------------------
147+
148+
For a system with 4 CPU cores (0-3) where cores 2-3 are dedicated to VPP:
149+
150+
.. code-block:: none
151+
152+
# Kernel CPU optimizations
153+
set system option kernel cpu disable-nmi-watchdog
154+
set system option kernel cpu isolate-cpus '2-3'
155+
set system option kernel cpu nohz-full '2-3'
156+
set system option kernel cpu rcu-no-cbs '2-3'
157+
158+
# System optimizations
159+
set system option kernel disable-hpet
160+
set system option kernel disable-mce
161+
set system option kernel disable-power-saving
162+
set system option kernel disable-softlockup
163+
164+
# VPP CPU assignment (matches isolated cores)
165+
set vpp settings cpu main-core '2'
166+
set vpp settings cpu corelist-workers '3'

0 commit comments

Comments
 (0)