> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RT 配置 — 基于 KVM 的 RT

## **实时内核配置**

### 内核命令行启动参数

内核命令行参数控制 CPU、中断、调度和电源管理在启动阶段（用户空间启动之前）的行为方式。它们是将 Linux 调优为确定性实时系统的主要手段。

| 参数 | 用途 | 示例 |
| - | - | - |
| `isolcpus` | 将所列 CPU 从通用调度器负载均衡中移除 | `isolcpus=2-7` |
| `irqaffinity` | 将硬件中断限制在特定 CPU 上 | `irqaffinity=0-1` |
| `rcu_nocbs` | 将 RCU 回调从指定 CPU 上移走 | `rcu_nocbs=2-7` |
| `rcupdate.rcu_expedited` | 加快 RCU 宽限期，降低延迟的不可预测性 | `rcupdate.rcu_expedited=1` |
| `cpuidle.off` | 禁用 CPU 空闲状态以实现确定性调度 | `cpuidle.off=1` |
| `nohz_full` | 消除所选 CPU 上的周期性调度器 tick | `nohz_full=2-7` |

**CPU 分区：**

```
CPU 0       → Housekeeping CPU   — handles interrupts, kernel tasks
CPU 1–3     → RT Isolated CPUs   — run deterministic workloads
```

典型的组合命令行：

```
isolcpus=1-3 nohz_full=1-3 rcu_nocbs=1-3 irqaffinity=0
```

***

### 通过 Yocto 构建应用参数

QLI 2.0 通过 Yocto 构建系统中的 `KERNEL_CMDLINE_EXTRA` 变量应用内核命令行参数。

**通用配置文件：**

```
<Workspace_Path>/meta-qcom/conf/machine/include/qcom-common.inc
```

可用的 RT 调优变量：

```bitbake theme={null}
QCOM_RT_CPU           ?= ""
QCOM_IRQAFF           ?= ""
QCOM_RCU_NOCBS        ?= ""
QCOM_RCU_EXPEDITED    ?= ""
QCOM_CPUIDLE_OFF      ?= ""
QCOM_NOHZ_FULL        ?= ""
```

选择 RT 内核时，这些变量会被自动组合并追加：

```bitbake theme={null}
KERNEL_CMDLINE_EXTRA:append = "${@bb.utils.contains_any('PREFERRED_PROVIDER_virtual/kernel',\
                              'linux-qcom-rt linux-qcom-next-rt', \
                              ' ${RT_KERNEL_CMDLINE}', '', d)}"
```

**机器专用覆盖** — 在 `meta-qcom/conf/machine/<machine>.conf` 中设置。IQ-9075 EVK 示例：

```bitbake theme={null}
# meta-qcom/conf/machine/iq-9075-evk.conf
QCOM_RT_CPU        = "2-7"
QCOM_IRQAFF        = "0-1"
QCOM_RCU_NOCBS     = "2-7"
QCOM_RCU_EXPEDITED = "1"
QCOM_CPUIDLE_OFF   = "1"
QCOM_NOHZ_FULL     = "2-7"
```

***

### 在运行时验证已应用的参数

```bash theme={null}
root@iq-9075-evk:~# cat /proc/cmdline
root=PARTLABEL=rootfs rw rootwait console=ttyMSM0,115200 qcom_scm.download_mode=1 \
isolcpus=2-7 irqaffinity=0-1 rcu_nocbs=2-7 rcupdate.rcu_expedited=1 cpuidle.off=1 nohz_full=2-7 efi=runtime
```

***

> [card] [构建 — 基于 KVM 的 RT](https://dragonwingdocs-staging.qualcomm.com/zh/Suites/Industrial-Edge-Suite/rt-with-kvm-build.md)
>
> RT + KVM 的 KAS 构建命令

> [card] [RT 基准测试 IQ9（KVM）](https://dragonwingdocs-staging.qualcomm.com/zh/Suites/Industrial-Edge-Suite/kvm-rt-benchmarks-iq9.md)
>
> IQ-9075 上 KVM 下的 Cyclictest 结果
