如何提交patch 到内核

本文介绍了如何将patch提交到Linux内核,包括遵循的代码规范、撰写commit message的要点、如何生成和发送patch,以及邮件订阅和稳定版本内核patch的提交规则。重点强调了patch的格式要求和沟通过程,如使用git工具、邮件客户端设置,以及与维护者的交互方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

内核的开发是在邮件列表来进行的,通过一个个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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值