Code review · what we borrowedCode review · 借鉴了什么

How Google and the kernel
review code — and how we build it in.
Google 和内核社区怎么审代码——
以及我们怎么把它内建进 skill。

To make AI-written kernel code review-grade, we studied two sources that set the bar: Google's engineering practices (the human review guide plus its 2025 AI review tooling) and the Linux kernel community's own process docs. This page maps what they require onto what linux-kernel-dev actually enforces. 要让 AI 写的内核代码达到能过 review 的水准,我们研究了两个定标准的来源:Google 的工程实践(人工 review 指南 + 它 2025 年的 AI review 工具),以及 Linux 内核社区自己的流程文档。这一页把它们的要求,对应到 linux-kernel-dev 实际强制了什么。

See the mapping看对照 See it run看它干活
01 · How Google reviews01 · Google 怎么审

Eight dimensions, plus AI doing the first pass.八个维度,外加 AI 先过一遍。

Google's open eng-practices guide says the point of review is that overall code health improves over time — "there is no perfect code, only better code." A reviewer covers eight things; in 2025 an AI does the mechanical first pass. Google 开源的 eng-practices 指南说,review 的目的是让代码整体健康度随时间变好——"没有完美代码,只有更好的代码"。reviewer 看八件事;2025 年起 AI 先做机械的第一遍。

The 8 review dimensions8 个审查维度

Design (the most important), functionality, complexity, tests, naming, comments, style, documentation. Reviewers balance progress against perfection — don't block a CL over tiny nits.设计(最重要)、功能、复杂度、测试、命名、注释、风格、文档。reviewer 平衡推进与完美——别为小毛病卡住一个 CL。

AI first pass (2025)AI 第一遍(2025)

Gemini Code Assist auto-reviews each PR (summary + bug/style flags); a 2025 "memory" feature accrues an evolving record of the team's standards from PR interactions. AutoCommenter enforces best practices for C/C++/Java/Go/Python.Gemini Code Assist 自动审每个 PR(摘要 + bug/风格标注);2025 年的"记忆"功能从 PR 互动里积累一份会演进的团队规范记录。AutoCommenter 为 C/C++/Java/Go/Python 执行最佳实践。

02 · What the kernel requires02 · 内核社区怎么要求

A toolchain of gates, and a 2025 rule for AI.一串工具闸门,外加一条 2025 年给 AI 的规矩。

The kernel community enforces quality with documented tools and process — not taste. Most relevant to us: a 2025 doc on AI assistants that lines up exactly with our own no-AI-signature rule. 内核社区靠有文档的工具和流程把质量卡住——不靠口味。和我们最相关的:2025 年一份讲 AI 助手的文档,跟我们"不加 AI 署名"的规则完全对上。

Style + static analysis风格 + 静态分析

checkpatch.pl for style; then sparse (types / endianness / __user), smatch (flow), coccinelle (semantic patches), clang-format. Each catches a different class — all have false positives.checkpatch.pl 查风格;再加 sparse(类型/大小端/__user)、smatch(流分析)、coccinelle(语义补丁)、clang-format。各抓一类,都有误报。

SPDX + Signed-off-bySPDX + Signed-off-by

Every source file starts with an SPDX license identifier; every patch carries a Signed-off-by certifying the DCO (git commit -s). All code must be GPL-2.0 compatible.每个源文件首行带 SPDX 许可标识;每个补丁带 Signed-off-by 认证 DCO(git commit -s)。所有代码必须与 GPL-2.0 兼容。

AI assistants (2025)AI 助手(2025)

The coding-assistants doc: an AI must not add Signed-off-by — only a human can certify the DCO. Disclose AI help with Assisted-by:; the human reviews all of it and takes full responsibility.coding-assistants 文档:AI 绝不Signed-off-by——只有人能认证 DCO。用 Assisted-by: 披露 AI 辅助;人类审查全部并负全责。

Small, single-purpose patches小而单一的补丁

One patch does one thing; a big change is split into a series, each independently reviewable, compilable, and bisect-safe.一个补丁只做一件事;大改动拆成一系列,每个能独立 review、独立编译、不破坏二分。

03 · Mapped onto the skill03 · 对应到 skill

Google's 8 dimensions → our 7-axis panel.Google 的 8 维 → 我们的 7 轴面板。

Each answer is scored by seven fresh-context critics; design, testing and complexity were added to match Google's core concerns. Kernel work adds one dimension Google doesn't need: safety, with a veto — a sleep-in-spinlock is not a nit. 每个答案由七个独立上下文的打分员评;为对齐 Google 最看重的几项,新增了 设计测试复杂度。内核活儿多一个 Google 不需要的维度:safety,带一票否决——持 spinlock 睡眠不是小毛病。

Google dimensionGoogle 维度 Our coverage我们怎么覆盖
Designkernel-design-critic — fits the subsystem framework, no reinvented wheels (new)—— 融入子系统框架、不重造轮子(新增)
Functionalitykernel-correctness-critic + fact_gate — claims grep-verified against a real tree—— 断言对真树 grep 核过
Complexitykernel-complexity-critic — could it be simpler, can a maintainer follow it (new)—— 能否更简单、维护者能否看懂(新增)
Testskernel-testing-critic + regression_test — KUnit/kselftest coverage, error-path tests, testability (new)—— KUnit/kselftest 覆盖、错误路径测试、可测性(新增)
Naming · Stylekernel-coding-style-critic + checkpatch_gate — coding-style.rst + kernel's own checkpatch.pl—— coding-style.rst + 内核自带 checkpatch.pl
Comments · Docskernel-completeness-critic — error handling, cleanup, the claims block—— 错误处理、清理路径、断言块
(kernel-only) Safety(内核独有)安全kernel-safety-critic — atomic-sleep / UAPI / hardware rules; an error here vetoes the answer—— 原子睡眠/UAPI/硬件规则;这一轴出 error 直接否决

Weights: correctness .28 · safety .22 · design .13 · testing .12 · complexity .09 · coding-style .08 · completeness .08. See the weighted bar on the capabilities page. 权重:correctness .28 · safety .22 · design .13 · testing .12 · complexity .09 · coding-style .08 · completeness .08。加权条见能力页

04 · The three we acted on04 · 落地的三条

What changed in the skill.skill 里改了什么。

Design, complexity, testing axes设计 / 复杂度 / 测试三轴

Google treats design, complexity and tests as core review concerns; we had no critic for them. Added three, taking the panel from 4 to 7 axes.Google 把设计、复杂度、测试都当 review 核心关注,我们之前没有对应打分员。补了三个,面板从 4 轴到 7 轴。

AI never signs offAI 绝不 sign-off

The kernel's rule became Forbidden Action #11: an AI/tool never adds Signed-off-by; disclose with Assisted-by:; the human signs and owns it.内核这条成了 Forbidden Action 第 11 条:AI/工具绝不加 Signed-off-by;用 Assisted-by: 披露;人类签名并负责。

Third: the submission workflow (patch-workflow.md) gained the static-analysis tools (sparse / smatch / coccinelle / clang-format), SPDX, and the DCO flow — so review-grade output is documented end to end, from checkpatch to sign-off. 第三条:提交流程(patch-workflow.md)补上了静态分析工具(sparse / smatch / coccinelle / clang-format)、SPDX、DCO 流程——从 checkpatch 到 sign-off,能过 review 的产物全程有文档。