如何从 LKML 获取完整 patchset

背景

Linux 内核有一个金字塔的开发模型,所有的开发者都会把新的内核支持通过邮件发到某个内核子系统专属的邮件列表,经过反复的 Review 和修订以后,这些 patchset 最终会进入到 Maintainer 的内核仓库,这些 Maintainer 又会发起 Pull Request 申请,发起之后 Linux Next 的 Maintainer 会先 pull 进去,用于提前修复潜在的冲突等等,之后 Linus 会评估是否 Pull 到 master 分支。大体就是这样。

所以,很多新的内核贡献会先出现在邮件列表,经过一段时间的“孵化”之后,足够成熟了才能进入 Linus 的仓库,即 mainline。因此,要找最新的 Linux 内核技术,自然是去邮件列表那里取。

通常我们对内核新特性的需求是:

  • 了解到新特性对我们有用,如从国内翻译的https://zhuanlan.zhihu.com/p/451485944,和https://kernelnewbies.org/Linux_5.18,想学习或 back port.
  • 到 kernel.org 找相关代码(很多时候,patchset 没有标号 [1/8] 合入,分散在不同目录,难以完整获取)
  • 到 http://lore.kernel.org 找相关原始提交

但是呢,Linux 内核子系统很多,对应的邮件列表也特别多,比较分散;与此同时,邮件里头的代码跟 Review 的回复混杂在一起,比较凌乱。这导致要去查找和下载对应技术的代码是很不方便的。

社区为了解决上面的问题,早期有维护一个邮件列表的汇总页面,并提供了一个 http://patchwork.kernel.org 网站,用于自动监控大部分邮件列表,并从中分门别类地提取出 patchset。但是 patchwork 并不是包含整个内核的模块。

后来,又出来了一个 http://lore.kernel.org,这个的展示方式非常自然,差不多是一个“树形”的结构,可以逐级找到某个“子系统”的某个最新的 patchset,然后下载也很简单,不需要注册账号,直接用一个名叫 b4 的脚本,传递一个邮件的 message id 就可以下载对应的 patchset。

例子

用 kunit 作为例子。假如你想 back port 到旧版本内核。首先找到作者在 LMKL 的最后一个版本合入提交。已经修改了 V18 版本了:https://lore.kernel.org/all/20190923090249.127984-1-brendanhiggins@google.com/,找到 Message-ID。然后:

$ git clone git://git.kernel.org/pub/scm/utils/b4/b4.git
$ ./b4.sh am  20190923090249.127984-1-brendanhiggins@google.com

Looking up https://lore.kernel.org/r/20190923090249.127984-1-brendanhiggins%40google.com
Grabbing thread from lore.kernel.org/all/20190923090249.127984-1-brendanhiggins%40google.com/t.mbox.gz
Analyzing 47 messages in the thread
Checking attestation on all messages, may take a moment...
---
  [PATCH v18 1/19] kunit: test: add KUnit test runner core
  [PATCH v18 2/19] kunit: test: add test resource management API
  [PATCH v18 3/19] kunit: test: add string_stream a std::stream like string builder
  [PATCH v18 4/19] kunit: test: add assertion printing library
  [PATCH v18 5/19] kunit: test: add the concept of expectations
  [PATCH v18 6/19] lib: enable building KUnit in lib/
    + Reviewed-by: Stephen Boyd <sboyd@kernel.org>
  [PATCH v18 7/19] kunit: test: add initial tests
  [PATCH v18 8/19] objtool: add kunit_try_catch_throw to the noreturn list
  [PATCH v18 9/19] kunit: test: add support for test abort
  [PATCH v18 10/19] kunit: test: add tests for kunit test abort
  [PATCH v18 11/19] kunit: test: add the concept of assertions
  [PATCH v18 12/19] kunit: test: add tests for KUnit managed resources
  [PATCH v18 13/19] kunit: tool: add Python wrappers for running KUnit tests
  [PATCH v18 14/19] kunit: defconfig: add defconfigs for building KUnit tests
  [PATCH v18 15/19] Documentation: kunit: add documentation for KUnit
  [PATCH v18 16/19] MAINTAINERS: add entry for KUnit the unit testing framework
  [PATCH v18 17/19] kernel/sysctl-test: Add null pointer test for sysctl.c:proc_dointvec()
  [PATCH v18 18/19] MAINTAINERS: add proc sysctl KUnit test to PROC SYSCTL section
  [PATCH v18 19/19] kunit: fix failure to build without printk
  ---
  NOTE: install dkimpy for DKIM signature verification
---
Total patches: 19
---
Cover: ./v18_20190923_brendanhiggins_kunit_introduce_kunit_the_linux_kernel_unit_testing_framework.cover
 Link: https://lore.kernel.org/r/20190923090249.127984-1-brendanhiggins@google.com
 Base: not specified
       git am ./v18_20190923_brendanhiggins_kunit_introduce_kunit_the_linux_kernel_unit_testing_framework.mbx

接着直接 git am 打上 mbx 到你的代码里,解决冲突,编译,测试。

参考:
https://zhuanlan.zhihu.com/p/415617020
https://adam.younglogic.com/2022/10/apply-linux-kernel-patches-from-lkml/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值