1# Lightweight CPU Isolation 2 3 4## Basic Concepts 5 6Lightweight CPU isolation enables dynamic CPU isolation based on the system load and user configuration. The kernel migrates the tasks and interrupts from the isolated CPU to other CPUs for execution. The isolated CPU enters the idle state, which reduces the power consumption. In addition, user-mode configuration and query APIs are provided for better system optimization. 7 8 9## Configuration 10 11### Enabling Lightweight CPU Isolation 12Enable related configuration items and dependencies. 13 14To enable lightweight CPU isolation, you need to enable the corresponding configuration items and dependencies during kernel compilation. The related configuration items are as follows: 15 16``` 17CONFIG_CPU_ISOLATION_OPT=y 18CONFIG_SCHED_CORE_CTRL=y 19``` 20 21Enable the following dependencies: 22 23``` 24CONFIG_SMP=y 25CONFIG_SCHED_WALT=y 26``` 27## Available APIs 28 29APIs are provided to set the number of isolated CPU cores and record the current status. Configurations can be performed based on CPU clusters. These APIs are located in the first CPU device directory of each CPU cluster, for example, `/sys/devices/system/cpu/cpu0/core_ctl`. 30 31| Category| API | Description | 32| ---- | ------------ | ---------------------------------------- | 33| Control API| enable | Enables or disables the lightweight CPU isolation. The value **1** means enable, and **0** means disable. | 34| | min_cpus | Sets the minimum number of active (not isolated) CPUs. | 35| | max_cpus | Sets the maximum number of active (not isolated) CPUs. The maximum value is the number of CPUs in a CPU cluster.| 36| Status API| active_cpus | Obtains the number of active (not isolated) CPUs. | 37| | need_cpus | Obtains the number of CPUs to de-isolate. | 38| | global_state | Records the status of all CPU clusters in the system, including the CPU isolation status, online status, and load information.| 39