Submitting My First Linux Kernel Patch
Linux 内核的 patch 是以纯文本的邮件形式进行提交和代码走查的,而且 patch 是先到内核子系统 maintainer 维护的 git tree, 再到 Linus Torvalds 的 main tree。本文主要是以一个 patch 提交的实例来记录一下整个过程中的一些具体操作要点,至于 kernel patch 提交的规范和操作细节内核文档 和各种博客文章有很多,这里不再赘述。
Linux 内核的 patch 是以纯文本的邮件形式进行提交和代码走查的,而且 patch 是先到内核子系统 maintainer 维护的 git tree, 再到 Linus Torvalds 的 main tree。本文主要是以一个 patch 提交的实例来记录一下整个过程中的一些具体操作要点,至于 kernel patch 提交的规范和操作细节内核文档 和各种博客文章有很多,这里不再赘述。
Vulkan ICD (Installable Client Driver) is a software component that enables the Vulkan API (Application Programming Interface) to interact with the hardware of a computer system. Vulkan is a low-level graphics API developed by the Khronos Group, which provides developers with more control over hardware resources, leading to improved performance and efficiency in graphics-intensive applications such as video games. The Vulkan ICD is responsible for managing the communication between the Vulkan API and the graphics hardware of a system. It is typically provided by the manufacturer of the graphics card as a driver for the system.
Light Display Manager 是一个轻量级的跨桌面环境的 Display Manager, 可以支持多种显示技术,如 X11, Mir, Wayland.
开发包依赖
构建工具依赖
安装
Lightdm 可执行程序路径 /usr/sbin/lightdm, 日志默认路径 /var/log/lightdm/lightdm.log. 所以构建时可以使用
--prefix 指定安装路径 (默认 /usr/local)--localstatedir 指定日志路径 (默认 $prefix/var/log/lightdm)--sysconfdir 指定 lightdm.conf 路径 (默认 $prefix/etc/lightdm)1 | ./autogen.sh --prefix=/usr --localstatedir=/var --sysconfdir=/etc --disable-tests |
flowchart TD
A["systemd"]
B["/usr/sbin/lightdm"]
C["`[Seat:*]
# Dump core
xserver-command=X -core`"]
D["`X
Symbolic link to Xorg`"]
A -- lightdm.service --> B -- /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf --> C --> D
P.S. lightdm --show-config 可以显示与 lightdm 相关的配置
《程序员的自我修养–链接,装载与库》这本书是在读研时才看的,印象很深,现在想想这本书讲的都是程序员,尤其是从事系统编程需要的知识。这里我将平时使用的跟编译,链接和构建应用程序及库相关的知识记录下来,希望以后能温故知新。
LLVM 是 Low-Level Virtual Machine 的简写,但事实上它与虚拟机关系不大。我们更熟悉它是一套工具链,包括 clang /'klæŋ/, lld, lldb 等等。接触 LLVM 是因为 Mesa llvmpipe 使用 LLVM, 还有 AMDGPU 和 Radeon 的编译器后端都使用 LLVM IR,所以要编译 Mesa 的 -Dgallium-drivers=llvmpipe,radeonsi 都依赖于 LLVM 的诸多组件, 构建 Linux 内核的 eBPF 程序也依赖 LLVM, 构建 perfetto 也依赖 LLVM。这里主要记录 LLVM 的构建和使用的一些问题。
POSIX Basic Regular Expression
POSIX Extended Regular Expression
| shorthand | equivalence |
|---|---|
\w |
[[:alnum:]_] |
\W |
[^[:alnum:]_] |
\s |
[[:space:]] |
\S |
[^[:space:]] |
| shorthand | matches |
|---|---|
\b |
position at a word boundary |
\B |
position not at a word boundary |
\< |
position at the start of a word |
\> |
position at the end of a word |
\` (backtick) |
position at the start of subject string |
\' (single quote) |
position at the end of subject string |
grep multiline mode-P: 使用 Perl 正则表达式扩展-z: 让 grep 把输入的行看成是一个多个行的集合,一个整体.*?: 后面的 ? 表示 .* 按 non-greedy 模式匹配,也就是尽可能少(短)的匹配(?s): 让 . 匹配包括 \n 在内的任意字符,也就是所谓的 dot all flag.rg multiline mode-U, --multiline 使能多行匹配,允许正则表达式里包含 \n (普通模式下不允许),但 -U 并不会改变 . 的语义,所以你仍然需要显式地给 . 指定 (?s) flag
rg -U 'struct file_operations .*? = ?\{(?s).*?\.mmap = (?s).*?\};' -tc drivers/gpummap file operation 方法的c文件| 语法 | 名称 | 含义 |
|---|---|---|
| (?=foo) | 正向先行断言 Positive Lookahead | 向前(右) 字符串里必须有 foo |
| (?!foo) | 负向先行断言 Negative Lookahead | 向前(右) 字符串里不能有 foo |
| (?<=foo) | 正向后行断言 Positive Lookbehind | 向后(左) 字符串里必须有 foo |
| (?<!foo) | 负向后行断言 Negative Lookbehind | 向后(左) 字符串里不能有 foo |
rg (ripgrep) 默认不支持 lookahead, lookbehind, 需要加 -P 或 --pcre2 选项