编辑
2024-01-15
记录知识
0

debian类系统的依赖问题

debian类系统通过apt和dpkg命令来安装系统软件包,但是通常会出现依赖问题,其主要原因来是dpkg这类命令太过细节和直接,对整体系统依赖关系的考量不够多,一旦出现问题只能依靠其他命令例如apt,aptitude来解决。这里介绍一下如何通过apt和aptitude来解决依赖问题。

制造依赖问题

为了制造出依赖的问题,通过dpkg可以强制卸载某个存在依赖关系的包。

dpkg -P --force-all xserver-xorg-core xserver-xorg-core是一个与系统显示强相关的软件包。它和系统许多应用强相关。在上述命令中,会强制卸载掉这个包。此时如果通过apt安装其他包的时候,就会因为依赖问题导致无法正常使用apt,如下:

root@kylin:~# apt install 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 您也许需要运行“apt --fix-broken install”来修正上面的错误。 下列软件包有未满足的依赖关系: xorgxrdp : 依赖: xorg-input-abi-24 依赖: xorg-video-abi-24 依赖: xserver-xorg-core (>= 2:1.18.99.901) 但是它还没有被安装 xserver-xorg : 依赖: xserver-xorg-core (>= 2:1.17.2-2) 但是它还没有被安装 xserver-xorg-input-libinput : 依赖: xorg-input-abi-24 依赖: xserver-xorg-core (>= 2:1.18.99.901) 但是它还没有被安装 E: 有未能满足的依赖关系。请尝试不指明软件包的名字来运行“apt --fix-broken install”(也可以指定一个解决办法)。

直接修复

当依赖问题出现时,最直接的办法就是按照提示修正错误。

apt --fix-broken install 通常是能够正常修复错误的(在系统源和网络正常的情况下),如下

root@kylin:~# apt --fix-broken install 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 正在修复依赖关系... 完成 将会同时安装下列软件: xserver-xorg-core 建议安装: xfonts-100dpi | xfonts-75dpi xfonts-scalable 下列【新】软件包将被安装: xserver-xorg-core 升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 546 个软件包未被升级。 需要下载 1,343 kB 的归档。 解压缩后会消耗 3,946 kB 的额外空间。 您希望继续执行吗? [Y/n]

寻找错误原因

如果需要追溯出来依赖产生原因,可以找找谁修改了dpkg列表
当某个包被破坏,其实意味着某人在不经意之间修改了dpkg的列表。查看dpkg的处理日志可以初步判断原因

root@kylin:~# grep "remove" /var/log/dpkg.log 2024-01-15 11:10:53 remove xserver-xorg-core:arm64 3:1.20.8-2rk7 <无>

找到原因是 2024-01-15 11:10:53 卸载了xserver-xorg-core 软件包导致依赖问题 那么接下来是找到3:1.20.4-1kord1版本的xorg即可

通过已有源找包

先从源里搜索

apt-cache show xserver-xorg-core | grep 3:1.20.8-2rk7

Version: 3:1.20.8-2rk7

这时候手动下载安装即可

apt download xserver-xorg-core=3:1.20.8-2rk7 dpkg -i xserver-xorg-core*.deb

试试aptitude修复

如果依赖问题一旦出现,可以第一步试试-f命令能否修复

apt install -f

如果不满足预期,可以使用aptitude工具,也可以修复

aptitude install

安装 下列软件包: 1) xserver-xorg-core [3:1.20.8-2rk7 (v101)] 是否接受该解决方案?[Y/n/q/?]

选择适合自己的方案即可

其他依赖问题

如果尝试上述方法无法解决,首先应该警觉起来,因为需要安装的包与当前系统和当前源存在不兼容的问题。你应该在心里做好即使安装好了,软件包仍会存在问题的最坏预期。如下分享一下判断手段

“E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系”

这种情况下,说明需要安装的包的依赖和系统要求的依赖存在版本之间的差异。 aptitude install pkgname 会找到最好的方案将系统的包进行升级和降级,从而适配需要安装的软件包。

如果aptitude无法解决这个问题,再去尝试修改需要安装包的依赖信息

dpkg -x pkgname.deb test (将pkgname.deb解包到test目录) cd test dpkg -e ../pkgname.deb (将pkgname.deb的control信息解开)

这里需要修改依赖描述文件的信息,使其符合系统当前要求
(注意:此操作仅修改依赖版本关系,保证安装包正常安装,不保证安装后运行正常)

vim DEBIAN/control

根据实际情况,修改包的依赖关系(降低包版本依赖要求,删除依赖信息,增加依赖信息)

Depends: xserver-common (>= 3:1.20.8-2rk7), keyboard-configuration, udev (>= 149), libegl1, libaudit1 (>= 1:2.2.1), libbsd0 (>= 0.7.0), libc6 (>= 2.29), libdbus-1-3 (>= 1.9.14), libdrm2 (>= 2.4.66), libepoxy0 (>= 1.5.4), libgcrypt20 (>= 1.8.0), libgl1, libpciaccess0 (>= 0.12.902), libpixman-1-0 (>= 0.30.0), librga2, libselinux1 (>= 2.0.82), libsystemd0, libudev1 (>= 183), libunwind8, libxau6, libxdmcp6, libxfont2 (>= 1:2.0.1), libxshmfence1

然后重新打包

cd .. && dpkg -b test/ pkgname.deb (重新打包)

不计后果的强制安装

在aptitude install无法正常解决依赖问题时,如果仅仅为了包的安装成功,通过强制命令可以将其安装成功,或许能够将其依赖问题解决。
(此操作可能损坏系统,执行操作的人需要为这样的操作承担后果)

dpkg -i --force-all pkgname.deb

安装之后,直接验证安装包内的程序是否正常使用。
如果安装之后,应用软件能够正常使用,可以修改包的安装信息,以匹配系统。如下所示:

vim /var/lib/dpkg/status (找到对应包的说明,修改成系统匹配的依赖状态)
vim /usr/share/doc/pkgname/changelog.gz(适当的修改changlog内容,用于明示此包是个人擅自修改过的)

如果安装成功后,应用软件不能正常使用或出现问题,请尝试从ld,patchelf等其他方式处理,通过安装包已无法正常处理。

下面将恢复软件包现状

dpkg -P pkgname.deb apt download pkgname.deb dpkg -i pkgname.deb apt install -f

与依赖相关的其他命令

apt-cache depends xserver-xorg-core # 查找安装包的正向依赖 apt-cache rdepends xserver-xorg-core # 查找安装包的反向依赖 apt-cache show xserver-xorg-core # 查看包的详细信息 apt-cache policy xserver-xorg-core # 查看包的优先级,以及哪个源提供的包 apt-cache showpkg xserver-xorg-core # 以更详细的方式查看包的依赖关系 echo "pkgname hold" | sudo dpkg --set-selections # 锁定某个包,让其他人无法升级和卸载 dpkg --get-selections | grep hold # 查看已经锁定的软件包 dpkg -S /usr/lib/xorg/Xorg # 查看文件输入哪个包 dpkg-deb -c pkgname.deb # 查看deb文件的内容 dpkg -i --force-overwrite B.deb # 强制覆盖某个安装包 apt install pkgname --download-only # 只想下载不想安装

锁定所有的包

#!/bin/bash dpkg --get-selections | awk -F ' ' '{print $1}' | while read name do echo $name echo "$name hold" | dpkg --set-selections done

提升某个包的优先级

vim /etc/apt/preferences.d/my.perf (优先级越高的源会首先安装) Package: pkgname Pin: origin "源地址" Pin-Priority: 1600

dpkg info被损坏 报错 “dpkg: unrecoverable fatal error, aborting: files list file for package 'xxxxxxx' is missing final newline”

mv /var/lib/dpkg/info/* /tmp/ dpkg --configure -a apt update apt-get install --reinstall linux-base apt install -f

警告 “dpkg: warning: files list file for package 'xxxxxxxx' missing; assuming package has no files currently installed”

for package in $(apt-get install -f 2>&1 |\ grep "warning: files list file for package '" |\ grep -Po "[^'\n ]+'" | grep -Po "[^']+"); do apt-get install --reinstall "$package"; done

总结

其实如果大家在安装包过程中存在问题,尝试apt和aptitude后仍无法解决,其实已经代表这个依赖很可能无法解决。换个思路,而不是一定要安装上这个包,或许能够解决你的问题。

参考链接

https://www.debian.org/doc/debian-policy/

编辑
2024-01-14
记录知识
0

从c程序来理解X86汇编

回顾x86汇编

简单的代码

#include <stdio.h> int main() { int a = 5; int b = a + 6; return 0; }

gcc -g -O0 simple.c -o simple gdb ./simple

(gdb) b main Breakpoint 1 at 0x1129: file simple.c, line 3. (gdb) r Starting program: /home/vivien/test/simple Breakpoint 1, main () at simple.c:3 3 { (gdb) n 2 5 int b = a + 6; (gdb) disass Dump of assembler code for function main: 0x0000555555555129 <+0>: endbr64 0x000055555555512d <+4>: push %rbp 0x000055555555512e <+5>: mov %rsp,%rbp 0x0000555555555131 <+8>: movl $0x5,-0x8(%rbp) => 0x0000555555555138 <+15>: mov -0x8(%rbp),%eax 0x000055555555513b <+18>: add $0x6,%eax 0x000055555555513e <+21>: mov %eax,-0x4(%rbp) 0x0000555555555141 <+24>: mov $0x0,%eax 0x0000555555555146 <+29>: pop %rbp 0x0000555555555147 <+30>: retq End of assembler dump.

这里disassemble命令默认以AT&T语法输出汇编指令 AT&T 语法中的指令格式为mnemonic source, destination 立即数为$符号,寄存器为%符号。 %eax是累加器,return的值也会放在这里 %ecx是计数器 %ebx是基地址寄存器 %edx是数据寄存器 %rbp是基指针,指向当前基址指针 %rsp是栈指针,指向当前堆栈指针

push %rbp mov %rsp,%rbp

这里将旧的基址指针压入栈保存备用,并将堆栈指针复制到基址指针上,这样%rbp指向main函数的栈帧底部。

movl $0x5,-0x8(%rbp) mov -0x8(%rbp),%eax add $0x6,%eax mov %eax,-0x4(%rbp)

这里将立即数5存储到 %rbp-8的局部变量中,再将%rbp-8移动到累加器中,然后对%eax自加6,然后将%eax的值存放在%rbp-4的局部变量

mov $0x0,%eax pop %rbp retq

这里将立即数0复制给%eax用作return的返回,并通过pop把旧的基指针从堆栈中取出并存回%rbp中。retq跳转回返回地址 在gdb中打印值来看看。

(gdb) x $rbp - 8 0x7fffffffe4f8: 0x00000005 (gdb) x &a 0x7fffffffe4f8: 0x00000005 (gdb) x &b 0x7fffffffe4fc: 0x0000000b (gdb) x $rbp - 4 0x7fffffffe4fc: 0x0000000b (gdb) x $rbp 0x7fffffffe500: 0x00000000

参考链接

https://www.recurse.com/blog/7-understanding-c-by-learning-assembly?utm_source=wechat_session&utm_medium=social&utm_oi=801824054439985152

编辑
2024-01-14
记录知识
0

Sar命令使用简介

Sar命令是一个分析系统性能的工具,这里简单介绍以下sar命令如何使用

sar -u 1

23时03分27秒 CPU %user %nice %system %iowait %steal %idle 23时03分28秒 all 2.76 0.00 2.01 0.00 0.00 95.23 %user 在用户模式下的百分比 %nice 如果通过renice调整了nice值,那么调整过的程序cpu占用的百分比 %system 在内核运行的百分比 %iowait 在io上阻塞时间的百分比,如果明显高,说明io压力很大 %steal 虚拟cpu等待实际cpu的时间百分比。说明虚拟机性能有问题 %idle 空闲的cpu百分比

sar -B 1

23时15分26秒 pgpgin/s pgpgout/s fault/s majflt/s pgfree/s pgscank/s pgscand/s pgsteal/s %vmeff 23时15分27秒 0.00 0.00 77.00 0.00 1126.00 0.00 0.00 0.00 0.00 pgpgin 页面换入计数 pgpgout 页面换出到磁盘的计数 fault 页面错误计数(major + minor) majflt major fault 的计数 pgfree 空闲链表的页面数 pgscank kswapd扫描的页数 pgscand 直接扫描的页数 pgsteal 扫描的页中每秒被回收的数 vmeff pgsteal / pgscan ,也就是回收效率,一直接近0%说明系统内存压力很大

sar -r 1

3时26分34秒 kbmemfree kbavail kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty 23时26分35秒 10114900 12329400 2527920 15.80 115168 2967592 9403528 55.63 1030508 4108996 124 kbmemfree 剩余内存,meminfo 的 MemFree kbavail 可用内存,meminfo的MemAvailable kbmemused 已用内存,free命令里面的used %memused 物理内存百分比 kbbuffers buffer使用,meminfo的Buffers kbcached cached使用,meminfo的Cached kbcommit 保证当前系统所需要的内存 %commit kbcommit/MemTotal kbactive 活跃内存数,meminfo的Active kbinact 非活跃内存数,meminfo的Inactive kbdirty 脏页数,meminfo的Dirty

sar -d 1

平均时间: DEV tps rkB/s wkB/s dkB/s areq-sz aqu-sz await %util 平均时间: dev7-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 tps 从物理磁盘读取IO的次数 rkB/s 读扇区的次数 wkB/s 写扇区的次数 dkB/s 丢弃IO的次数 areq-sz I/O 请求的平均大小 aqu-sz I/O请求的平均队列长度 await 每次请求IO的消耗时间,平均的 %util IO请求占用的cpu百分比

sar -b 1

17时36分27秒 tps rtps wtps dtps bread/s bwrtn/s bdscd/s 17时36分28秒 0.00 0.00 0.00 0.00 0.00 0.00 0.00 tps 从物理磁盘读取IO的总次数 rtps 读IO请求的次数 wtps 写IO请求的次数 dtps 丢弃IO请求的次数 bread/s 读取的数量 bwrtn/s 写入的数量 bdscd/s 丢弃的数量

sar -q 1

17时39分50秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked 17时39分51秒 0 697 0.10 0.18 0.10 0 runq-sz 等待运行队列长度 plist-sz 任务列表的任务数 ldavg-1 最近一分钟内的平均负载 ldavg-5 最近5分钟内的平均负载 ldavg-15 最近15分钟内的平均负载 blocked 因为IO原因在等待状态的任务数

sar -v 1

17时41分09秒 dentunusd file-nr inode-nr pty-nr 17时41分10秒 78017 10304 97509 2 dentunusd 目录缓存中的未使用的缓存数 file-nr 系统文件句柄使用数量 inode-nr 索引节点句柄的使用数量 pty-nr pty终端的使用数量

sar -w 1

17时41分39秒 proc/s cswch/s 17时41分40秒 0.00 431.00 proc/s 每秒创建的任务总数 cswch/s 每秒上下文切换的总数

sar -I 中断号 1

18时13分11秒 INTR intr/s 18时13分12秒 190 28.00 INTR 中断号 intr/s cpu对中断响应的时间

sar 电源统计

sar -m USB 1 总计: BUS idvendor idprod maxpower manufact product 总计: 3 24ae 4012 200 Rapoo V500RGB Gaming Keyboard BUS USB挂的总线号 idvendor USB的vendor ID idprod USB的product ID maxpower USB设置的最大电流值 manufact 制造商 product USB类型

sar -m CPU 1

18时26分54秒 CPU MHz 18时26分55秒 all 2223.78 CPU CPU号 MHz 频率

sar -m TEMP 1

平均时间: TEMP degC %temp DEVICE 平均时间: 1 29.00 29.00 coretemp-isa-0000 degC 当前摄氏度 %temp 相对设备温度,最大是temp_max

sar 网络监控

sar -n DEV 1

18时32分28秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil 18时32分29秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 IFACE 网卡接口 rxpck/s 接收包数量 txpck/s 发送包数量 rxkB/s 接收包数据 txkB/s 发送包数据 rxcmp/s 接收压缩包数量 txcmp/s 发送压缩包数量 rxmcst/s 接收多播包数量 %ifutil 网卡利用率

sar -n EDEV 1

平均时间: IFACE rxerr/s txerr/s coll/s rxdrop/s txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s 平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rxerr/s 接收到的损坏包 txerr/s 发送包的损坏数 coll/s 当发送数据包时候,每秒钟发生的冲撞(collisions)数,这个是在半双工模式下才有 rxdrop/s 因为网络缓冲区满,接收时丢弃的包数量 txdrop/s 因为网络缓冲区满,发送时丢弃的包数量 txcarr/s carrier-errors发生的次数 rxfram/s 接收包时发生帧对齐错误的次数 rxfifo/s 接收包发生缓冲区溢出的次数 txfifo/s 发送包发生缓冲区溢出的次数

sar -n ICMP 1

18时46分51秒 imsg/s omsg/s iech/s iechr/s oech/s oechr/s itm/s itmr/s otm/s otmr/s iadrmk/s iadrmkr/s oadrmk/s oadrmkr/s 18时46分52秒 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 imsg/s 接收到的ICMP包数量 icmpInMsgs omsg/s 发送的ICMP包数量 icmpOutMsgs iech/s icmpInEchos的数量 iechr/s icmpInEchoReps的消息数 oech/s icmpOutEchos消息数 oechr/s icmpOutEchoReps消息数 itm/s icmpInTimestamps的数量 itmr/s icmpInTimestampReps的数量 otm/s icmpInTimestampReps的数量 otmr/s icmpOutTimestampReps的数量 iadrmk/s ICMP 地址掩码请求消息的数量 iadrmkr/s ICMP 地址掩码回复消息的数量 oadrmk/s ICMP 地址掩码请求消息的数量 oadrmkr/s 发送的 ICMP 地址掩码回复消息的数量

sar -n IP 1

19时11分13秒 irec/s fwddgm/s idel/s orq/s asmrq/s asmok/s fragok/s fragcrt/s irec/s 接收到的报文数 fwddgm/s 转发的报文数 idel/s 成功发送的报文数 orq/s 向IP层提供的报文数 asmrq/s 接收的IP分片数 asmok/s 成功重组的IP报文数 fragok/s 成功分片的报文数 fragcrt/s 产生的分片数

sar -n SOCK 1

19时12分15秒 totsck tcpsck udpsck rawsck ip-frag tcp-tw totsck 被使用的socket数 tcpsck TCP的socket数 udpsck UDP的socket数 rawsck RAW的socket数 if-frag IP分片的数 tcp-tw 处于TIME-WAIT状态的连接数量

sar -n SOFT 1

19时12分38秒 CPU total/s dropd/s squeezd/s rx_rps/s flw_lim/s total/s 网络帧数 dropd/s 溢出丢弃的网络帧数 squeezd/s 软中断的次数 rx_rps/s 唤醒cpu的次数 flw_lim/s 达到流量限制的次数

sar -n TCP 1

19时14分45秒 active/s passive/s iseg/s oseg/s active/s:主动连接数 passive/s:被动连接数 iseg/s:每秒接收的段总数 oseg/s:每秒发送的段总数

sar -n ETCP 1

19时20分22秒 atmptf/s estres/s retrans/s isegerr/s orsts/s atmptf/s 重试失败数 estres/s 断开连接数 retrans/s 重传数 isegerr/s 错误数 orsts/s 包含RST flag的tcp段数

sar -n UDP 1

19时16分14秒 idgm/s odgm/s noport/s idgmerr/s idgm/s 每次接收的 UDP 数据报总数 odgm/s 每秒发送的 UDP 数据报总数 noport/s 接收到但是却没有应用程序在指定目的端口的数据个数 idgmerr/s 本机接收到但却无法派发的数据个数

七七八八总算整理完了sar命令的这些用法,但实际上工作中用不到这么多。或者sar的一些监控命令也可以通过其他命令实现。 不过需要留一个印象的是,如果想监控内存,缓存,CPU,IO,网络,中断这些通常需要监控的信息,可以尝试一下sar命令。

参考链接

https://www.man7.org/linux/man-pages/man1/sar.1.html

编辑
2024-01-11
记录知识
0

git提交建议

git commit一直没有一个规范,但是经常翻阅大型仓库例如linux kernel的都能感觉到commit是有一定规范的。为了让自己提交代码更合规点,这里整理了规范和一些注意事项(不一定正确哦),如下分享

我的模板

Module: SubModule: Brief description of the patch ################################################################################# # Reference: https://www.kernel.org/doc/html/v5.4/process/submitting-patches.html # Notice: # 1. Only one problem was solved. # 2. Full description and justification # 3. Only one problem per patch # # Example 1: # Module: SubModule: Brief description of the patch # # Example 2: # Module: SubModule: Brief description of the patch # # Detailed description (if desired) # # Example 3: # [PATCH] Foo: Fix these things # or # [PATCH v2] Foo: Fix these things better # or # [PATCH v3 0/2] comedi: Fix these things # [PATCH v3 1/2] comedi: Fix the first thing # [PATCH v3 2/2] comedi: Fix the second thing #################################################################################

上述是.gitmessage文件,这个文件需要在自己的目录~/.gitmessage
为了使得这个模板生效,可以git config --global commit.template ~/.gitmessage
这样,以后提交就可以按照这个模板了。

介绍内核补丁提交

vim设置

vim ~/.vimrc

filetype plugin indent on syntax on set title set tabstop=8 set softtabstop=8 set shiftwidth=8 set noexpandtab

命令如下
:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab
update-alternatives --config editor

mutt设置

apt install esmtp touch ~/.esmtprc chmod g-rwx ~/.esmtprc chmod o-rwx ~/.esmtprc vim ~/.esmtprc identity "tangfengweny@gmail.com" hostname smtp.gmail.com:587 username "tangfengweny@gmail.com" password "邮箱密码" starttls required set sendmail="/usr/bin/esmtp" set envelope_from=yes set from="tangfeng <tangfengweny@gmail.com>" set use_from=yes set edit_headers=yes

git设置

vim ~/.gitconfig [user] name = tangfeng email = tangfengweny@example.com

更新内核

git fetch origin git rebase origin/yourbranch

checkpatch

apt-get install codespell python-ply python-git vim .git/hooks/post-commit #!/bin/sh exec git show --format=email HEAD | ./scripts/checkpatch.pl --strict --codespell chmod a+x .git/hooks/post-commit

这样提交时就默认检查补丁规范了./scripts/checkpatch.pl --strict --codespell

提交

确保提交的commit信息用 git log --oneline 能够清晰了解补丁内容

发送

了解对应提交的maintainer
git show HEAD | perl scripts/get_maintainer.pl --separator , -- nokeywords --nogit --nogit-fallback --norolestats 如果是特定文件 perl scripts/get_maintainer.pl --separator , --nokeywords --nogit -- nogit-fallback --norolestats -f drivers/staging/vt6655/baseband.c
不要直接把补丁发送到邮件列表,要先制作一封特殊的邮件。如下 git format-patch -o /tmp/ HEAD^ 先发给自己 mutt -H /tmp/0001-*.patch 也可以git发送

vim .gitconfig [sendemail] smtpserver = /usr/bin/esmtp git send-email --annotate HEAD^

对补丁进行版本控制

git format-patch --subject-prefix="PATCH v2"
如果需要对补丁额外修改,应该在补丁下添加---,然后开始解释,git工具会忽略---下面的内容 然后在补充内容后面加剪刀符>8-----8<这样文本会更加清晰 如下:

Signed-off-by: Your Name <my.email@gmail.com> --- Changes since v2: * Made commit message more clear * Corrected grammer in code comment * Used new API instead of depreciated API >8------------------------------------------------------8< drivers/staging/csr/bh.c

这里---下面的是补充的内容

制作补丁集

补丁集也就是对所有提交补丁的汇总,如下
git format-patch -n --subject-prefix="PATCH vY" --cover-letter
最后发送补丁集
git send-email --to <发给谁> --cc <addresses from get_maintainer.pl output> /tmp/*.patch
可以先--dry-run在本地实验后在发送
git send-email --to <发给谁> --cc <addresses from get_maintainer.pl output> -dry-run /tmp/*.patch

参考链接

https://kernelnewbies.org/FirstKernelPatch
https://kernelnewbies.org/PatchPhilosophy

编辑
2024-01-09
记录知识
0

了解/proc/vmstat

nr_free_pages 2596184 # 系统可用的页数 对应MemFree nr_zone_inactive_anon 489528 # 未活跃的页数 对应Inactive(anon) nr_zone_active_anon 599 # 对应Active(anon) nr_zone_inactive_file 516396 # 对应 Inactive(file) nr_zone_active_file 235058 # Active(file) nr_zone_unevictable 71526 # Unevictable nr_zone_write_pending 149 # dirty+writeback+unstable pages nr_mlock 8 # Mlocked nr_bounce 0 # Bounce nr_zspages 0 # allocated in zsmalloc nr_free_cma 0 # cma numa_hit 4634064 # allocated in intended node numa_miss 0 # allocated in non intended node numa_foreign 0 # was intended here, hit elsewhere numa_interleave 2880 # interleaver preferred this zone numa_local 4634064 # allocation from local node numa_other 0 # allocation from other node nr_inactive_anon 489528 # nr_zone_inactive_anon nr_active_anon 599 # nr_zone_active_anon nr_inactive_file 516396 # nr_zone_inactive_file nr_active_file 235058 # nr_zone_active_file nr_unevictable 71526 # nr_zone_unevictable nr_slab_reclaimable 32813 # SReclaimable nr_slab_unreclaimable 26640 # SUnreclaim nr_isolated_anon 0 # Temporary isolated pages from anon lru nr_isolated_file 0 # Temporary isolated pages from file lru workingset_nodes 0 workingset_refault_anon 0 workingset_refault_file 0 workingset_activate_anon 0 workingset_activate_file 0 workingset_restore_anon 0 workingset_restore_file 0 workingset_nodereclaim 0 nr_anon_pages 470838 # AnonPages nr_mapped 196874 # Mapped nr_file_pages 842283 # 文件缓存页 nr_dirty 149 # 脏页数 nr_writeback 0 # 回写页数 nr_writeback_temp 0 # WritebackTmp 文件系统的临时回写 nr_shmem 92614 # Shmem nr_shmem_hugepages 0 # ShmemHugePages nr_shmem_pmdmapped 0 # ShmemPmdMapped nr_file_hugepages 0 # FileHugePages nr_file_pmdmapped 0 # FilePmdMapped nr_anon_transparent_hugepages 0 # AnonHugePages nr_vmscan_write 0 # LRU内存回收写入页数 nr_vmscan_immediate_reclaim 0 # 优先回收的页数 nr_dirtied 515721 # page dirtyings since bootup nr_written 346168 # page dirtyings since bootup nr_kernel_misc_reclaimable 0 # reclaimable non-slab kernel pages nr_foll_pin_acquired 0 # via: pin_user_page(), gup flag: FOLL_PIN nr_foll_pin_released 0 # pages returned via unpin_user_page() nr_kernel_stack 12992 # KernelStack,kb单位 nr_page_table_pages 6858 # PageTables nr_swapcached 0 # swap cached nr_dirty_threshold 660577 # 脏页触发系统回写的阈值 nr_dirty_background_threshold 329885 # 脏页触发后台回写的阈值 pgpgin 2541198 # 从启动到现在读入的内存页数 pgpgout 1421761 # 从启动到现在换出的内存页数 pswpin 0 # 从启动到现在读入的交换分区页数 pswpout 0 # 从启动到现在换出的交换分区页数 pgalloc_dma 512 # 从启动到现在DMA存储区分配的页数 pgalloc_dma32 513 # 从启动到现在DMA 32位的存储区分配的页数 pgalloc_normal 4756880 # 从启动到现在普通存储区分配的页数 pgalloc_movable 0 # 可移除内存区 allocstall_dma 0 allocstall_dma32 0 allocstall_normal 0 allocstall_movable 0 pgskip_dma 0 pgskip_dma32 0 pgskip_normal 0 pgskip_movable 0 pgfree 7356348 # 从启动到现在释放的页数 pgactivate 365485 # 从启动到现在激活的页数 pgdeactivate 0 # 从启动到现在去激活的页数 pglazyfree 2336 pgfault 2896643 # 从启动到现在二级页面错误数 pgmajfault 6079 # 从启动到现在一级页面错误数 pglazyfreed 0 pgrefill 0 pgreuse 429609 # 不太理解,这里解释https://lkml.kernel.org/lkml/CAHk-=wgchPHqevEZ1radW1vLHKGGSaq_SCVHKgxHmQt70OSSfg@mail.gmail.com/ pgsteal_kswapd 0 pgsteal_direct 0 pgscan_kswapd 0 pgscan_direct 0 pgscan_direct_throttle 0 pgscan_anon 0 pgscan_file 0 pgsteal_anon 0 pgsteal_file 0 zone_reclaim_failed 0 pginodesteal 0 slabs_scanned 0 kswapd_inodesteal 0 kswapd_low_wmark_hit_quickly 0 kswapd_high_wmark_hit_quickly 0 pageoutrun 0 pgrotated 2 # 从启动到现在轮换的页面数 drop_pagecache 0 drop_slab 0 oom_kill 0 numa_pte_updates 0 numa_huge_pte_updates 0 numa_hint_faults 0 numa_hint_faults_local 0 numa_pages_migrated 0 pgmigrate_success 0 pgmigrate_fail 0 thp_migration_success 0 thp_migration_fail 0 thp_migration_split 0 compact_migrate_scanned 0 compact_free_scanned 0 compact_isolated 0 compact_stall 0 compact_fail 0 compact_success 0 compact_daemon_wake 0 compact_daemon_migrate_scanned 0 compact_daemon_free_scanned 0 htlb_buddy_alloc_success 0 htlb_buddy_alloc_fail 0 unevictable_pgs_culled 538811 unevictable_pgs_scanned 423920 unevictable_pgs_rescued 424015 unevictable_pgs_mlocked 202 unevictable_pgs_munlocked 194 unevictable_pgs_cleared 0 unevictable_pgs_stranded 0 thp_fault_alloc 0 thp_fault_fallback 0 thp_fault_fallback_charge 0 thp_collapse_alloc 0 thp_collapse_alloc_failed 0 thp_file_alloc 0 thp_file_fallback 0 thp_file_fallback_charge 0 thp_file_mapped 0 thp_split_page 0 thp_split_page_failed 0 thp_deferred_split_page 0 thp_split_pmd 0 thp_split_pud 0 thp_zero_page_alloc 0 thp_zero_page_alloc_failed 0 thp_swpout 0 thp_swpout_fallback 0 balloon_inflate 0 balloon_deflate 0 balloon_migrate 0 swap_ra 0 swap_ra_hit 0 direct_map_level2_splits 113 direct_map_level3_splits 2 nr_unstable 0

可以发现vmstat里面包含了很多的内存名词和信息,这些都是平时完全不知道的,要把内存这款了解透,得慢慢接触这些代码,配置和慢慢实践。上面分析vmstat过程中,很多不知道的,就没有细究了。因为还没那个功底去细究