0/8 已展开

LLM 分析

+--------------------------------------------------------------+
| sched_ext Documentation Fixes (v1 -> v2)                     |
+--------------------------------------------------------------+
|  PATCH 0/2  cover letter |
|  PATCH 1/2  cgroup-v2.rst: cpu.max / cpu.max.burst / cpu.idle |
|  PATCH 2/2  sched-ext.rst: ops.exit() example field name |
+--------------------------------------------------------------+
| Reviewer: Tejun Heo                                           |
| Branch:   sched_ext/for-7.3-fixes                            |
+--------------------------------------------------------------+

sched_ext 文档修复:补齐 BPF 回调说明与示例字段名

系列概况

  • 标题: [PATCH 0/2] sched_ext: documentation fixes
  • 作者: Liang Luo luoliang@kylinos.cn
  • 版本: v1(2 patches)+ v2(仅 patch 1 重发)
  • 规模: 2 个文件,v1 +10/-4,v2 +11/-5
  • 修改文件:
    • Documentation/admin-guide/cgroup-v2.rst
    • Documentation/scheduler/sched-ext.rst
  • 代码统计: 0 行 C 代码改动,纯文档修订
  • Message-ID: 20260819031244.178638-1-luoliang@kylinos.cn(cover letter)
  • 完整性: 完整 — 作者投稿 → Tejun 评审 → v2 重发 → 两份均合入 sched_ext/for-7.3-fixes

补丁目的

两条独立的文档 bugfix:

  1. cgroup-v2.rst 覆盖面错位cpu.maxcpu.max.burstcpu.idle 三条仍声称仅影响 fair-class 调度器,但写入同样会经 cgroup_set_bandwidth / cgroup_set_idle 回调通知 BPF 调度器,需要对齐已有 cpu.weight 的写法。
  2. sched-ext.rst 示例字段不存在ops.exit() 示例读 ei->type,而 struct scx_exit_info 自引入起只有 ei->kind。按示例照抄的 BPF 程序会因 no member named 'type' 编译失败。

旧流程的问题

cgroup-v2.rst "CPU Interface Files" preamble
+------------------------------------+
| 1. fair-class scheduler |
| 2. BPF w/ cgroup_set_weight         |
| 3. SCHED_{FIFO,RR,DEADLINE} and |
|    BPF without cgroup_set_weight    |
+------------------------------------+
              |
              v
 applies ONLY to entries that mention cgroup_set_weight
 cpu.max / cpu.max.burst / cpu.idle entries drift out of cover
sched-ext.rst ops.exit() example (broken)
+-----------------------------------------+
| void BPF_STRUCT_OPS(simple_exit, ...)   |
| {                                       |
|     exit_type = ei->type;   // WRONG    |
| } |
+-----------------------------------------+
 |
   v error: no member named 'type' in struct scx_exit_info

新流程

cgroup-v2.rst v1 -> v2
+-----------------------------------------------------+
| preamble bullets generalize to "corresponding       |
| cgroup_set_* callback" so they keep covering        |
| every entry below                                   |
+-----------------------------------------------------+
 |
   v cpu.max        : add cgroup_set_bandwidth notice
  cpu.max.burst  : add cgroup_set_bandwidth notice
  cpu.idle       : add cgroup_set_idle    notice
sched-ext.rst ops.exit() example (fixed)
+-----------------------------------------+
| void BPF_STRUCT_OPS(simple_exit, ...)   |
| {                                       |
|     exit_type = ei->kind;   // CORRECT  |
| }                                       |
+-----------------------------------------+
 |
   v
  compiles against struct scx_exit_info in headers

Patch 概览

PATCH 0/2 cover letter: two doc fixes
PATCH 1/2   cgroup-v2.rst three entries + preamble
PATCH 2/2   sched-ext.rst   ops.exit() example

Review flow:
  PATCH 1/2 v1  -> Tejun: generalize preamble bullet -> author resends as PATCH v2
                  -> Tejun: Applied
  PATCH 2/2 v1  -> Tejun: Applied (single-line fix)

评审 / 合入时间线

+-----------+-----------+-----------------------------------+
| Date      | Author    | Action                            |
+-----------+-----------+-----------------------------------+
| 08-19 11  | Liang     | PATCH 0/2 + 1/2 + 2/2 sent |
| 08-19 10 | Tejun     | PATCH 2/2 applied |
| 08-19 10  | Tejun     | PATCH 1/2: ask to gen preamble    |
| 08-20 10  | Liang     | reply + announce v2               |
| 08-20 10  | Liang     | PATCH v2 sent |
| 08-21 09  | Tejun     | PATCH v2 applied                  |
+-----------+-----------+-----------------------------------+

关键实现

Patch 1/2(v1 → v2)

v1:
  + three entry bullets for cgroup_set_bandwidth / cgroup_set_idle

v2 (delta over v1):
  - "with the cgroup_set_weight callback"
  + "with the corresponding cgroup_set_* callback"
  - "without the cgroup_set_weight callback"
  + "without the corresponding cgroup_set_* callback"
  + Suggested-by: Tejun Heo <tj@kernel.org>

Patch 2/2

/* Documentation/scheduler/sched-ext.rst */
void BPF_STRUCT_OPS(simple_exit, struct scx_exit_info *ei)
{
/* hunk */
- exit_type = ei->type;
+       exit_type = ei->kind;
}
Fixes: fa48e8d2c7b5 ("sched_ext: Documentation: scheduler: Document extensible scheduler class")
1 file changed, 1 insertion(+), 1 deletion(-)

类比

Patch 2 像图书馆书架贴错书脊标签 —侧架上没有 "type" 这本书,真正的索引条是 "kind",照着标签找书的人只能空手而归。

Patch 1 像博物馆手册只写"本展区展示油画",却漏了隔壁展柜里也陈列着 BPF 调度器。

  • v1 像只补了三块展品牌(cpu.max / cpu.max.burst / cpu.idle),
  • v2 进一步把入口的总览导览牌也改正过来,让游客从入口就看到完整展品类别。

Highlight:风险与注意点

  • v2 的前言 bullet 泛化为"对应的 cgroup_set_* 回调"后,未来若 sched_ext 新增 cgroup_set_throttling / cgroup_set_latency 等回调,前言虽然不需要重写,但具体条目里仍需继续补一行新回调说明,否则信息会再次滞后。
  • sched-ext.rst 仅修正了 ei->type 一处示例;建议顺手核对文中其它回调示例(如 simple_init 之外的示例)所用字段名是否与头文件实际定义一一对应。
  • 用户照搬示例时若未先 struct scx_exit_info,编译器会先以"undeclared identifier"报错,而非直接指出 type 字段不存在;建议在示例上方多保留一句"参考头文件 struct scx_exit_info"。
  • 这两条改动语义轻,但都依赖 commit fa48e8d2c7b5 的结构定义,未来若 scx_exit_info 再重命名 kind,需要反向修该示例。

版本变化

v1 → v2(仅 patch 1):

  • 新增 preamble bullet 泛化:cgroup_set_weightcorresponding cgroup_set_* callback
  • 添加 Suggested-by: Tejun Heo <tj@kernel.org>
  • diffstat 增量:+11/-5(v1 是 +9/-3,多出的 2 行即 preamble 的两条 bullet)。

一句话总结

两份 sched_ext 文档修复:在 cgroup-v2.rstcpu.max / cpu.max.burst / cpu.idle 带上 BPF 调度器回调触点(v2 同步把类别前言泛化为"对应的 cgroup_set_* 回调"),并在 sched-ext.rstops.exit() 示例里把不存在的 ei->type 改成真实字段 ei->kind