内核的开发是在邮件列表来进行的,通过一个个patch来更新内核,patch既是代码又是文档。我以提交的两个内核bug修正patch为例,来具体说明一下这个过程。
先同步本地内核源码,确保最新代码上还能复现对应的问题。阅读Documentation/process/submitting-pathes.rst 。 代码规范需符合 coding-style.rst,Linux 的缩进使用的是TAB(8个空格)。
Commit message
尽量使用祈使语句,说明碰到了什么问题,处理措施是什么。
Subject: 对代码做了什么改变
如:“fix sparse/build warning” ,就不合适,不够准确。可以改成 “cast xx to __rcu pointer”,这个就明确地表明做了一个指针转换。
消息体里面主要是:说明问题,产生原因,解决方案 三段式的结构,不要带主语。
如:不要说“I check xxx, We test xxx”, 直接就是 check /test/fix/make/….. 。最后一般以“Introduce”语句作为结尾。例如:“Introduce a temporary value for "ima_rules" when iterating over the ruleset to avoid the deadlocks.”
最后面使用 Signed-off-by 来签名,表明这个patch的所有者。
The current IMA ruleset is identified by the variable "ima_rules"
that default to "&ima_default_rules". When loading a custom policy
for the first time, the variable is updated to "&ima_policy_rules"
instead. That update isn't RCU-safe, and deadlocks are possible.
Indeed, some functions like ima_match_policy() may loop indefinitely
when traversing "ima_default_rules" with list_for_each_entry_rcu().
When iterating over the default ruleset back to head, if the list
head is "ima_default_rules", and "ima_rules" have been updated to
"&ima_policy_rules", the loop condition (&entry->list != ima_rules)
stays always true, traversing won't terminate, causing a soft lockup
and RCU stalls.
Introduce a temporary value for "ima_rules" when iterating over
the ruleset to avoid the deadlocks.
Signed-off-by: your name <xxx@yyyy.com>
subject 里面还需要带上模块名,可以通过 gi