Linux Kernel

Linux Kernel

Kernel相关

Basics

说明

最近计划开始看下linux内核相关的内容,是一个相当大的挑战,但是人总要push自己一把,万一自己又行了呢,加油吧,少年!

下载内核源码

  • 直接去kernel.html下载即可
  • 这里需要注意,other resources里面的资源也可以看看,挺好的
  • 右下角的feed建议订阅一下,罗马不是一天建成的
  • 2.6版本下载
1
2
3
liuliancao@liuliancao:~/projects$ cd /tmp
liuliancao@liuliancao:/tmp$ wget https://mirrors.edge.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.27/linux-2.6.27.61.tar.gz
liuliancao@liuliancao:/tmp$ tar xf /tmp/linux-2.6.27.61.tar.gz -C ~/projects/

我建议可以通过git下载

1
➜  projects git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/

编译内核

配置内核选项,我的debian的编译config文件位于/boot/config-xxx

1
2
3
4
5
6
# 默认配置
make defconfig
# qt5 cofnig
make xconfig
# old to new
make oldconfig

copy config and make oldconfig

1
2
3
4
5
6
7
8
9
➜  linux git:(master) cp /boot/config-5.15.0-2-amd64 .config
➜  linux git:(master) make oldconfig
...省略
  Test freeing pages (TEST_FREE_PAGES) [N/m/y/?] n
  Test floating point operations in kernel space (TEST_FPU) [N/m/y/?] n
  Test clocksource watchdog in kernel space (TEST_CLOCKSOURCE_WATCHDOG) [N/m/y/?] n
#
# configuration written to .config
#

make

1
2
3
make -j16
# 装在本机module
sudo make modules_install

目录结构

打开了压缩包,发现如下目录结构

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  /home/liuliancao/projects/linux-5.12.4:
  总用量 718180
  drwxr-xr-x  24 liuliancao liuliancao      4096 5月  17 09:13 .
  drwxr-xr-x  27 liuliancao liuliancao      4096 5月  25 18:44 ..
  drwxr-xr-x  25 liuliancao liuliancao      4096 5月  17 08:59 arch
  drwxr-xr-x   3 liuliancao liuliancao      4096 5月  17 08:59 block
  drwxr-xr-x   2 liuliancao liuliancao      4096 5月  17 08:59 certs
  -rw-r--r--   1 liuliancao liuliancao     16757 5月  17 08:59 .clang-format
  -rw-r--r--   1 liuliancao liuliancao        59 5月  17 08:59 .cocciconfig
  -rw-r--r--   1 liuliancao liuliancao       496 5月  17 08:59 COPYING
  -rw-r--r--   1 liuliancao liuliancao    100629 5月  17 08:59 CREDITS
  drwxr-xr-x   4 liuliancao liuliancao      4096 5月  17 08:59 crypto
  -rw-r--r--   1 liuliancao liuliancao   1795037 5月  17 09:11 cscope.files
  -rw-r--r--   1 liuliancao liuliancao 732667274 5月  17 09:13 cscope.out
  drwxr-xr-x  81 liuliancao liuliancao      4096 5月  17 08:59 Documentation
  drwxr-xr-x 139 liuliancao liuliancao      4096 5月  17 08:59 drivers
  drwxr-xr-x  79 liuliancao liuliancao      4096 5月  17 08:59 fs
  -rw-r--r--   1 liuliancao liuliancao        71 5月  17 08:59 .get_maintainer.ignore
  -rw-r--r--   1 liuliancao liuliancao        62 5月  17 08:59 .gitattributes
  -rw-r--r--   1 liuliancao liuliancao      1910 5月  17 08:59 .gitignore
  drwxr-xr-x  29 liuliancao liuliancao      4096 5月  17 08:59 include
  drwxr-xr-x   2 liuliancao liuliancao      4096 5月  17 08:59 init
  drwxr-xr-x   2 liuliancao liuliancao      4096 5月  17 08:59 ipc
  -rw-r--r--   1 liuliancao liuliancao      1327 5月  17 08:59 Kbuild
  -rw-r--r--   1 liuliancao liuliancao       555 5月  17 08:59 Kconfig
  drwxr-xr-x  20 liuliancao liuliancao      4096 5月  17 08:59 kernel
  drwxr-xr-x  21 liuliancao liuliancao     12288 5月  17 08:59 lib
  drwxr-xr-x   6 liuliancao liuliancao      4096 5月  17 08:59 LICENSES
  -rw-r--r--   1 liuliancao liuliancao     19598 5月  17 08:59 .mailmap
  -rw-r--r--   1 liuliancao liuliancao    591724 5月  17 08:59 MAINTAINERS
  -rw-r--r--   1 liuliancao liuliancao     66265 5月  17 08:59 Makefile
  drwxr-xr-x   4 liuliancao liuliancao      4096 5月  17 08:59 mm
  drwxr-xr-x  71 liuliancao liuliancao      4096 5月  17 08:59 net
  -rw-r--r--   1 liuliancao liuliancao       727 5月  17 08:59 README
  drwxr-xr-x  33 liuliancao liuliancao      4096 5月  17 08:59 samples
  drwxr-xr-x  17 liuliancao liuliancao      4096 5月  17 08:59 scripts
  drwxr-xr-x  13 liuliancao liuliancao      4096 5月  17 08:59 security
  drwxr-xr-x  26 liuliancao liuliancao      4096 5月  17 08:59 sound
  drwxr-xr-x  37 liuliancao liuliancao      4096 5月  17 08:59 tools
  drwxr-xr-x   3 liuliancao liuliancao      4096 5月  17 08:59 usr
  drwxr-xr-x   4 liuliancao liuliancao      4096 5月  17 08:59 virt

可用看到我们的内核已经非常庞大,但是没事,我们只是了解,并不需要开发,先放松心态

目录结构对应哪些内容(这里参考)

arch: arch(architecture)架构的意思,这里放的是适配x86,arm等平台的代码
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  drwxr-xr-x  9 liuliancao liuliancao  4096 5月  17 08:59 alpha
  drwxr-xr-x 12 liuliancao liuliancao  4096 5月  17 08:59 arc
  drwxr-xr-x 87 liuliancao liuliancao  4096 5月  17 08:59 arm
  drwxr-xr-x 12 liuliancao liuliancao  4096 5月  17 08:59 arm64
  drwxr-xr-x 10 liuliancao liuliancao  4096 5月  17 08:59 csky
  -rw-r--r--  1 liuliancao liuliancao    52 5月  17 08:59 .gitignore
  drwxr-xr-x  8 liuliancao liuliancao  4096 5月  17 08:59 h8300
  drwxr-xr-x  7 liuliancao liuliancao  4096 5月  17 08:59 hexagon
  drwxr-xr-x 11 liuliancao liuliancao  4096 5月  17 08:59 ia64
  -rw-r--r--  1 liuliancao liuliancao 36417 5月  17 08:59 Kconfig
  drwxr-xr-x 25 liuliancao liuliancao  4096 5月  17 08:59 m68k
  drwxr-xr-x  9 liuliancao liuliancao  4096 5月  17 08:59 microblaze
  drwxr-xr-x 49 liuliancao liuliancao  4096 5月  17 08:59 mips
  drwxr-xr-x  9 liuliancao liuliancao  4096 5月  17 08:59 nds32
  drwxr-xr-x  9 liuliancao liuliancao  4096 5月  17 08:59 nios2
  drwxr-xr-x  8 liuliancao liuliancao  4096 5月  17 08:59 openrisc
  drwxr-xr-x  9 liuliancao liuliancao  4096 5月  17 08:59 parisc
  drwxr-xr-x 19 liuliancao liuliancao  4096 5月  17 08:59 powerpc
  drwxr-xr-x  9 liuliancao liuliancao  4096 5月  17 08:59 riscv
  drwxr-xr-x 16 liuliancao liuliancao  4096 5月  17 08:59 s390
  drwxr-xr-x 13 liuliancao liuliancao  4096 5月  17 08:59 sh
  drwxr-xr-x 14 liuliancao liuliancao  4096 5月  17 08:59 sparc
  drwxr-xr-x  8 liuliancao liuliancao  4096 5月  17 08:59 um
  drwxr-xr-x 26 liuliancao liuliancao  4096 5月  17 08:59 x86
  drwxr-xr-x 10 liuliancao liuliancao  4096 5月  17 08:59 xtensa
block: block(块设备),用于处理io请求和管理块设备

从/linux-5.12.4/Documentation/block/文档的index.rst里面可用看出来, 我们还看到了deadline bfq等调度算法 .. SPDX-License-Identifier: GPL-2.0

=== Block ===

.. toctree:: :maxdepth: 1

bfq-iosched biodoc biovecs blk-mq capability cmdline-partition data-integrity deadline-iosched inline-encryption ioprio kyber-iosched null_blk pr queue-sysfs request stat switching-sched writeback_cache_control

certs: 定义证书等信息确保模块被正确加载的
crypto: 加密, 里面定义了很多加密算法的实现
Documentation: 文档,里面定义了很多模块的说明文档
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
  /home/liuliancao/projects/linux-5.12.4/Documentation:
  总用量 552
  drwxr-xr-x 81 liuliancao liuliancao   4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao   4096 5月  17 09:13 ..
  drwxr-xr-x  6 liuliancao liuliancao   4096 5月  17 08:59 ABI
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 accounting
  drwxr-xr-x 21 liuliancao liuliancao   4096 5月  17 08:59 admin-guide
  drwxr-xr-x 14 liuliancao liuliancao   4096 5月  17 08:59 arm
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 arm64
  -rw-r--r--  1 liuliancao liuliancao   9661 5月  17 08:59 asm-annotations.rst
  -rw-r--r--  1 liuliancao liuliancao   1573 5月  17 08:59 atomic_bitops.txt
  -rw-r--r--  1 liuliancao liuliancao   7184 5月  17 08:59 atomic_t.txt
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 block
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 bpf
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 cdrom
  lrwxrwxrwx  1 liuliancao liuliancao     19 5月  17 08:59 Changes -> process/changes.rst
  -rw-r--r--  1 liuliancao liuliancao     48 5月  17 08:59 CodingStyle
  -rw-r--r--  1 liuliancao liuliancao  18332 5月  17 08:59 conf.py
  -rw-r--r--  1 liuliancao liuliancao    564 5月  17 08:59 COPYING-logo
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 core-api
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 cpu-freq
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 crypto
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 devicetree
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 dev-tools
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 doc-guide
  -rw-r--r--  1 liuliancao liuliancao    159 5月  17 08:59 docutils.conf
  -rw-r--r--  1 liuliancao liuliancao   2678 5月  17 08:59 dontdiff
  drwxr-xr-x 33 liuliancao liuliancao   4096 5月  17 08:59 driver-api
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 fault-injection
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 fb
  drwxr-xr-x 12 liuliancao liuliancao   4096 5月  17 08:59 features
  drwxr-xr-x  7 liuliancao liuliancao   4096 5月  17 08:59 filesystems
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 firmware_class
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 firmware-guide
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 fpga
  -rw-r--r--  1 liuliancao liuliancao     53 5月  17 08:59 .gitignore
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 gpu
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 hid
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 hwmon
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 i2c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 ia64
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 ide
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 iio
  -rw-r--r--  1 liuliancao liuliancao   4316 5月  17 08:59 index.rst
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 infiniband
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 input
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 isdn
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 kbuild
  -rw-r--r--  1 liuliancao liuliancao    789 5月  17 08:59 Kconfig
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 kernel-hacking
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 leds
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 litmus-tests
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 livepatch
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 locking
  -rw-r--r--  1 liuliancao liuliancao  16335 5月  17 08:59 logo.gif
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 m68k
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 maintainer
  -rw-r--r--  1 liuliancao liuliancao   5860 5月  17 08:59 Makefile
  -rw-r--r--  1 liuliancao liuliancao 112483 5月  17 08:59 memory-barriers.txt
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 mhi
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 mips
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 misc-devices
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 netlabel
  drwxr-xr-x  7 liuliancao liuliancao   4096 5月  17 08:59 networking
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 nios2
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 nvdimm
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 openrisc
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 parisc
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 PCI
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 pcmcia
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 power
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 powerpc
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 process
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 RCU
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 riscv
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 s390
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 scheduler
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 scsi
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 security
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 sh
  drwxr-xr-x  7 liuliancao liuliancao   4096 5月  17 08:59 sound
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 sparc
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 sphinx
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 sphinx-static
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 spi
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 staging
  -rw-r--r--  1 liuliancao liuliancao     54 5月  17 08:59 SubmittingPatches
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 target
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 timers
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 trace
  drwxr-xr-x  6 liuliancao liuliancao   4096 5月  17 08:59 translations
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 usb
  drwxr-xr-x  5 liuliancao liuliancao   4096 5月  17 08:59 userspace-api
  drwxr-xr-x  5 liuliancao liuliancao   4096 5月  17 08:59 virt
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 vm
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 w1
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 watchdog
  -rw-r--r--  1 liuliancao liuliancao  11679 5月  17 08:59 watch_queue.rst
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 x86
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 xtensa
drivers: 驱动, 里面写了很多硬件驱动的实现
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  /home/liuliancao/projects/linux-5.12.4/drivers:
  总用量 592
  drwxr-xr-x 139 liuliancao liuliancao  4096 5月  17 08:59 .
  drwxr-xr-x  24 liuliancao liuliancao  4096 5月  17 09:13 ..
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 accessibility
  drwxr-xr-x  10 liuliancao liuliancao  4096 5月  17 08:59 acpi
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 amba
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 android
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 ata
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 atm
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 auxdisplay
  drwxr-xr-x   6 liuliancao liuliancao  4096 5月  17 08:59 base
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 bcma
  drwxr-xr-x  11 liuliancao liuliancao  4096 5月  17 08:59 block
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 bluetooth
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 bus
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 cdrom
  drwxr-xr-x  10 liuliancao liuliancao  4096 5月  17 08:59 char
  drwxr-xr-x  48 liuliancao liuliancao  4096 5月  17 08:59 clk
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 clocksource
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 connector
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 counter
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 cpufreq
  drwxr-xr-x   3 liuliancao liuliancao  4096 5月  17 08:59 cpuidle
  drwxr-xr-x  25 liuliancao liuliancao  4096 5月  17 08:59 crypto
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 cxl
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 dax
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 dca
  drwxr-xr-x   3 liuliancao liuliancao  4096 5月  17 08:59 devfreq
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 dio
  drwxr-xr-x  19 liuliancao liuliancao  4096 5月  17 08:59 dma
  drwxr-xr-x   3 liuliancao liuliancao  4096 5月  17 08:59 dma-buf
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 edac
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 eisa
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 extcon
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 firewire
  drwxr-xr-x  12 liuliancao liuliancao  4096 5月  17 08:59 firmware
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 fpga
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 fsi
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 gnss
  drwxr-xr-x   2 liuliancao liuliancao 12288 5月  17 08:59 gpio
  drwxr-xr-x   7 liuliancao liuliancao  4096 5月  17 08:59 gpu
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 greybus
  drwxr-xr-x   6 liuliancao liuliancao  4096 5月  17 08:59 hid
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 hsi
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 hv
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 hwmon
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 hwspinlock
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 hwtracing
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 i2c
  drwxr-xr-x   3 liuliancao liuliancao  4096 5月  17 08:59 i3c
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 ide
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 idle
  drwxr-xr-x  28 liuliancao liuliancao  4096 5月  17 08:59 iio
  drwxr-xr-x   6 liuliancao liuliancao  4096 5月  17 08:59 infiniband
  drwxr-xr-x  11 liuliancao liuliancao  4096 5月  17 08:59 input
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 interconnect
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 iommu
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 ipack
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 irqchip
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 isdn
  -rw-r--r--   1 liuliancao liuliancao  3942 5月  17 08:59 Kconfig
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 leds
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 lightnvm
  drwxr-xr-x   3 liuliancao liuliancao  4096 5月  17 08:59 macintosh
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 mailbox
  -rw-r--r--   1 liuliancao liuliancao  5426 5月  17 08:59 Makefile
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 mcb
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 md
  drwxr-xr-x  19 liuliancao liuliancao  4096 5月  17 08:59 media
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 memory
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 memstick
  drwxr-xr-x   3 liuliancao liuliancao  4096 5月  17 08:59 message
  drwxr-xr-x   2 liuliancao liuliancao 12288 5月  17 08:59 mfd
  drwxr-xr-x  22 liuliancao liuliancao  4096 5月  17 08:59 misc
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 mmc
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 most
  drwxr-xr-x  12 liuliancao liuliancao  4096 5月  17 08:59 mtd
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 mux
  drwxr-xr-x  32 liuliancao liuliancao  4096 5月  17 08:59 net
  drwxr-xr-x  12 liuliancao liuliancao  4096 5月  17 08:59 nfc
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 ntb
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 nubus
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 nvdimm
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 nvme
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 nvmem
  drwxr-xr-x   3 liuliancao liuliancao  4096 5月  17 08:59 of
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 opp
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 parisc
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 parport
  drwxr-xr-x   7 liuliancao liuliancao  4096 5月  17 08:59 pci
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 pcmcia
  drwxr-xr-x   3 liuliancao liuliancao  4096 5月  17 08:59 perf
  drwxr-xr-x  25 liuliancao liuliancao  4096 5月  17 08:59 phy
  drwxr-xr-x  28 liuliancao liuliancao  4096 5月  17 08:59 pinctrl
  drwxr-xr-x   9 liuliancao liuliancao  4096 5月  17 08:59 platform
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 pnp
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 power
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 powercap
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 pps
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 ps3
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 ptp
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 pwm
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 rapidio
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 ras
  drwxr-xr-x   2 liuliancao liuliancao 12288 5月  17 08:59 regulator
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 remoteproc
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 reset
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 rpmsg
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 rtc
  drwxr-xr-x   9 liuliancao liuliancao  4096 5月  17 08:59 s390
  drwxr-xr-x   3 liuliancao liuliancao  4096 5月  17 08:59 sbus
  drwxr-xr-x  39 liuliancao liuliancao  4096 5月  17 08:59 scsi
  drwxr-xr-x   6 liuliancao liuliancao  4096 5月  17 08:59 sh
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 siox
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 slimbus
  drwxr-xr-x  27 liuliancao liuliancao  4096 5月  17 08:59 soc
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 soundwire
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 spi
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 spmi
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 ssb
  drwxr-xr-x  48 liuliancao liuliancao  4096 5月  17 08:59 staging
  drwxr-xr-x   6 liuliancao liuliancao  4096 5月  17 08:59 target
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 tc
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 tee
  drwxr-xr-x   9 liuliancao liuliancao  4096 5月  17 08:59 thermal
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 thunderbolt
  drwxr-xr-x   7 liuliancao liuliancao  4096 5月  17 08:59 tty
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 uio
  drwxr-xr-x  27 liuliancao liuliancao  4096 5月  17 08:59 usb
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 vdpa
  drwxr-xr-x   6 liuliancao liuliancao  4096 5月  17 08:59 vfio
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 vhost
  drwxr-xr-x   6 liuliancao liuliancao  4096 5月  17 08:59 video
  drwxr-xr-x   5 liuliancao liuliancao  4096 5月  17 08:59 virt
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 virtio
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 visorbus
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 vlynq
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 vme
  drwxr-xr-x   4 liuliancao liuliancao  4096 5月  17 08:59 w1
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 watchdog
  drwxr-xr-x   6 liuliancao liuliancao  4096 5月  17 08:59 xen
  drwxr-xr-x   2 liuliancao liuliancao  4096 5月  17 08:59 zorro
fs: filesystem,文件系统,里面定义了各种fs的实现
include: kernel headers, 要编译的kernel header供其他函数使用
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  /home/liuliancao/projects/linux-5.12.4/include:
  总用量 156
  drwxr-xr-x 29 liuliancao liuliancao  4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao  4096 5月  17 09:13 ..
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 acpi
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 asm-generic
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 clocksource
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 crypto
  drwxr-xr-x  5 liuliancao liuliancao  4096 5月  17 08:59 drm
  drwxr-xr-x 37 liuliancao liuliancao  4096 5月  17 08:59 dt-bindings
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 keys
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 kunit
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 kvm
  drwxr-xr-x 64 liuliancao liuliancao 40960 5月  17 08:59 linux
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 math-emu
  drwxr-xr-x  6 liuliancao liuliancao  4096 5月  17 08:59 media
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 memory
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 misc
  drwxr-xr-x 12 liuliancao liuliancao  4096 5月  17 08:59 net
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 pcmcia
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ras
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 rdma
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 scsi
  drwxr-xr-x 15 liuliancao liuliancao  4096 5月  17 08:59 soc
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 sound
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 target
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 trace
  drwxr-xr-x 12 liuliancao liuliancao  4096 5月  17 08:59 uapi
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 vdso
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 video
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 xen
init: initialization,启动,包含启动内核相关的代码
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
  /home/liuliancao/projects/linux-5.12.4/init:
  总用量 204
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao  4096 5月  17 09:13 ..
  -rw-r--r--  1 liuliancao liuliancao  8756 5月  17 08:59 calibrate.c
  -rw-r--r--  1 liuliancao liuliancao 15238 5月  17 08:59 do_mounts.c
  -rw-r--r--  1 liuliancao liuliancao   908 5月  17 08:59 do_mounts.h
  -rw-r--r--  1 liuliancao liuliancao  3476 5月  17 08:59 do_mounts_initrd.c
  -rw-r--r--  1 liuliancao liuliancao  7885 5月  17 08:59 do_mounts_rd.c
  -rw-r--r--  1 liuliancao liuliancao 15680 5月  17 08:59 initramfs.c
  -rw-r--r--  1 liuliancao liuliancao  6318 5月  17 08:59 init_task.c
  -rw-r--r--  1 liuliancao liuliancao 76156 5月  17 08:59 Kconfig
  -rw-r--r--  1 liuliancao liuliancao 38563 5月  17 08:59 main.c
  -rw-r--r--  1 liuliancao liuliancao  1182 5月  17 08:59 Makefile
  -rw-r--r--  1 liuliancao liuliancao   813 5月  17 08:59 noinitramfs.c
  -rw-r--r--  1 liuliancao liuliancao  1118 5月  17 08:59 version.c
ipc: inter-process-communication, 进程间通信,定义进程之间如何通信,比如信号和管道等
kernel: 内核子系统,比如cgroup, debug, irq, coredump等
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  /home/liuliancao/projects/linux-5.12.4/kernel:
  总用量 2516
  drwxr-xr-x 20 liuliancao liuliancao   4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao   4096 5月  17 09:13 ..
  -rw-r--r--  1 liuliancao liuliancao  15831 5月  17 08:59 acct.c
  -rw-r--r--  1 liuliancao liuliancao  10402 5月  17 08:59 async.c
  -rw-r--r--  1 liuliancao liuliancao  65047 5月  17 08:59 audit.c
  -rw-r--r--  1 liuliancao liuliancao  34881 5月  17 08:59 auditfilter.c
  -rw-r--r--  1 liuliancao liuliancao   5352 5月  17 08:59 audit_fsnotify.c
  -rw-r--r--  1 liuliancao liuliancao  10525 5月  17 08:59 audit.h
  -rw-r--r--  1 liuliancao liuliancao  73512 5月  17 08:59 auditsc.c
  -rw-r--r--  1 liuliancao liuliancao  26219 5月  17 08:59 audit_tree.c
  -rw-r--r--  1 liuliancao liuliancao  13996 5月  17 08:59 audit_watch.c
  -rw-r--r--  1 liuliancao liuliancao   1918 5月  17 08:59 backtracetest.c
  -rw-r--r--  1 liuliancao liuliancao    751 5月  17 08:59 bounds.c
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 bpf
  -rw-r--r--  1 liuliancao liuliancao  15122 5月  17 08:59 capability.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 cgroup
  -rw-r--r--  1 liuliancao liuliancao   7487 5月  17 08:59 compat.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 configs
  -rw-r--r--  1 liuliancao liuliancao   2054 5月  17 08:59 configs.c
  -rw-r--r--  1 liuliancao liuliancao   6560 5月  17 08:59 context_tracking.c
  -rw-r--r--  1 liuliancao liuliancao  62622 5月  17 08:59 cpu.c
  -rw-r--r--  1 liuliancao liuliancao   5495 5月  17 08:59 cpu_pm.c
  -rw-r--r--  1 liuliancao liuliancao  13127 5月  17 08:59 crash_core.c
  -rw-r--r--  1 liuliancao liuliancao   1163 5月  17 08:59 crash_dump.c
  -rw-r--r--  1 liuliancao liuliancao  23878 5月  17 08:59 cred.c
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 debug
  -rw-r--r--  1 liuliancao liuliancao   4805 5月  17 08:59 delayacct.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 dma
  -rw-r--r--  1 liuliancao liuliancao   3425 5月  17 08:59 dma.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 entry
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 events
  -rw-r--r--  1 liuliancao liuliancao   1094 5月  17 08:59 exec_domain.c
  -rw-r--r--  1 liuliancao liuliancao  44762 5月  17 08:59 exit.c
  -rw-r--r--  1 liuliancao liuliancao   4503 5月  17 08:59 extable.c
  -rw-r--r--  1 liuliancao liuliancao   7124 5月  17 08:59 fail_function.c
  -rw-r--r--  1 liuliancao liuliancao  77122 5月  17 08:59 fork.c
  -rw-r--r--  1 liuliancao liuliancao   4455 5月  17 08:59 freezer.c
  -rw-r--r--  1 liuliancao liuliancao 112147 5月  17 08:59 futex.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 gcov
  -rwxr-xr-x  1 liuliancao liuliancao   3239 5月  17 08:59 gen_kheaders.sh
  -rw-r--r--  1 liuliancao liuliancao     84 5月  17 08:59 .gitignore
  -rw-r--r--  1 liuliancao liuliancao   4897 5月  17 08:59 groups.c
  -rw-r--r--  1 liuliancao liuliancao   7659 5月  17 08:59 hung_task.c
  -rw-r--r--  1 liuliancao liuliancao   4801 5月  17 08:59 iomem.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 irq
  -rw-r--r--  1 liuliancao liuliancao   4914 5月  17 08:59 irq_work.c
  -rw-r--r--  1 liuliancao liuliancao  21664 5月  17 08:59 jump_label.c
  -rw-r--r--  1 liuliancao liuliancao  19216 5月  17 08:59 kallsyms.c
  -rw-r--r--  1 liuliancao liuliancao   5519 5月  17 08:59 kcmp.c
  -rw-r--r--  1 liuliancao liuliancao     92 5月  17 08:59 Kconfig.freezer
  -rw-r--r--  1 liuliancao liuliancao   1709 5月  17 08:59 Kconfig.hz
  -rw-r--r--  1 liuliancao liuliancao   5028 5月  17 08:59 Kconfig.locks
  -rw-r--r--  1 liuliancao liuliancao   3804 5月  17 08:59 Kconfig.preempt
  -rw-r--r--  1 liuliancao liuliancao  28409 5月  17 08:59 kcov.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 kcsan
  -rw-r--r--  1 liuliancao liuliancao   8157 5月  17 08:59 kexec.c
  -rw-r--r--  1 liuliancao liuliancao  31884 5月  17 08:59 kexec_core.c
  -rw-r--r--  1 liuliancao liuliancao  11691 5月  17 08:59 kexec_elf.c
  -rw-r--r--  1 liuliancao liuliancao  34206 5月  17 08:59 kexec_file.c
  -rw-r--r--  1 liuliancao liuliancao    924 5月  17 08:59 kexec_internal.h
  -rw-r--r--  1 liuliancao liuliancao   1636 5月  17 08:59 kheaders.c
  -rw-r--r--  1 liuliancao liuliancao   5120 5月  17 08:59 kmod.c
  -rw-r--r--  1 liuliancao liuliancao  69254 5月  17 08:59 kprobes.c
  -rw-r--r--  1 liuliancao liuliancao   6445 5月  17 08:59 ksysfs.c
  -rw-r--r--  1 liuliancao liuliancao  40070 5月  17 08:59 kthread.c
  -rw-r--r--  1 liuliancao liuliancao   7405 5月  17 08:59 latencytop.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 livepatch
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 locking
  -rw-r--r--  1 liuliancao liuliancao   5178 5月  17 08:59 Makefile
  -rw-r--r--  1 liuliancao liuliancao 121144 5月  17 08:59 module.c
  -rw-r--r--  1 liuliancao liuliancao    782 5月  17 08:59 module-internal.h
  -rw-r--r--  1 liuliancao liuliancao   1116 5月  17 08:59 module_signature.c
  -rw-r--r--  1 liuliancao liuliancao   1084 5月  17 08:59 module_signing.c
  -rw-r--r--  1 liuliancao liuliancao  16693 5月  17 08:59 notifier.c
  -rw-r--r--  1 liuliancao liuliancao  13076 5月  17 08:59 nsproxy.c
  -rw-r--r--  1 liuliancao liuliancao  28666 5月  17 08:59 padata.c
  -rw-r--r--  1 liuliancao liuliancao  18738 5月  17 08:59 panic.c
  -rw-r--r--  1 liuliancao liuliancao  23279 5月  17 08:59 params.c
  -rw-r--r--  1 liuliancao liuliancao  17397 5月  17 08:59 pid.c
  -rw-r--r--  1 liuliancao liuliancao  11504 5月  17 08:59 pid_namespace.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 power
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 printk
  -rw-r--r--  1 liuliancao liuliancao  15183 5月  17 08:59 profile.c
  -rw-r--r--  1 liuliancao liuliancao  37272 5月  17 08:59 ptrace.c
  -rw-r--r--  1 liuliancao liuliancao   3110 5月  17 08:59 range.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 rcu
  -rw-r--r--  1 liuliancao liuliancao  19375 5月  17 08:59 reboot.c
  -rw-r--r--  1 liuliancao liuliancao   1898 5月  17 08:59 regset.c
  -rw-r--r--  1 liuliancao liuliancao  30758 5月  17 08:59 relay.c
  -rw-r--r--  1 liuliancao liuliancao  49069 5月  17 08:59 resource.c
  -rw-r--r--  1 liuliancao liuliancao   4400 5月  17 08:59 resource_kunit.c
  -rw-r--r--  1 liuliancao liuliancao  10084 5月  17 08:59 rseq.c
  -rw-r--r--  1 liuliancao liuliancao  18499 5月  17 08:59 scftorture.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 sched
  -rw-r--r--  1 liuliancao liuliancao   2871 5月  17 08:59 scs.c
  -rw-r--r--  1 liuliancao liuliancao  63090 5月  17 08:59 seccomp.c
  -rw-r--r--  1 liuliancao liuliancao 122734 5月  17 08:59 signal.c
  -rw-r--r--  1 liuliancao liuliancao  12040 5月  17 08:59 smpboot.c
  -rw-r--r--  1 liuliancao liuliancao    640 5月  17 08:59 smpboot.h
  -rw-r--r--  1 liuliancao liuliancao  27610 5月  17 08:59 smp.c
  -rw-r--r--  1 liuliancao liuliancao  18426 5月  17 08:59 softirq.c
  -rw-r--r--  1 liuliancao liuliancao   3709 5月  17 08:59 stackleak.c
  -rw-r--r--  1 liuliancao liuliancao   9846 5月  17 08:59 stacktrace.c
  -rw-r--r--  1 liuliancao liuliancao  12655 5月  17 08:59 static_call.c
  -rw-r--r--  1 liuliancao liuliancao  18219 5月  17 08:59 stop_machine.c
  -rw-r--r--  1 liuliancao liuliancao  64576 5月  17 08:59 sys.c
  -rw-r--r--  1 liuliancao liuliancao  82444 5月  17 08:59 sysctl.c
  -rw-r--r--  1 liuliancao liuliancao  11014 5月  17 08:59 sysctl-test.c
  -rw-r--r--  1 liuliancao liuliancao  10251 5月  17 08:59 sys_ni.c
  -rw-r--r--  1 liuliancao liuliancao  15561 5月  17 08:59 taskstats.c
  -rw-r--r--  1 liuliancao liuliancao   4015 5月  17 08:59 task_work.c
  -rw-r--r--  1 liuliancao liuliancao   6057 5月  17 08:59 test_kprobes.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 time
  -rw-r--r--  1 liuliancao liuliancao  25887 5月  17 08:59 torture.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 trace
  -rw-r--r--  1 liuliancao liuliancao  16725 5月  17 08:59 tracepoint.c
  -rw-r--r--  1 liuliancao liuliancao   4840 5月  17 08:59 tsacct.c
  -rw-r--r--  1 liuliancao liuliancao   5740 5月  17 08:59 ucount.c
  -rw-r--r--  1 liuliancao liuliancao   5198 5月  17 08:59 uid16.c
  -rw-r--r--  1 liuliancao liuliancao    442 5月  17 08:59 uid16.h
  -rw-r--r--  1 liuliancao liuliancao  15387 5月  17 08:59 umh.c
  -rw-r--r--  1 liuliancao liuliancao   2315 5月  17 08:59 up.c
  -rw-r--r--  1 liuliancao liuliancao   5638 5月  17 08:59 user.c
  -rw-r--r--  1 liuliancao liuliancao   4453 5月  17 08:59 usermode_driver.c
  -rw-r--r--  1 liuliancao liuliancao  35765 5月  17 08:59 user_namespace.c
  -rw-r--r--  1 liuliancao liuliancao   1379 5月  17 08:59 user-return-notifier.c
  -rw-r--r--  1 liuliancao liuliancao   3855 5月  17 08:59 utsname.c
  -rw-r--r--  1 liuliancao liuliancao   3317 5月  17 08:59 utsname_sysctl.c
  -rw-r--r--  1 liuliancao liuliancao  20621 5月  17 08:59 watchdog.c
  -rw-r--r--  1 liuliancao liuliancao   7862 5月  17 08:59 watchdog_hld.c
  -rw-r--r--  1 liuliancao liuliancao  16746 5月  17 08:59 watch_queue.c
  -rw-r--r--  1 liuliancao liuliancao 170193 5月  17 08:59 workqueue.c
  -rw-r--r--  1 liuliancao liuliancao   2448 5月  17 08:59 workqueue_internal.h
libs: 内核经常用到的一些库,比如字符处理,加密,字体,计算等信息
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
  /home/liuliancao/projects/linux-5.12.4/lib:
  总用量 2964
  drwxr-xr-x 21 liuliancao liuliancao  12288 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao   4096 5月  17 09:13 ..
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 842
  -rw-r--r--  1 liuliancao liuliancao   2154 5月  17 08:59 argv_split.c
  -rw-r--r--  1 liuliancao liuliancao    541 5月  17 08:59 ashldi3.c
  -rw-r--r--  1 liuliancao liuliancao    565 5月  17 08:59 ashrdi3.c
  -rw-r--r--  1 liuliancao liuliancao  13510 5月  17 08:59 asn1_decoder.c
  -rw-r--r--  1 liuliancao liuliancao  53036 5月  17 08:59 assoc_array.c
  -rw-r--r--  1 liuliancao liuliancao   4570 5月  17 08:59 atomic64.c
  -rw-r--r--  1 liuliancao liuliancao   6587 5月  17 08:59 atomic64_test.c
  -rw-r--r--  1 liuliancao liuliancao   1817 5月  17 08:59 audit.c
  -rw-r--r--  1 liuliancao liuliancao    297 5月  17 08:59 bcd.c
  -rw-r--r--  1 liuliancao liuliancao  39265 5月  17 08:59 bch.c
  -rw-r--r--  1 liuliancao liuliancao   4514 5月  17 08:59 bitfield_kunit.c
  -rw-r--r--  1 liuliancao liuliancao  38966 5月  17 08:59 bitmap.c
  -rw-r--r--  1 liuliancao liuliancao   1971 5月  17 08:59 bitrev.c
  -rw-r--r--  1 liuliancao liuliancao  19421 5月  17 08:59 bootconfig.c
  -rw-r--r--  1 liuliancao liuliancao   1247 5月  17 08:59 bsearch.c
  -rw-r--r--  1 liuliancao liuliancao  19707 5月  17 08:59 btree.c
  -rw-r--r--  1 liuliancao liuliancao   1437 5月  17 08:59 bucket_locks.c
  -rw-r--r--  1 liuliancao liuliancao   5878 5月  17 08:59 bug.c
  -rw-r--r--  1 liuliancao liuliancao   3900 5月  17 08:59 buildid.c
  -rwxr-xr-x  1 liuliancao liuliancao   4646 5月  17 08:59 build_OID_registry
  -rw-r--r--  1 liuliancao liuliancao    676 5月  17 08:59 bust_spinlocks.c
  -rw-r--r--  1 liuliancao liuliancao    635 5月  17 08:59 check_signature.c
  -rw-r--r--  1 liuliancao liuliancao   4245 5月  17 08:59 checksum.c
  -rw-r--r--  1 liuliancao liuliancao   1186 5月  17 08:59 clz_ctz.c
  -rw-r--r--  1 liuliancao liuliancao    891 5月  17 08:59 clz_tab.c
  -rw-r--r--  1 liuliancao liuliancao   5949 5月  17 08:59 cmdline.c
  -rw-r--r--  1 liuliancao liuliancao   4322 5月  17 08:59 cmdline_kunit.c
  -rw-r--r--  1 liuliancao liuliancao    501 5月  17 08:59 cmpdi2.c
  -rw-r--r--  1 liuliancao liuliancao    832 5月  17 08:59 compat_audit.c
  -rw-r--r--  1 liuliancao liuliancao   7238 5月  17 08:59 cpumask.c
  -rw-r--r--  1 liuliancao liuliancao   7766 5月  17 08:59 cpu_rmap.c
  -rw-r--r--  1 liuliancao liuliancao   2753 5月  17 08:59 crc16.c
  -rw-r--r--  1 liuliancao liuliancao   9521 5月  17 08:59 crc32.c
  -rw-r--r--  1 liuliancao liuliancao   1619 5月  17 08:59 crc32defs.h
  -rw-r--r--  1 liuliancao liuliancao  38300 5月  17 08:59 crc32test.c
  -rw-r--r--  1 liuliancao liuliancao   1003 5月  17 08:59 crc4.c
  -rw-r--r--  1 liuliancao liuliancao   1800 5月  17 08:59 crc64.c
  -rw-r--r--  1 liuliancao liuliancao   2562 5月  17 08:59 crc7.c
  -rw-r--r--  1 liuliancao liuliancao   2472 5月  17 08:59 crc8.c
  -rw-r--r--  1 liuliancao liuliancao   5737 5月  17 08:59 crc-ccitt.c
  -rw-r--r--  1 liuliancao liuliancao   2805 5月  17 08:59 crc-itu-t.c
  -rw-r--r--  1 liuliancao liuliancao   3232 5月  17 08:59 crc-t10dif.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 crypto
  -rw-r--r--  1 liuliancao liuliancao   1426 5月  17 08:59 ctype.c
  -rw-r--r--  1 liuliancao liuliancao    777 5月  17 08:59 debug_info.c
  -rw-r--r--  1 liuliancao liuliancao   1275 5月  17 08:59 debug_locks.c
  -rw-r--r--  1 liuliancao liuliancao  36097 5月  17 08:59 debugobjects.c
  -rw-r--r--  1 liuliancao liuliancao   1256 5月  17 08:59 dec_and_lock.c
  -rw-r--r--  1 liuliancao liuliancao  24045 5月  17 08:59 decompress_bunzip2.c
  -rw-r--r--  1 liuliancao liuliancao   1869 5月  17 08:59 decompress.c
  -rw-r--r--  1 liuliancao liuliancao   4873 5月  17 08:59 decompress_inflate.c
  -rw-r--r--  1 liuliancao liuliancao   4115 5月  17 08:59 decompress_unlz4.c
  -rw-r--r--  1 liuliancao liuliancao  16209 5月  17 08:59 decompress_unlzma.c
  -rw-r--r--  1 liuliancao liuliancao   6565 5月  17 08:59 decompress_unlzo.c
  -rw-r--r--  1 liuliancao liuliancao  11194 5月  17 08:59 decompress_unxz.c
  -rw-r--r--  1 liuliancao liuliancao  10473 5月  17 08:59 decompress_unzstd.c
  -rw-r--r--  1 liuliancao liuliancao    687 5月  17 08:59 devmem_is_allowed.c
  -rw-r--r--  1 liuliancao liuliancao  12634 5月  17 08:59 devres.c
  -rw-r--r--  1 liuliancao liuliancao   5647 5月  17 08:59 digsig.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 dim
  -rw-r--r--  1 liuliancao liuliancao   3326 5月  17 08:59 dump_stack.c
  -rw-r--r--  1 liuliancao liuliancao  28562 5月  17 08:59 dynamic_debug.c
  -rw-r--r--  1 liuliancao liuliancao   4429 5月  17 08:59 dynamic_queue_limits.c
  -rw-r--r--  1 liuliancao liuliancao   3637 5月  17 08:59 earlycpio.c
  -rw-r--r--  1 liuliancao liuliancao   3738 5月  17 08:59 errname.c
  -rw-r--r--  1 liuliancao liuliancao   5592 5月  17 08:59 error-inject.c
  -rw-r--r--  1 liuliancao liuliancao   6781 5月  17 08:59 errseq.c
  -rw-r--r--  1 liuliancao liuliancao   2945 5月  17 08:59 extable.c
  -rw-r--r--  1 liuliancao liuliancao   5999 5月  17 08:59 fault-inject.c
  -rw-r--r--  1 liuliancao liuliancao    823 5月  17 08:59 fault-inject-usercopy.c
  -rw-r--r--  1 liuliancao liuliancao     79 5月  17 08:59 fdt_addresses.c
  -rw-r--r--  1 liuliancao liuliancao     69 5月  17 08:59 fdt.c
  -rw-r--r--  1 liuliancao liuliancao     80 5月  17 08:59 fdt_empty_tree.c
  -rw-r--r--  1 liuliancao liuliancao     72 5月  17 08:59 fdt_ro.c
  -rw-r--r--  1 liuliancao liuliancao     72 5月  17 08:59 fdt_rw.c
  -rw-r--r--  1 liuliancao liuliancao     78 5月  17 08:59 fdt_strerror.c
  -rw-r--r--  1 liuliancao liuliancao     72 5月  17 08:59 fdt_sw.c
  -rw-r--r--  1 liuliancao liuliancao     73 5月  17 08:59 fdt_wip.c
  -rw-r--r--  1 liuliancao liuliancao   3996 5月  17 08:59 find_bit_benchmark.c
  -rw-r--r--  1 liuliancao liuliancao   4655 5月  17 08:59 find_bit.c
  -rw-r--r--  1 liuliancao liuliancao   6981 5月  17 08:59 flex_proportions.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 fonts
  -rw-r--r--  1 liuliancao liuliancao  26838 5月  17 08:59 genalloc.c
  -rw-r--r--  1 liuliancao liuliancao   3406 5月  17 08:59 gen_crc32table.c
  -rw-r--r--  1 liuliancao liuliancao   1463 5月  17 08:59 gen_crc64table.c
  -rw-r--r--  1 liuliancao liuliancao   5457 5月  17 08:59 generic-radix-tree.c
  -rw-r--r--  1 liuliancao liuliancao    116 5月  17 08:59 .gitignore
  -rw-r--r--  1 liuliancao liuliancao   3627 5月  17 08:59 glob.c
  -rw-r--r--  1 liuliancao liuliancao   4306 5月  17 08:59 globtest.c
  -rw-r--r--  1 liuliancao liuliancao   7538 5月  17 08:59 hexdump.c
  -rw-r--r--  1 liuliancao liuliancao   1961 5月  17 08:59 hweight.c
  -rw-r--r--  1 liuliancao liuliancao  17946 5月  17 08:59 idr.c
  -rw-r--r--  1 liuliancao liuliancao  39585 5月  17 08:59 inflate.c
  -rw-r--r--  1 liuliancao liuliancao    540 5月  17 08:59 interval_tree.c
  -rw-r--r--  1 liuliancao liuliancao   3505 5月  17 08:59 interval_tree_test.c
  -rw-r--r--  1 liuliancao liuliancao   9365 5月  17 08:59 iomap.c
  -rw-r--r--  1 liuliancao liuliancao   2226 5月  17 08:59 iomap_copy.c
  -rw-r--r--  1 liuliancao liuliancao    755 5月  17 08:59 iommu-helper.c
  -rw-r--r--  1 liuliancao liuliancao  45355 5月  17 08:59 iov_iter.c
  -rw-r--r--  1 liuliancao liuliancao   5571 5月  17 08:59 irq_poll.c
  -rw-r--r--  1 liuliancao liuliancao    394 5月  17 08:59 irq_regs.c
  -rw-r--r--  1 liuliancao liuliancao   1202 5月  17 08:59 is_single_threaded.c
  -rw-r--r--  1 liuliancao liuliancao   1420 5月  17 08:59 kasprintf.c
  -rw-r--r--  1 liuliancao liuliancao  16040 5月  17 08:59 Kconfig
  -rw-r--r--  1 liuliancao liuliancao  84928 5月  17 08:59 Kconfig.debug
  -rw-r--r--  1 liuliancao liuliancao   6883 5月  17 08:59 Kconfig.kasan
  -rw-r--r--  1 liuliancao liuliancao   8927 5月  17 08:59 Kconfig.kcsan
  -rw-r--r--  1 liuliancao liuliancao   3100 5月  17 08:59 Kconfig.kfence
  -rw-r--r--  1 liuliancao liuliancao   5708 5月  17 08:59 Kconfig.kgdb
  -rw-r--r--  1 liuliancao liuliancao   6419 5月  17 08:59 Kconfig.ubsan
  -rw-r--r--  1 liuliancao liuliancao  12379 5月  17 08:59 kfifo.c
  -rw-r--r--  1 liuliancao liuliancao  10680 5月  17 08:59 klist.c
  -rw-r--r--  1 liuliancao liuliancao  28827 5月  17 08:59 kobject.c
  -rw-r--r--  1 liuliancao liuliancao  19296 5月  17 08:59 kobject_uevent.c
  -rw-r--r--  1 liuliancao liuliancao  10692 5月  17 08:59 kstrtox.c
  -rw-r--r--  1 liuliancao liuliancao    293 5月  17 08:59 kstrtox.h
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 kunit
  -rw-r--r--  1 liuliancao liuliancao   2020 5月  17 08:59 libcrc32c.c
  -rw-r--r--  1 liuliancao liuliancao   7401 5月  17 08:59 linear_ranges.c
  -rw-r--r--  1 liuliancao liuliancao   1861 5月  17 08:59 list_debug.c
  -rw-r--r--  1 liuliancao liuliancao   8566 5月  17 08:59 list_sort.c
  -rw-r--r--  1 liuliancao liuliancao  17800 5月  17 08:59 list-test.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 livepatch
  -rw-r--r--  1 liuliancao liuliancao   2602 5月  17 08:59 llist.c
  -rw-r--r--  1 liuliancao liuliancao  64284 5月  17 08:59 locking-selftest.c
  -rw-r--r--  1 liuliancao liuliancao    246 5月  17 08:59 locking-selftest-hardirq.h
  -rw-r--r--  1 liuliancao liuliancao    159 5月  17 08:59 locking-selftest-mutex.h
  -rw-r--r--  1 liuliancao liuliancao    197 5月  17 08:59 locking-selftest-rlock.h
  -rw-r--r--  1 liuliancao liuliancao     74 5月  17 08:59 locking-selftest-rlock-hardirq.h
  -rw-r--r--  1 liuliancao liuliancao     74 5月  17 08:59 locking-selftest-rlock-softirq.h
  -rw-r--r--  1 liuliancao liuliancao    202 5月  17 08:59 locking-selftest-rsem.h
  -rw-r--r--  1 liuliancao liuliancao    162 5月  17 08:59 locking-selftest-rtmutex.h
  -rw-r--r--  1 liuliancao liuliancao    246 5月  17 08:59 locking-selftest-softirq.h
  -rw-r--r--  1 liuliancao liuliancao    157 5月  17 08:59 locking-selftest-spin.h
  -rw-r--r--  1 liuliancao liuliancao     73 5月  17 08:59 locking-selftest-spin-hardirq.h
  -rw-r--r--  1 liuliancao liuliancao     73 5月  17 08:59 locking-selftest-spin-softirq.h
  -rw-r--r--  1 liuliancao liuliancao    197 5月  17 08:59 locking-selftest-wlock.h
  -rw-r--r--  1 liuliancao liuliancao     74 5月  17 08:59 locking-selftest-wlock-hardirq.h
  -rw-r--r--  1 liuliancao liuliancao     74 5月  17 08:59 locking-selftest-wlock-softirq.h
  -rw-r--r--  1 liuliancao liuliancao    202 5月  17 08:59 locking-selftest-wsem.h
  -rw-r--r--  1 liuliancao liuliancao   4609 5月  17 08:59 lockref.c
  -rw-r--r--  1 liuliancao liuliancao   8705 5月  17 08:59 logic_pio.c
  -rw-r--r--  1 liuliancao liuliancao  19267 5月  17 08:59 lru_cache.c
  -rw-r--r--  1 liuliancao liuliancao    559 5月  17 08:59 lshrdi3.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 lz4
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 lzo
  -rw-r--r--  1 liuliancao liuliancao  12080 5月  17 08:59 Makefile
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 math
  -rw-r--r--  1 liuliancao liuliancao    753 5月  17 08:59 memcat_p.c
  -rw-r--r--  1 liuliancao liuliancao   1157 5月  17 08:59 memory-notifier-error-inject.c
  -rw-r--r--  1 liuliancao liuliancao    429 5月  17 08:59 memregion.c
  -rw-r--r--  1 liuliancao liuliancao   1035 5月  17 08:59 memweight.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 mpi
  -rw-r--r--  1 liuliancao liuliancao   1709 5月  17 08:59 muldi3.c
  -rw-r--r--  1 liuliancao liuliancao   1586 5月  17 08:59 netdev-notifier-error-inject.c
  -rw-r--r--  1 liuliancao liuliancao    640 5月  17 08:59 net_utils.c
  -rw-r--r--  1 liuliancao liuliancao  27545 5月  17 08:59 nlattr.c
  -rw-r--r--  1 liuliancao liuliancao   3195 5月  17 08:59 nmi_backtrace.c
  -rw-r--r--  1 liuliancao liuliancao    653 5月  17 08:59 nodemask.c
  -rw-r--r--  1 liuliancao liuliancao   2566 5月  17 08:59 notifier-error-inject.c
  -rw-r--r--  1 liuliancao liuliancao    653 5月  17 08:59 notifier-error-inject.h
  -rw-r--r--  1 liuliancao liuliancao  28957 5月  17 08:59 objagg.c
  -rw-r--r--  1 liuliancao liuliancao   1346 5月  17 08:59 of-reconfig-notifier-error-inject.c
  -rw-r--r--  1 liuliancao liuliancao   3781 5月  17 08:59 oid_registry.c
  -rw-r--r--  1 liuliancao liuliancao   1395 5月  17 08:59 once.c
  -rw-r--r--  1 liuliancao liuliancao   6717 5月  17 08:59 packing.c
  -rw-r--r--  1 liuliancao liuliancao  10848 5月  17 08:59 parman.c
  -rw-r--r--  1 liuliancao liuliancao   8829 5月  17 08:59 parser.c
  -rw-r--r--  1 liuliancao liuliancao   4313 5月  17 08:59 pci_iomap.c
  -rw-r--r--  1 liuliancao liuliancao   6582 5月  17 08:59 percpu_counter.c
  -rw-r--r--  1 liuliancao liuliancao  15722 5月  17 08:59 percpu-refcount.c
  -rw-r--r--  1 liuliancao liuliancao   3300 5月  17 08:59 percpu_test.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 pldmfw
  -rw-r--r--  1 liuliancao liuliancao   6041 5月  17 08:59 plist.c
  -rw-r--r--  1 liuliancao liuliancao   1183 5月  17 08:59 pm-notifier-error-inject.c
  -rw-r--r--  1 liuliancao liuliancao  44110 5月  17 08:59 radix-tree.c
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 raid6
  -rw-r--r--  1 liuliancao liuliancao  18928 5月  17 08:59 random32.c
  -rw-r--r--  1 liuliancao liuliancao   1649 5月  17 08:59 ratelimit.c
  -rw-r--r--  1 liuliancao liuliancao  17485 5月  17 08:59 rbtree.c
  -rw-r--r--  1 liuliancao liuliancao   9586 5月  17 08:59 rbtree_test.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 reed_solomon
  -rw-r--r--  1 liuliancao liuliancao   4883 5月  17 08:59 refcount.c
  -rw-r--r--  1 liuliancao liuliancao  30227 5月  17 08:59 rhashtable.c
  -rw-r--r--  1 liuliancao liuliancao  16521 5月  17 08:59 sbitmap.c
  -rw-r--r--  1 liuliancao liuliancao  27973 5月  17 08:59 scatterlist.c
  -rw-r--r--  1 liuliancao liuliancao  10136 5月  17 08:59 seq_buf.c
  -rw-r--r--  1 liuliancao liuliancao   4318 5月  17 08:59 sg_pool.c
  -rw-r--r--  1 liuliancao liuliancao   5161 5月  17 08:59 sg_split.c
  -rw-r--r--  1 liuliancao liuliancao   6425 5月  17 08:59 sha1.c
  -rw-r--r--  1 liuliancao liuliancao   1078 5月  17 08:59 show_mem.c
  -rw-r--r--  1 liuliancao liuliancao  12219 5月  17 08:59 siphash.c
  -rw-r--r--  1 liuliancao liuliancao   1488 5月  17 08:59 smp_processor_id.c
  -rw-r--r--  1 liuliancao liuliancao   8645 5月  17 08:59 sort.c
  -rw-r--r--  1 liuliancao liuliancao  10300 5月  17 08:59 stackdepot.c
  -rw-r--r--  1 liuliancao liuliancao   1953 5月  17 08:59 stmp_device.c
  -rw-r--r--  1 liuliancao liuliancao  26300 5月  17 08:59 string.c
  -rw-r--r--  1 liuliancao liuliancao  14838 5月  17 08:59 string_helpers.c
  -rw-r--r--  1 liuliancao liuliancao   4025 5月  17 08:59 strncpy_from_user.c
  -rw-r--r--  1 liuliancao liuliancao   3429 5月  17 08:59 strnlen_user.c
  -rw-r--r--  1 liuliancao liuliancao   2723 5月  17 08:59 syscall.c
  -rw-r--r--  1 liuliancao liuliancao  17846 5月  17 08:59 test_bitmap.c
  -rw-r--r--  1 liuliancao liuliancao   2540 5月  17 08:59 test_bitops.c
  -rw-r--r--  1 liuliancao liuliancao   1814 5月  17 08:59 test_bits.c
  -rw-r--r--  1 liuliancao liuliancao   2585 5月  17 08:59 test_blackhole_dev.c
  -rw-r--r--  1 liuliancao liuliancao 164276 5月  17 08:59 test_bpf.c
  -rw-r--r--  1 liuliancao liuliancao    981 5月  17 08:59 test_debug_virtual.c
  -rw-r--r--  1 liuliancao liuliancao  28332 5月  17 08:59 test_firmware.c
  -rw-r--r--  1 liuliancao liuliancao   2052 5月  17 08:59 test_fpu.c
  -rw-r--r--  1 liuliancao liuliancao    995 5月  17 08:59 test_free_pages.c
  -rw-r--r--  1 liuliancao liuliancao   6475 5月  17 08:59 test_hash.c
  -rw-r--r--  1 liuliancao liuliancao   6437 5月  17 08:59 test_hexdump.c
  -rw-r--r--  1 liuliancao liuliancao  27231 5月  17 08:59 test_hmm.c
  -rw-r--r--  1 liuliancao liuliancao   2315 5月  17 08:59 test_hmm_uapi.h
  -rw-r--r--  1 liuliancao liuliancao   4392 5月  17 08:59 test_ida.c
  -rw-r--r--  1 liuliancao liuliancao  28889 5月  17 08:59 test_kasan.c
  -rw-r--r--  1 liuliancao liuliancao   3499 5月  17 08:59 test_kasan_module.c
  -rw-r--r--  1 liuliancao liuliancao  30571 5月  17 08:59 test_kmod.c
  -rw-r--r--  1 liuliancao liuliancao  17713 5月  17 08:59 test-kstrtox.c
  -rw-r--r--  1 liuliancao liuliancao   7695 5月  17 08:59 test_linear_ranges.c
  -rw-r--r--  1 liuliancao liuliancao   3383 5月  17 08:59 test_list_sort.c
  -rw-r--r--  1 liuliancao liuliancao  16668 5月  17 08:59 test_lockup.c
  -rw-r--r--  1 liuliancao liuliancao   2298 5月  17 08:59 test_memcat_p.c
  -rw-r--r--  1 liuliancao liuliancao   9961 5月  17 08:59 test_meminit.c
  -rw-r--r--  1 liuliancao liuliancao   4425 5月  17 08:59 test_min_heap.c
  -rw-r--r--  1 liuliancao liuliancao    794 5月  17 08:59 test_module.c
  -rw-r--r--  1 liuliancao liuliancao  25159 5月  17 08:59 test_objagg.c
  -rw-r--r--  1 liuliancao liuliancao  22870 5月  17 08:59 test_overflow.c
  -rw-r--r--  1 liuliancao liuliancao  11431 5月  17 08:59 test_parman.c
  -rw-r--r--  1 liuliancao liuliancao  17005 5月  17 08:59 test_printf.c
  -rw-r--r--  1 liuliancao liuliancao  20431 5月  17 08:59 test_rhashtable.c
  -rw-r--r--  1 liuliancao liuliancao   7704 5月  17 08:59 test_siphash.c
  -rw-r--r--  1 liuliancao liuliancao    870 5月  17 08:59 test_sort.c
  -rw-r--r--  1 liuliancao liuliancao  11551 5月  17 08:59 test_stackinit.c
  -rw-r--r--  1 liuliancao liuliancao   1603 5月  17 08:59 test_static_key_base.c
  -rw-r--r--  1 liuliancao liuliancao   5731 5月  17 08:59 test_static_keys.c
  -rw-r--r--  1 liuliancao liuliancao   3931 5月  17 08:59 test_string.c
  -rw-r--r--  1 liuliancao liuliancao  11936 5月  17 08:59 test-string_helpers.c
  -rw-r--r--  1 liuliancao liuliancao   4112 5月  17 08:59 test_strscpy.c
  -rw-r--r--  1 liuliancao liuliancao   4036 5月  17 08:59 test_sysctl.c
  -rw-r--r--  1 liuliancao liuliancao   2976 5月  17 08:59 test_ubsan.c
  -rw-r--r--  1 liuliancao liuliancao   9303 5月  17 08:59 test_user_copy.c
  -rw-r--r--  1 liuliancao liuliancao   3485 5月  17 08:59 test_uuid.c
  -rw-r--r--  1 liuliancao liuliancao  12272 5月  17 08:59 test_vmalloc.c
  -rw-r--r--  1 liuliancao liuliancao  47880 5月  17 08:59 test_xarray.c
  -rw-r--r--  1 liuliancao liuliancao   9551 5月  17 08:59 textsearch.c
  -rw-r--r--  1 liuliancao liuliancao   2340 5月  17 08:59 timerqueue.c
  -rw-r--r--  1 liuliancao liuliancao   5194 5月  17 08:59 ts_bm.c
  -rw-r--r--  1 liuliancao liuliancao  10644 5月  17 08:59 ts_fsm.c
  -rw-r--r--  1 liuliancao liuliancao   4220 5月  17 08:59 ts_kmp.c
  -rw-r--r--  1 liuliancao liuliancao  10140 5月  17 08:59 ubsan.c
  -rw-r--r--  1 liuliancao liuliancao   1815 5月  17 08:59 ubsan.h
  -rw-r--r--  1 liuliancao liuliancao    568 5月  17 08:59 ucmpdi2.c
  -rw-r--r--  1 liuliancao liuliancao   2534 5月  17 08:59 ucs2_string.c
  -rw-r--r--  1 liuliancao liuliancao   2239 5月  17 08:59 usercopy.c
  -rw-r--r--  1 liuliancao liuliancao   2988 5月  17 08:59 uuid.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 vdso
  -rw-r--r--  1 liuliancao liuliancao  85400 5月  17 08:59 vsprintf.c
  -rw-r--r--  1 liuliancao liuliancao   3436 5月  17 08:59 win_minmax.c
  -rw-r--r--  1 liuliancao liuliancao  59946 5月  17 08:59 xarray.c
  -rw-r--r--  1 liuliancao liuliancao  12979 5月  17 08:59 xxhash.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 xz
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 zlib_deflate
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 zlib_dfltcc
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 zlib_inflate
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 zstd
LICENSES: 内核各个部分代码的LICENSE,GPL and so on.
1
2
3
4
5
6
7
8
  /home/liuliancao/projects/linux-5.12.4/LICENSES:
  总用量 24
  drwxr-xr-x  6 liuliancao liuliancao 4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao 4096 5月  17 09:13 ..
  drwxr-xr-x  2 liuliancao liuliancao 4096 5月  17 08:59 deprecated
  drwxr-xr-x  2 liuliancao liuliancao 4096 5月  17 08:59 dual
  drwxr-xr-x  2 liuliancao liuliancao 4096 5月  17 08:59 exceptions
  drwxr-xr-x  2 liuliancao liuliancao 4096 5月  17 08:59 preferred
mm: memory management and virtual memory, 用于内存和虚拟内存的管理

通过目录结构我们可用发现里面有swap, page等的管理和使用

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  /home/liuliancao/projects/linux-5.12.4/mm:
  总用量 4164
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao   4096 5月  17 09:13 ..
  -rw-r--r--  1 liuliancao liuliancao  25739 5月  17 08:59 backing-dev.c
  -rw-r--r--  1 liuliancao liuliancao   8425 5月  17 08:59 balloon_compaction.c
  -rw-r--r--  1 liuliancao liuliancao  10030 5月  17 08:59 cleancache.c
  -rw-r--r--  1 liuliancao liuliancao  15305 5月  17 08:59 cma.c
  -rw-r--r--  1 liuliancao liuliancao   4629 5月  17 08:59 cma_debug.c
  -rw-r--r--  1 liuliancao liuliancao    646 5月  17 08:59 cma.h
  -rw-r--r--  1 liuliancao liuliancao  83421 5月  17 08:59 compaction.c
  -rw-r--r--  1 liuliancao liuliancao   8640 5月  17 08:59 debug.c
  -rw-r--r--  1 liuliancao liuliancao   1414 5月  17 08:59 debug_page_ref.c
  -rw-r--r--  1 liuliancao liuliancao  32037 5月  17 08:59 debug_vm_pgtable.c
  -rw-r--r--  1 liuliancao liuliancao  13983 5月  17 08:59 dmapool.c
  -rw-r--r--  1 liuliancao liuliancao   6928 5月  17 08:59 early_ioremap.c
  -rw-r--r--  1 liuliancao liuliancao   5393 5月  17 08:59 fadvise.c
  -rw-r--r--  1 liuliancao liuliancao   1406 5月  17 08:59 failslab.c
  -rw-r--r--  1 liuliancao liuliancao 108158 5月  17 08:59 filemap.c
  -rw-r--r--  1 liuliancao liuliancao  14578 5月  17 08:59 frontswap.c
  -rw-r--r--  1 liuliancao liuliancao  83065 5月  17 08:59 gup.c
  -rw-r--r--  1 liuliancao liuliancao   5576 5月  17 08:59 gup_test.c
  -rw-r--r--  1 liuliancao liuliancao    915 5月  17 08:59 gup_test.h
  -rw-r--r--  1 liuliancao liuliancao  19889 5月  17 08:59 highmem.c
  -rw-r--r--  1 liuliancao liuliancao  16961 5月  17 08:59 hmm.c
  -rw-r--r--  1 liuliancao liuliancao  85053 5月  17 08:59 huge_memory.c
  -rw-r--r--  1 liuliancao liuliancao 161515 5月  17 08:59 hugetlb.c
  -rw-r--r--  1 liuliancao liuliancao  22046 5月  17 08:59 hugetlb_cgroup.c
  -rw-r--r--  1 liuliancao liuliancao   2693 5月  17 08:59 hwpoison-inject.c
  -rw-r--r--  1 liuliancao liuliancao   1324 5月  17 08:59 init-mm.c
  -rw-r--r--  1 liuliancao liuliancao  20307 5月  17 08:59 internal.h
  -rw-r--r--  1 liuliancao liuliancao   3201 5月  17 08:59 interval_tree.c
  -rw-r--r--  1 liuliancao liuliancao   6624 5月  17 08:59 ioremap.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 kasan
  -rw-r--r--  1 liuliancao liuliancao  28726 5月  17 08:59 Kconfig
  -rw-r--r--  1 liuliancao liuliancao   5699 5月  17 08:59 Kconfig.debug
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 kfence
  -rw-r--r--  1 liuliancao liuliancao  60444 5月  17 08:59 khugepaged.c
  -rw-r--r--  1 liuliancao liuliancao  57589 5月  17 08:59 kmemleak.c
  -rw-r--r--  1 liuliancao liuliancao  90883 5月  17 08:59 ksm.c
  -rw-r--r--  1 liuliancao liuliancao  14499 5月  17 08:59 list_lru.c
  -rw-r--r--  1 liuliancao liuliancao   8887 5月  17 08:59 maccess.c
  -rw-r--r--  1 liuliancao liuliancao  31354 5月  17 08:59 madvise.c
  -rw-r--r--  1 liuliancao liuliancao   4427 5月  17 08:59 Makefile
  -rw-r--r--  1 liuliancao liuliancao  10778 5月  17 08:59 mapping_dirty_helpers.c
  -rw-r--r--  1 liuliancao liuliancao  60241 5月  17 08:59 memblock.c
  -rw-r--r--  1 liuliancao liuliancao 195016 5月  17 08:59 memcontrol.c
  -rw-r--r--  1 liuliancao liuliancao   8126 5月  17 08:59 memfd.c
  -rw-r--r--  1 liuliancao liuliancao 145068 5月  17 08:59 memory.c
  -rw-r--r--  1 liuliancao liuliancao  54095 5月  17 08:59 memory-failure.c
  -rw-r--r--  1 liuliancao liuliancao  55145 5月  17 08:59 memory_hotplug.c
  -rw-r--r--  1 liuliancao liuliancao  78234 5月  17 08:59 mempolicy.c
  -rw-r--r--  1 liuliancao liuliancao  16212 5月  17 08:59 mempool.c
  -rw-r--r--  1 liuliancao liuliancao  14795 5月  17 08:59 memremap.c
  -rw-r--r--  1 liuliancao liuliancao   2851 5月  17 08:59 memtest.c
  -rw-r--r--  1 liuliancao liuliancao  84249 5月  17 08:59 migrate.c
  -rw-r--r--  1 liuliancao liuliancao   7189 5月  17 08:59 mincore.c
  -rw-r--r--  1 liuliancao liuliancao  22686 5月  17 08:59 mlock.c
  -rw-r--r--  1 liuliancao liuliancao 105416 5月  17 08:59 mmap.c
  -rw-r--r--  1 liuliancao liuliancao   5960 5月  17 08:59 mmap_lock.c
  -rw-r--r--  1 liuliancao liuliancao   5445 5月  17 08:59 mm_init.c
  -rw-r--r--  1 liuliancao liuliancao   8733 5月  17 08:59 mmu_gather.c
  -rw-r--r--  1 liuliancao liuliancao  35870 5月  17 08:59 mmu_notifier.c
  -rw-r--r--  1 liuliancao liuliancao   2204 5月  17 08:59 mmzone.c
  -rw-r--r--  1 liuliancao liuliancao  17689 5月  17 08:59 mprotect.c
  -rw-r--r--  1 liuliancao liuliancao  26404 5月  17 08:59 mremap.c
  -rw-r--r--  1 liuliancao liuliancao   2712 5月  17 08:59 msync.c
  -rw-r--r--  1 liuliancao liuliancao  45928 5月  17 08:59 nommu.c
  -rw-r--r--  1 liuliancao liuliancao  31053 5月  17 08:59 oom_kill.c
  -rw-r--r--  1 liuliancao liuliancao 254661 5月  17 08:59 page_alloc.c
  -rw-r--r--  1 liuliancao liuliancao   6795 5月  17 08:59 page_counter.c
  -rw-r--r--  1 liuliancao liuliancao  11173 5月  17 08:59 page_ext.c
  -rw-r--r--  1 liuliancao liuliancao   5477 5月  17 08:59 page_idle.c
  -rw-r--r--  1 liuliancao liuliancao  11462 5月  17 08:59 page_io.c
  -rw-r--r--  1 liuliancao liuliancao   9456 5月  17 08:59 page_isolation.c
  -rw-r--r--  1 liuliancao liuliancao  16688 5月  17 08:59 page_owner.c
  -rw-r--r--  1 liuliancao liuliancao   2436 5月  17 08:59 page_poison.c
  -rw-r--r--  1 liuliancao liuliancao  10183 5月  17 08:59 page_reporting.c
  -rw-r--r--  1 liuliancao liuliancao   1647 5月  17 08:59 page_reporting.h
  -rw-r--r--  1 liuliancao liuliancao   7949 5月  17 08:59 page_vma_mapped.c
  -rw-r--r--  1 liuliancao liuliancao  14534 5月  17 08:59 pagewalk.c
  -rw-r--r--  1 liuliancao liuliancao  87066 5月  17 08:59 page-writeback.c
  -rw-r--r--  1 liuliancao liuliancao  97985 5月  17 08:59 percpu.c
  -rw-r--r--  1 liuliancao liuliancao   7920 5月  17 08:59 percpu-internal.h
  -rw-r--r--  1 liuliancao liuliancao   3074 5月  17 08:59 percpu-km.c
  -rw-r--r--  1 liuliancao liuliancao   6341 5月  17 08:59 percpu-stats.c
  -rw-r--r--  1 liuliancao liuliancao  10569 5月  17 08:59 percpu-vm.c
  -rw-r--r--  1 liuliancao liuliancao   1298 5月  17 08:59 pgalloc-track.h
  -rw-r--r--  1 liuliancao liuliancao   5743 5月  17 08:59 pgtable-generic.c
  -rw-r--r--  1 liuliancao liuliancao   8429 5月  17 08:59 process_vm_access.c
  -rw-r--r--  1 liuliancao liuliancao   4111 5月  17 08:59 ptdump.c
  -rw-r--r--  1 liuliancao liuliancao  17702 5月  17 08:59 readahead.c
  -rw-r--r--  1 liuliancao liuliancao  57050 5月  17 08:59 rmap.c
  -rw-r--r--  1 liuliancao liuliancao   1345 5月  17 08:59 rodata_test.c
  -rw-r--r--  1 liuliancao liuliancao 112637 5月  17 08:59 shmem.c
  -rw-r--r--  1 liuliancao liuliancao   4789 5月  17 08:59 shuffle.c
  -rw-r--r--  1 liuliancao liuliancao   1164 5月  17 08:59 shuffle.h
  -rw-r--r--  1 liuliancao liuliancao 108862 5月  17 08:59 slab.c
  -rw-r--r--  1 liuliancao liuliancao  32758 5月  17 08:59 slab_common.c
  -rw-r--r--  1 liuliancao liuliancao  17140 5月  17 08:59 slab.h
  -rw-r--r--  1 liuliancao liuliancao  18621 5月  17 08:59 slob.c
  -rw-r--r--  1 liuliancao liuliancao 146754 5月  17 08:59 slub.c
  -rw-r--r--  1 liuliancao liuliancao  27055 5月  17 08:59 sparse.c
  -rw-r--r--  1 liuliancao liuliancao   6959 5月  17 08:59 sparse-vmemmap.c
  -rw-r--r--  1 liuliancao liuliancao  31380 5月  17 08:59 swap.c
  -rw-r--r--  1 liuliancao liuliancao   5270 5月  17 08:59 swap_cgroup.c
  -rw-r--r--  1 liuliancao liuliancao  98675 5月  17 08:59 swapfile.c
  -rw-r--r--  1 liuliancao liuliancao   9492 5月  17 08:59 swap_slots.c
  -rw-r--r--  1 liuliancao liuliancao  24990 5月  17 08:59 swap_state.c
  -rw-r--r--  1 liuliancao liuliancao  26192 5月  17 08:59 truncate.c
  -rw-r--r--  1 liuliancao liuliancao   9764 5月  17 08:59 usercopy.c
  -rw-r--r--  1 liuliancao liuliancao  18041 5月  17 08:59 userfaultfd.c
  -rw-r--r--  1 liuliancao liuliancao  25709 5月  17 08:59 util.c
  -rw-r--r--  1 liuliancao liuliancao   2792 5月  17 08:59 vmacache.c
  -rw-r--r--  1 liuliancao liuliancao  93948 5月  17 08:59 vmalloc.c
  -rw-r--r--  1 liuliancao liuliancao  14187 5月  17 08:59 vmpressure.c
  -rw-r--r--  1 liuliancao liuliancao 126838 5月  17 08:59 vmscan.c
  -rw-r--r--  1 liuliancao liuliancao  55129 5月  17 08:59 vmstat.c
  -rw-r--r--  1 liuliancao liuliancao  21841 5月  17 08:59 workingset.c
  -rw-r--r--  1 liuliancao liuliancao  48206 5月  17 08:59 z3fold.c
  -rw-r--r--  1 liuliancao liuliancao  18652 5月  17 08:59 zbud.c
  -rw-r--r--  1 liuliancao liuliancao  11764 5月  17 08:59 zpool.c
  -rw-r--r--  1 liuliancao liuliancao  62547 5月  17 08:59 zsmalloc.c
  -rw-r--r--  1 liuliancao liuliancao  39946 5月  17 08:59 zswap.c
net: network stack, 网络协议栈

从目录结构我们可用看出来是网络协议的实现,包含类似802, ipv4, dns等对数据包的管理

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  /home/liuliancao/projects/linux-5.12.4/net:
  总用量 428
  drwxr-xr-x 71 liuliancao liuliancao  4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao  4096 5月  17 09:13 ..
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 6lowpan
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 802
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 8021q
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 9p
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 appletalk
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 atm
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ax25
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 batman-adv
  drwxr-xr-x  6 liuliancao liuliancao  4096 5月  17 08:59 bluetooth
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 bpf
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 bpfilter
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 bridge
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 caif
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 can
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 ceph
  -rw-r--r--  1 liuliancao liuliancao 14540 5月  17 08:59 compat.c
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 core
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 dcb
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 dccp
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 decnet
  -rw-r--r--  1 liuliancao liuliancao  2248 5月  17 08:59 devres.c
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 dns_resolver
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 dsa
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ethernet
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ethtool
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 hsr
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 ieee802154
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ife
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 ipv4
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 ipv6
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 iucv
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 kcm
  -rw-r--r--  1 liuliancao liuliancao 14385 5月  17 08:59 Kconfig
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 key
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 l2tp
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 l3mdev
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 lapb
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 llc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 mac80211
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 mac802154
  -rw-r--r--  1 liuliancao liuliancao  2433 5月  17 08:59 Makefile
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 mpls
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 mptcp
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ncsi
  drwxr-xr-x  4 liuliancao liuliancao 12288 5月  17 08:59 netfilter
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 netlabel
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 netlink
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 netrom
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 nfc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 nsh
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 openvswitch
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 packet
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 phonet
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 psample
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 qrtr
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 rds
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 rfkill
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 rose
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 rxrpc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 sched
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 sctp
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 smc
  -rw-r--r--  1 liuliancao liuliancao 93522 5月  17 08:59 socket.c
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 strparser
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 sunrpc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 switchdev
  -rw-r--r--  1 liuliancao liuliancao  3083 5月  17 08:59 sysctl_net.c
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 tipc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 tls
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 unix
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 vmw_vsock
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 wireless
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 x25
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 xdp
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 xfrm
samples: 样例,里面写了一些工具的使用demo
1
2
3
4
5
6
7
  /home/liuliancao/projects/linux-5.12.4/samples/pidfd:
  总用量 20
  drwxr-xr-x  2 liuliancao liuliancao 4096 5月  17 08:59 .
  drwxr-xr-x 33 liuliancao liuliancao 4096 5月  17 08:59 ..
  -rw-r--r--  1 liuliancao liuliancao   55 5月  17 08:59 .gitignore
  -rw-r--r--  1 liuliancao liuliancao  104 5月  17 08:59 Makefile
  -rw-r--r--  1 liuliancao liuliancao 2389 5月  17 08:59 pidfd-metadata.c
scripts: 用于构建内核的脚本
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  /home/liuliancao/projects/linux-5.12.4/scripts:
  总用量 1396
  drwxr-xr-x 17 liuliancao liuliancao   4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao   4096 5月  17 09:13 ..
  -rwxr-xr-x  1 liuliancao liuliancao   2143 5月  17 08:59 adjust_autoksyms.sh
  -rw-r--r--  1 liuliancao liuliancao  36169 5月  17 08:59 asn1_compiler.c
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 atomic
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 basic
  -rw-r--r--  1 liuliancao liuliancao    743 5月  17 08:59 bin2c.c
  -rwxr-xr-x  1 liuliancao liuliancao   3445 5月  17 08:59 bloat-o-meter
  -rwxr-xr-x  1 liuliancao liuliancao   5780 5月  17 08:59 bootgraph.pl
  -rwxr-xr-x  1 liuliancao liuliancao  22062 5月  17 08:59 bpf_helpers_doc.py
  -rwxr-xr-x  1 liuliancao liuliancao    166 5月  17 08:59 cc-can-link.sh
  -rwxr-xr-x  1 liuliancao liuliancao   1847 5月  17 08:59 cc-version.sh
  -rwxr-xr-x  1 liuliancao liuliancao   5049 5月  17 08:59 check_extable.sh
  -rwxr-xr-x  1 liuliancao liuliancao   1988 5月  17 08:59 checkincludes.pl
  -rwxr-xr-x  1 liuliancao liuliancao  15854 5月  17 08:59 checkkconfigsymbols.py
  -rwxr-xr-x  1 liuliancao liuliancao 225083 5月  17 08:59 checkpatch.pl
  -rwxr-xr-x  1 liuliancao liuliancao   6041 5月  17 08:59 checkstack.pl
  -rwxr-xr-x  1 liuliancao liuliancao   7443 5月  17 08:59 checksyscalls.sh
  -rwxr-xr-x  1 liuliancao liuliancao   4472 5月  17 08:59 check-sysctl-docs
  -rwxr-xr-x  1 liuliancao liuliancao   1943 5月  17 08:59 checkversion.pl
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 clang-tools
  -rwxr-xr-x  1 liuliancao liuliancao   3542 5月  17 08:59 cleanfile
  -rwxr-xr-x  1 liuliancao liuliancao   5182 5月  17 08:59 cleanpatch
  -rwxr-xr-x  1 liuliancao liuliancao   8068 5月  17 08:59 coccicheck
  drwxr-xr-x  9 liuliancao liuliancao   4096 5月  17 08:59 coccinelle
  -rwxr-xr-x  1 liuliancao liuliancao   4784 5月  17 08:59 config
  -rw-r--r--  1 liuliancao liuliancao   1009 5月  17 08:59 const_structs.checkpatch
  -rwxr-xr-x  1 liuliancao liuliancao   2952 5月  17 08:59 decodecode
  -rwxr-xr-x  1 liuliancao liuliancao   5321 5月  17 08:59 decode_stacktrace.sh
  -rwxr-xr-x  1 liuliancao liuliancao   1441 5月  17 08:59 depmod.sh
  -rwxr-xr-x  1 liuliancao liuliancao   6219 5月  17 08:59 dev-needs.sh
  -rwxr-xr-x  1 liuliancao liuliancao   3812 5月  17 08:59 diffconfig
  -rwxr-xr-x  1 liuliancao liuliancao   5687 5月  17 08:59 documentation-file-ref-check
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 dtc
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 dummy-tools
  -rwxr-xr-x  1 liuliancao liuliancao   4605 5月  17 08:59 export_report.pl
  -rw-r--r--  1 liuliancao liuliancao   3548 5月  17 08:59 extract-cert.c
  -rwxr-xr-x  1 liuliancao liuliancao   1734 5月  17 08:59 extract-ikconfig
  -rwxr-xr-x  1 liuliancao liuliancao   3746 5月  17 08:59 extract-module-sig.pl
  -rwxr-xr-x  1 liuliancao liuliancao   3836 5月  17 08:59 extract-sys-certs.pl
  -rwxr-xr-x  1 liuliancao liuliancao   1695 5月  17 08:59 extract-vmlinux
  -rwxr-xr-x  1 liuliancao liuliancao  45686 5月  17 08:59 extract_xc3028.pl
  -rwxr-xr-x  1 liuliancao liuliancao   6301 5月  17 08:59 faddr2line
  -rwxr-xr-x  1 liuliancao liuliancao     86 5月  17 08:59 file-size.sh
  -rwxr-xr-x  1 liuliancao liuliancao   1304 5月  17 08:59 find-unused-docs.sh
  -rwxr-xr-x  1 liuliancao liuliancao    511 5月  17 08:59 gcc-goto.sh
  -rwxr-xr-x  1 liuliancao liuliancao    711 5月  17 08:59 gcc-ld
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 gcc-plugins
  -rwxr-xr-x  1 liuliancao liuliancao    173 5月  17 08:59 gcc-x86_32-has-stack-protector.sh
  -rwxr-xr-x  1 liuliancao liuliancao    198 5月  17 08:59 gcc-x86_64-has-stack-protector.sh
  drwxr-xr-x  3 liuliancao liuliancao   4096 5月  17 08:59 gdb
  -rwxr-xr-x  1 liuliancao liuliancao   2002 5月  17 08:59 gen_autoksyms.sh
  -rwxr-xr-x  1 liuliancao liuliancao   6090 5月  17 08:59 generate_initcall_order.pl
  -rwxr-xr-x  1 liuliancao liuliancao    399 5月  17 08:59 gen_ksymdeps.sh
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 genksyms
  -rwxr-xr-x  1 liuliancao liuliancao  14662 5月  17 08:59 get_abi.pl
  -rwxr-xr-x  1 liuliancao liuliancao  25128 5月  17 08:59 get_dvb_firmware
  -rwxr-xr-x  1 liuliancao liuliancao  14689 5月  17 08:59 get_feat.pl
  -rwxr-xr-x  1 liuliancao liuliancao  68744 5月  17 08:59 get_maintainer.pl
  -rwxr-xr-x  1 liuliancao liuliancao   1732 5月  17 08:59 gfp-translate
  -rw-r--r--  1 liuliancao liuliancao    151 5月  17 08:59 .gitignore
  -rwxr-xr-x  1 liuliancao liuliancao   3587 5月  17 08:59 headerdep.pl
  -rwxr-xr-x  1 liuliancao liuliancao   3819 5月  17 08:59 headers_check.pl
  -rwxr-xr-x  1 liuliancao liuliancao   3431 5月  17 08:59 headers_install.sh
  -rw-r--r--  1 liuliancao liuliancao   9084 5月  17 08:59 insert-sys-cert.c
  -rwxr-xr-x  1 liuliancao liuliancao   2213 5月  17 08:59 jobserver-exec
  -rw-r--r--  1 liuliancao liuliancao  18498 5月  17 08:59 kallsyms.c
  -rw-r--r--  1 liuliancao liuliancao  12016 5月  17 08:59 Kbuild.include
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 kconfig
  -rw-r--r--  1 liuliancao liuliancao   2286 5月  17 08:59 Kconfig.include
  -rwxr-xr-x  1 liuliancao liuliancao  69033 5月  17 08:59 kernel-doc
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 ksymoops
  -rwxr-xr-x  1 liuliancao liuliancao   1786 5月  17 08:59 ld-version.sh
  -rwxr-xr-x  1 liuliancao liuliancao  13105 5月  17 08:59 leaking_addresses.pl
  -rwxr-xr-x  1 liuliancao liuliancao    502 5月  17 08:59 Lindent
  -rwxr-xr-x  1 liuliancao liuliancao  11153 5月  17 08:59 link-vmlinux.sh
  -rw-r--r--  1 liuliancao liuliancao   1601 5月  17 08:59 Makefile
  -rw-r--r--  1 liuliancao liuliancao   1842 5月  17 08:59 Makefile.asm-generic
  -rw-r--r--  1 liuliancao liuliancao  18568 5月  17 08:59 Makefile.build
  -rw-r--r--  1 liuliancao liuliancao   2243 5月  17 08:59 Makefile.clean
  -rw-r--r--  1 liuliancao liuliancao    988 5月  17 08:59 Makefile.dtbinst
  -rw-r--r--  1 liuliancao liuliancao   2837 5月  17 08:59 Makefile.extrawarn
  -rw-r--r--  1 liuliancao liuliancao   2608 5月  17 08:59 Makefile.gcc-plugins
  -rw-r--r--  1 liuliancao liuliancao   2939 5月  17 08:59 Makefile.headersinst
  -rw-r--r--  1 liuliancao liuliancao   4743 5月  17 08:59 Makefile.host
  -rw-r--r--  1 liuliancao liuliancao   1654 5月  17 08:59 Makefile.kasan
  -rw-r--r--  1 liuliancao liuliancao    333 5月  17 08:59 Makefile.kcov
  -rw-r--r--  1 liuliancao liuliancao    739 5月  17 08:59 Makefile.kcsan
  -rw-r--r--  1 liuliancao liuliancao  17590 5月  17 08:59 Makefile.lib
  -rw-r--r--  1 liuliancao liuliancao   3261 5月  17 08:59 Makefile.modfinal
  -rw-r--r--  1 liuliancao liuliancao   1079 5月  17 08:59 Makefile.modinst
  -rw-r--r--  1 liuliancao liuliancao   4535 5月  17 08:59 Makefile.modpost
  -rw-r--r--  1 liuliancao liuliancao    791 5月  17 08:59 Makefile.modsign
  -rw-r--r--  1 liuliancao liuliancao   6779 5月  17 08:59 Makefile.package
  -rw-r--r--  1 liuliancao liuliancao    837 5月  17 08:59 Makefile.ubsan
  -rw-r--r--  1 liuliancao liuliancao   1607 5月  17 08:59 Makefile.userprogs
  -rwxr-xr-x  1 liuliancao liuliancao    808 5月  17 08:59 makelst
  -rwxr-xr-x  1 liuliancao liuliancao   8110 5月  17 08:59 markup_oops.pl
  -rwxr-xr-x  1 liuliancao liuliancao   2329 5月  17 08:59 mkcompile_h
  -rwxr-xr-x  1 liuliancao liuliancao    426 5月  17 08:59 mkmakefile
  -rwxr-xr-x  1 liuliancao liuliancao   1360 5月  17 08:59 mksysmap
  -rwxr-xr-x  1 liuliancao liuliancao    414 5月  17 08:59 mkuboot.sh
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 mod
  -rw-r--r--  1 liuliancao liuliancao   1132 5月  17 08:59 module.lds.S
  -rwxr-xr-x  1 liuliancao liuliancao    434 5月  17 08:59 modules-check.sh
  -rw-r--r--  1 liuliancao liuliancao   1763 5月  17 08:59 nsdeps
  -rwxr-xr-x  1 liuliancao liuliancao   2905 5月  17 08:59 objdiff
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 package
  -rwxr-xr-x  1 liuliancao liuliancao   4646 5月  17 08:59 parse-maintainers.pl
  -rwxr-xr-x  1 liuliancao liuliancao  10185 5月  17 08:59 patch-kernel
  -rwxr-xr-x  1 liuliancao liuliancao    414 5月  17 08:59 profile2linkerlist.pl
  -rwxr-xr-x  1 liuliancao liuliancao    708 5月  17 08:59 prune-kernel
  -rw-r--r--  1 liuliancao liuliancao  17091 5月  17 08:59 recordmcount.c
  -rw-r--r--  1 liuliancao liuliancao  19740 5月  17 08:59 recordmcount.h
  -rwxr-xr-x  1 liuliancao liuliancao  19226 5月  17 08:59 recordmcount.pl
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 selinux
  -rwxr-xr-x  1 liuliancao liuliancao   4844 5月  17 08:59 setlocalversion
  -rwxr-xr-x  1 liuliancao liuliancao   3087 5月  17 08:59 show_delta
  -rw-r--r--  1 liuliancao liuliancao   9994 5月  17 08:59 sign-file.c
  -rw-r--r--  1 liuliancao liuliancao   8887 5月  17 08:59 sorttable.c
  -rw-r--r--  1 liuliancao liuliancao   9884 5月  17 08:59 sorttable.h
  -rwxr-xr-x  1 liuliancao liuliancao  10315 5月  17 08:59 spdxcheck.py
  -rw-r--r--  1 liuliancao liuliancao    323 5月  17 08:59 spdxcheck-test.sh
  -rw-r--r--  1 liuliancao liuliancao  31804 5月  17 08:59 spelling.txt
  -rwxr-xr-x  1 liuliancao liuliancao  22186 5月  17 08:59 sphinx-pre-install
  -rwxr-xr-x  1 liuliancao liuliancao    604 5月  17 08:59 split-man.pl
  -rwxr-xr-x  1 liuliancao liuliancao   1887 5月  17 08:59 stackdelta
  -rwxr-xr-x  1 liuliancao liuliancao    794 5月  17 08:59 stackusage
  -rw-r--r--  1 liuliancao liuliancao    641 5月  17 08:59 subarch.include
  -rwxr-xr-x  1 liuliancao liuliancao   1945 5月  17 08:59 syscallhdr.sh
  -rwxr-xr-x  1 liuliancao liuliancao   1359 5月  17 08:59 syscalltbl.sh
  -rwxr-xr-x  1 liuliancao liuliancao   9781 5月  17 08:59 tags.sh
  -rwxr-xr-x  1 liuliancao liuliancao    416 5月  17 08:59 test_dwarf5_support.sh
  -rwxr-xr-x  1 liuliancao liuliancao    518 5月  17 08:59 tools-support-relr.sh
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 tracing
  -rw-r--r--  1 liuliancao liuliancao  35637 5月  17 08:59 unifdef.c
  -rwxr-xr-x  1 liuliancao liuliancao   2706 5月  17 08:59 ver_linux
  -rw-r--r--  1 liuliancao liuliancao    386 5月  17 08:59 xen-hypercalls.sh
  -rwxr-xr-x  1 liuliancao liuliancao    563 5月  17 08:59 xz_wrap.sh
security: Linux Secure Module(LSM), 放置linux安全模块, 里面还有selinux
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  /home/liuliancao/projects/linux-5.12.4/security:
  总用量 244
  drwxr-xr-x 13 liuliancao liuliancao  4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao  4096 5月  17 09:13 ..
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 apparmor
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 bpf
  -rw-r--r--  1 liuliancao liuliancao 43681 5月  17 08:59 commoncap.c
  -rw-r--r--  1 liuliancao liuliancao 21621 5月  17 08:59 device_cgroup.c
  -rw-r--r--  1 liuliancao liuliancao 10828 5月  17 08:59 inode.c
  drwxr-xr-x  5 liuliancao liuliancao  4096 5月  17 08:59 integrity
  -rw-r--r--  1 liuliancao liuliancao 10980 5月  17 08:59 Kconfig
  -rw-r--r--  1 liuliancao liuliancao  9048 5月  17 08:59 Kconfig.hardening
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 keys
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 loadpin
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 lockdown
  -rw-r--r--  1 liuliancao liuliancao 11134 5月  17 08:59 lsm_audit.c
  -rw-r--r--  1 liuliancao liuliancao  1292 5月  17 08:59 Makefile
  -rw-r--r--  1 liuliancao liuliancao  1374 5月  17 08:59 min_addr.c
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 safesetid
  -rw-r--r--  1 liuliancao liuliancao 65882 5月  17 08:59 security.c
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 selinux
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 smack
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 tomoyo
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 yama
sound: 音频系统
tools: 放了一些工具方便做小内核测试
usr: initramfs相关
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  /home/liuliancao/projects/linux-5.12.4/usr:
  总用量 60
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao  4096 5月  17 09:13 ..
  -rw-r--r--  1 liuliancao liuliancao   153 5月  17 08:59 default_cpio_list
  -rw-r--r--  1 liuliancao liuliancao 13065 5月  17 08:59 gen_init_cpio.c
  -rwxr-xr-x  1 liuliancao liuliancao  5848 5月  17 08:59 gen_initramfs.sh
  -rw-r--r--  1 liuliancao liuliancao    94 5月  17 08:59 .gitignore
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 include
  -rw-r--r--  1 liuliancao liuliancao  1243 5月  17 08:59 initramfs_data.S
  -rw-r--r--  1 liuliancao liuliancao  7905 5月  17 08:59 Kconfig
  -rw-r--r--  1 liuliancao liuliancao  3003 5月  17 08:59 Makefile
virt: 虚拟化相关
1
2
3
4
5
6
7
  /home/liuliancao/projects/linux-5.12.4/virt:
  总用量 20
  drwxr-xr-x  4 liuliancao liuliancao 4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao 4096 5月  17 09:13 ..
  drwxr-xr-x  2 liuliancao liuliancao 4096 5月  17 08:59 kvm
  drwxr-xr-x  2 liuliancao liuliancao 4096 5月  17 08:59 lib
  -rw-r--r--  1 liuliancao liuliancao   54 5月  17 08:59 Makefile

整个内核内部工作流

操作系统,shell,内核的关系
  • 对于计算机来讲,硬件是基础,而能让硬件运转起来的带有这些驱动的平台就是操作系统
  • 为了更方便管理好所有的硬件软件资源,操作系统需要做常见的内存管理、进程管理、块设备管理等,由于内部写的代码

并不是很好理解,所以提供库函数入口给其他软件层应用使用,而对于系统管理员和其他用户来说,shell就是很好的软件入口

  • 对于操作系统,其实包含了包含但不限于用户接口(比如shell)、运行程序(比如C),硬件设备管理,文件系统,各种资源分配,错误检查,各个

模块的信息交流(比如中断),安全等功能

  • 而内核是操作系统的核心,即使我们有各种发行版本,但是它们都有一个大脑,内核,而且随着时间推移,一直在更新里面的特性
操作系统启动流程

可以简要概述一下, 分为如下几个步骤

  • 按下启动按钮,电源接通
  • BIOS自检(检查硬件等情况)
  • 读取硬盘第一扇区MBR(512bytes并执行)
  • 这一段程序我们通常称为bootstrap program,常见的grub boot loader
  • 熟悉grub的配置的知道,里面对应了内核的位置和菜单等选项
  • 内核加载并运行第一个进程init
  • 内核运行自己的其他程序直至login

内核内部功能实现逻辑(个人理解,待修改)

从目录结构看,include,lib等地方放了常用的功能函数,其他地方比如是开发网络相关模块,就在net下面开发,开发完在 sample写一些例子,开发过程中include上面的功能函数,和自己的功能合并,最后通过内核perf等测试,最后合到分支

从了解网络开始

个人认为网络理解起来没那么抽象,作为第一个部分入门学习比较合适,主要了解内核的工作流和如何看内核,梳理用到的库等信息, 并且这里面会涉及到用哪些工具更快找到所需要的函数定义等信息

目录结构
net目录结构概览
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  /home/liuliancao/projects/linux-5.12.4/net:
  总用量 428
  drwxr-xr-x 71 liuliancao liuliancao  4096 5月  17 08:59 .
  drwxr-xr-x 24 liuliancao liuliancao  4096 5月  17 09:13 ..
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 6lowpan
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 802
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 8021q
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 9p
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 appletalk
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 atm
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ax25
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 batman-adv
  drwxr-xr-x  6 liuliancao liuliancao  4096 5月  17 08:59 bluetooth
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 bpf
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 bpfilter
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 bridge
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 caif
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 can
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 ceph
  -rw-r--r--  1 liuliancao liuliancao 14540 5月  17 08:59 compat.c
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 core
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 dcb
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 dccp
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 decnet
  -rw-r--r--  1 liuliancao liuliancao  2248 5月  17 08:59 devres.c
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 dns_resolver
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 dsa
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ethernet
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ethtool
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 hsr
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 ieee802154
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ife
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 ipv4
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 ipv6
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 iucv
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 kcm
  -rw-r--r--  1 liuliancao liuliancao 14385 5月  17 08:59 Kconfig
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 key
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 l2tp
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 l3mdev
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 lapb
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 llc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 mac80211
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 mac802154
  -rw-r--r--  1 liuliancao liuliancao  2433 5月  17 08:59 Makefile
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 mpls
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 mptcp
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 ncsi
  drwxr-xr-x  4 liuliancao liuliancao 12288 5月  17 08:59 netfilter
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 netlabel
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 netlink
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 netrom
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 nfc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 nsh
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 openvswitch
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 packet
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 phonet
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 psample
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 qrtr
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 rds
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 rfkill
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 rose
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 rxrpc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 sched
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 sctp
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 smc
  -rw-r--r--  1 liuliancao liuliancao 93522 5月  17 08:59 socket.c
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 strparser
  drwxr-xr-x  4 liuliancao liuliancao  4096 5月  17 08:59 sunrpc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 switchdev
  -rw-r--r--  1 liuliancao liuliancao  3083 5月  17 08:59 sysctl_net.c
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 tipc
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 tls
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 unix
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 vmw_vsock
  drwxr-xr-x  3 liuliancao liuliancao  4096 5月  17 08:59 wireless
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 x25
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 xdp
  drwxr-xr-x  2 liuliancao liuliancao  4096 5月  17 08:59 xfrm
目录结构看内核

先找网络的入口文件,我觉得是Makefile(linux-5.12.4/net/Makefile), 这里大家自己去看吧 首先发现有 obj-y devres.o socket.o core obj-$(CONFIG_COMPAT) compat.o 其他都是编译选项对应的具体模块目录比如ipv4, netfilter, ethtool等 所以当内核build的时候,其实通过调用各个模块的Makefile就可以把需要的模块包含进kernel-headers和kernel-common 这里我计划先看下ipv4的模块

ipv4的协议实现
ipv4里面的目录结构
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
  /home/liuliancao/projects/linux-5.12.4/net/ipv4:
  总用量 2676
  drwxr-xr-x  4 liuliancao liuliancao   4096 5月  17 08:59 .
  drwxr-xr-x 71 liuliancao liuliancao   4096 5月  17 08:59 ..
  -rw-r--r--  1 liuliancao liuliancao  52699 5月  17 08:59 af_inet.c
  -rw-r--r--  1 liuliancao liuliancao  13946 5月  17 08:59 ah4.c
  -rw-r--r--  1 liuliancao liuliancao  36641 5月  17 08:59 arp.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 bpfilter
  -rw-r--r--  1 liuliancao liuliancao   6584 5月  17 08:59 bpf_tcp_ca.c
  -rw-r--r--  1 liuliancao liuliancao  62464 5月  17 08:59 cipso_ipv4.c
  -rw-r--r--  1 liuliancao liuliancao   3148 5月  17 08:59 datagram.c
  -rw-r--r--  1 liuliancao liuliancao  70257 5月  17 08:59 devinet.c
  -rw-r--r--  1 liuliancao liuliancao  28214 5月  17 08:59 esp4.c
  -rw-r--r--  1 liuliancao liuliancao   8941 5月  17 08:59 esp4_offload.c
  -rw-r--r--  1 liuliancao liuliancao  39512 5月  17 08:59 fib_frontend.c
  -rw-r--r--  1 liuliancao liuliancao   1684 5月  17 08:59 fib_lookup.h
  -rw-r--r--  1 liuliancao liuliancao   1622 5月  17 08:59 fib_notifier.c
  -rw-r--r--  1 liuliancao liuliancao  10017 5月  17 08:59 fib_rules.c
  -rw-r--r--  1 liuliancao liuliancao  53547 5月  17 08:59 fib_semantics.c
  -rw-r--r--  1 liuliancao liuliancao  74215 5月  17 08:59 fib_trie.c
  -rw-r--r--  1 liuliancao liuliancao  28802 5月  17 08:59 fou.c
  -rw-r--r--  1 liuliancao liuliancao   4979 5月  17 08:59 gre_demux.c
  -rw-r--r--  1 liuliancao liuliancao   7415 5月  17 08:59 gre_offload.c
  -rw-r--r--  1 liuliancao liuliancao  33593 5月  17 08:59 icmp.c
  -rw-r--r--  1 liuliancao liuliancao  74350 5月  17 08:59 igmp.c
  -rw-r--r--  1 liuliancao liuliancao  31570 5月  17 08:59 inet_connection_sock.c
  -rw-r--r--  1 liuliancao liuliancao  36117 5月  17 08:59 inet_diag.c
  -rw-r--r--  1 liuliancao liuliancao  15521 5月  17 08:59 inet_fragment.c
  -rw-r--r--  1 liuliancao liuliancao  25017 5月  17 08:59 inet_hashtables.c
  -rw-r--r--  1 liuliancao liuliancao   8394 5月  17 08:59 inetpeer.c
  -rw-r--r--  1 liuliancao liuliancao   9100 5月  17 08:59 inet_timewait_sock.c
  -rw-r--r--  1 liuliancao liuliancao   4495 5月  17 08:59 ipcomp.c
  -rw-r--r--  1 liuliancao liuliancao  43726 5月  17 08:59 ipconfig.c
  -rw-r--r--  1 liuliancao liuliancao   4167 5月  17 08:59 ip_forward.c
  -rw-r--r--  1 liuliancao liuliancao  17985 5月  17 08:59 ip_fragment.c
  -rw-r--r--  1 liuliancao liuliancao  46498 5月  17 08:59 ip_gre.c
  -rw-r--r--  1 liuliancao liuliancao  18761 5月  17 08:59 ip_input.c
  -rw-r--r--  1 liuliancao liuliancao  18877 5月  17 08:59 ipip.c
  -rw-r--r--  1 liuliancao liuliancao  10428 5月  17 08:59 ipmr_base.c
  -rw-r--r--  1 liuliancao liuliancao  77576 5月  17 08:59 ipmr.c
  -rw-r--r--  1 liuliancao liuliancao  15135 5月  17 08:59 ip_options.c
  -rw-r--r--  1 liuliancao liuliancao  44004 5月  17 08:59 ip_output.c
  -rw-r--r--  1 liuliancao liuliancao  41911 5月  17 08:59 ip_sockglue.c
  -rw-r--r--  1 liuliancao liuliancao  30118 5月  17 08:59 ip_tunnel.c
  -rw-r--r--  1 liuliancao liuliancao  29719 5月  17 08:59 ip_tunnel_core.c
  -rw-r--r--  1 liuliancao liuliancao  17513 5月  17 08:59 ip_vti.c
  -rw-r--r--  1 liuliancao liuliancao  26546 5月  17 08:59 Kconfig
  -rw-r--r--  1 liuliancao liuliancao   2872 5月  17 08:59 Makefile
  -rw-r--r--  1 liuliancao liuliancao   2209 5月  17 08:59 metrics.c
  drwxr-xr-x  2 liuliancao liuliancao   4096 5月  17 08:59 netfilter
  -rw-r--r--  1 liuliancao liuliancao   2576 5月  17 08:59 netfilter.c
  -rw-r--r--  1 liuliancao liuliancao    737 5月  17 08:59 netlink.c
  -rw-r--r--  1 liuliancao liuliancao  53464 5月  17 08:59 nexthop.c
  -rw-r--r--  1 liuliancao liuliancao  28249 5月  17 08:59 ping.c
  -rw-r--r--  1 liuliancao liuliancao  21354 5月  17 08:59 proc.c
  -rw-r--r--  1 liuliancao liuliancao   2147 5月  17 08:59 protocol.c
  -rw-r--r--  1 liuliancao liuliancao  26712 5月  17 08:59 raw.c
  -rw-r--r--  1 liuliancao liuliancao   6431 5月  17 08:59 raw_diag.c
  -rw-r--r--  1 liuliancao liuliancao  91645 5月  17 08:59 route.c
  -rw-r--r--  1 liuliancao liuliancao  12859 5月  17 08:59 syncookies.c
  -rw-r--r--  1 liuliancao liuliancao  36631 5月  17 08:59 sysctl_net_ipv4.c
  -rw-r--r--  1 liuliancao liuliancao  41846 5月  17 08:59 tcp_bbr.c
  -rw-r--r--  1 liuliancao liuliancao   6162 5月  17 08:59 tcp_bic.c
  -rw-r--r--  1 liuliancao liuliancao  14911 5月  17 08:59 tcp_bpf.c
  -rw-r--r--  1 liuliancao liuliancao 121916 5月  17 08:59 tcp.c
  -rw-r--r--  1 liuliancao liuliancao  11364 5月  17 08:59 tcp_cdg.c
  -rw-r--r--  1 liuliancao liuliancao  11951 5月  17 08:59 tcp_cong.c
  -rw-r--r--  1 liuliancao liuliancao  15730 5月  17 08:59 tcp_cubic.c
  -rw-r--r--  1 liuliancao liuliancao   7345 5月  17 08:59 tcp_dctcp.c
  -rw-r--r--  1 liuliancao liuliancao   1036 5月  17 08:59 tcp_dctcp.h
  -rw-r--r--  1 liuliancao liuliancao   5583 5月  17 08:59 tcp_diag.c
  -rw-r--r--  1 liuliancao liuliancao  16890 5月  17 08:59 tcp_fastopen.c
  -rw-r--r--  1 liuliancao liuliancao   5035 5月  17 08:59 tcp_highspeed.c
  -rw-r--r--  1 liuliancao liuliancao   7580 5月  17 08:59 tcp_htcp.c
  -rw-r--r--  1 liuliancao liuliancao   5043 5月  17 08:59 tcp_hybla.c
  -rw-r--r--  1 liuliancao liuliancao   8504 5月  17 08:59 tcp_illinois.c
  -rw-r--r--  1 liuliancao liuliancao 201248 5月  17 08:59 tcp_input.c
  -rw-r--r--  1 liuliancao liuliancao  81204 5月  17 08:59 tcp_ipv4.c
  -rw-r--r--  1 liuliancao liuliancao   9358 5月  17 08:59 tcp_lp.c
  -rw-r--r--  1 liuliancao liuliancao  27462 5月  17 08:59 tcp_metrics.c
  -rw-r--r--  1 liuliancao liuliancao  27290 5月  17 08:59 tcp_minisocks.c
  -rw-r--r--  1 liuliancao liuliancao  16050 5月  17 08:59 tcp_nv.c
  -rw-r--r--  1 liuliancao liuliancao   8328 5月  17 08:59 tcp_offload.c
  -rw-r--r--  1 liuliancao liuliancao 121680 5月  17 08:59 tcp_output.c
  -rw-r--r--  1 liuliancao liuliancao   7998 5月  17 08:59 tcp_rate.c
  -rw-r--r--  1 liuliancao liuliancao   7750 5月  17 08:59 tcp_recovery.c
  -rw-r--r--  1 liuliancao liuliancao   1456 5月  17 08:59 tcp_scalable.c
  -rw-r--r--  1 liuliancao liuliancao  23433 5月  17 08:59 tcp_timer.c
  -rw-r--r--  1 liuliancao liuliancao   3448 5月  17 08:59 tcp_ulp.c
  -rw-r--r--  1 liuliancao liuliancao   9906 5月  17 08:59 tcp_vegas.c
  -rw-r--r--  1 liuliancao liuliancao    940 5月  17 08:59 tcp_vegas.h
  -rw-r--r--  1 liuliancao liuliancao   5897 5月  17 08:59 tcp_veno.c
  -rw-r--r--  1 liuliancao liuliancao   8483 5月  17 08:59 tcp_westwood.c
  -rw-r--r--  1 liuliancao liuliancao   6714 5月  17 08:59 tcp_yeah.c
  -rw-r--r--  1 liuliancao liuliancao   6705 5月  17 08:59 tunnel4.c
  -rw-r--r--  1 liuliancao liuliancao   1339 5月  17 08:59 udp_bpf.c
  -rw-r--r--  1 liuliancao liuliancao  84340 5月  17 08:59 udp.c
  -rw-r--r--  1 liuliancao liuliancao   7353 5月  17 08:59 udp_diag.c
  -rw-r--r--  1 liuliancao liuliancao    966 5月  17 08:59 udp_impl.h
  -rw-r--r--  1 liuliancao liuliancao   2973 5月  17 08:59 udplite.c
  -rw-r--r--  1 liuliancao liuliancao  18603 5月  17 08:59 udp_offload.c
  -rw-r--r--  1 liuliancao liuliancao   5202 5月  17 08:59 udp_tunnel_core.c
  -rw-r--r--  1 liuliancao liuliancao  24779 5月  17 08:59 udp_tunnel_nic.c
  -rw-r--r--  1 liuliancao liuliancao    199 5月  17 08:59 udp_tunnel_stub.c
  -rw-r--r--  1 liuliancao liuliancao   4292 5月  17 08:59 xfrm4_input.c
  -rw-r--r--  1 liuliancao liuliancao   1168 5月  17 08:59 xfrm4_output.c
  -rw-r--r--  1 liuliancao liuliancao   6069 5月  17 08:59 xfrm4_policy.c
  -rw-r--r--  1 liuliancao liuliancao   6794 5月  17 08:59 xfrm4_protocol.c
  -rw-r--r--  1 liuliancao liuliancao    469 5月  17 08:59 xfrm4_state.c
  -rw-r--r--  1 liuliancao liuliancao   2745 5月  17 08:59 xfrm4_tunnel.c

IP协议是网络层协议,所以核心是实现网络层通信的功能

Makefile找茬

开篇, TCP/IP层makefile,想起了两本大书

obj-y又来了,现在看来y是yes的意思,可以发现obj-y本质上是每个模块的最重要的输出文件,如果要看一个文件的实现,那么看这些C编译好的.o文件就好了 其他仍然是一些编译选项,这里可以看到很多之前内核优化的一些参数, 可以看到如果要了解net里面有啥,从选项里面一目了然,

makefile里面的编译选项
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
obj-$(CONFIG_BPFILTER) += bpfilter/

obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o
obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
obj-$(CONFIG_PROC_FS) += proc.o
obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o
obj-$(CONFIG_IP_MROUTE) += ipmr.o
obj-$(CONFIG_IP_MROUTE_COMMON) += ipmr_base.o
obj-$(CONFIG_NET_IPIP) += ipip.o
gre-y := gre_demux.o
obj-$(CONFIG_NET_FOU) += fou.o
obj-$(CONFIG_NET_IPGRE_DEMUX) += gre.o
obj-$(CONFIG_NET_IPGRE) += ip_gre.o
udp_tunnel-y := udp_tunnel_core.o udp_tunnel_nic.o
obj-$(CONFIG_NET_UDP_TUNNEL) += udp_tunnel.o
obj-$(CONFIG_NET_IPVTI) += ip_vti.o
obj-$(CONFIG_SYN_COOKIES) += syncookies.o
obj-$(CONFIG_INET_AH) += ah4.o
obj-$(CONFIG_INET_ESP) += esp4.o
obj-$(CONFIG_INET_ESP_OFFLOAD) += esp4_offload.o
obj-$(CONFIG_INET_IPCOMP) += ipcomp.o
obj-$(CONFIG_INET_XFRM_TUNNEL) += xfrm4_tunnel.o
obj-$(CONFIG_INET_TUNNEL) += tunnel4.o
obj-$(CONFIG_IP_PNP) += ipconfig.o
obj-$(CONFIG_NETFILTER)	+= netfilter.o netfilter/
obj-$(CONFIG_INET_DIAG) += inet_diag.o
obj-$(CONFIG_INET_TCP_DIAG) += tcp_diag.o
obj-$(CONFIG_INET_UDP_DIAG) += udp_diag.o
obj-$(CONFIG_INET_RAW_DIAG) += raw_diag.o
obj-$(CONFIG_TCP_CONG_BBR) += tcp_bbr.o
obj-$(CONFIG_TCP_CONG_BIC) += tcp_bic.o
obj-$(CONFIG_TCP_CONG_CDG) += tcp_cdg.o
obj-$(CONFIG_TCP_CONG_CUBIC) += tcp_cubic.o
obj-$(CONFIG_TCP_CONG_DCTCP) += tcp_dctcp.o
obj-$(CONFIG_TCP_CONG_WESTWOOD) += tcp_westwood.o
obj-$(CONFIG_TCP_CONG_HSTCP) += tcp_highspeed.o
obj-$(CONFIG_TCP_CONG_HYBLA) += tcp_hybla.o
obj-$(CONFIG_TCP_CONG_HTCP) += tcp_htcp.o
obj-$(CONFIG_TCP_CONG_VEGAS) += tcp_vegas.o
obj-$(CONFIG_TCP_CONG_NV) += tcp_nv.o
obj-$(CONFIG_TCP_CONG_VENO) += tcp_veno.o
obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o
obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o
obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o
obj-$(CONFIG_NET_SOCK_MSG) += tcp_bpf.o
obj-$(CONFIG_BPF_STREAM_PARSER) += udp_bpf.o
obj-$(CONFIG_NETLABEL) += cipso_ipv4.o

obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \
                      xfrm4_output.o xfrm4_protocol.o

ifeq ($(CONFIG_BPF_JIT),y)
obj-$(CONFIG_BPF_SYSCALL) += bpf_tcp_ca.o
endif
继续找路,route.o是咋实现的

route.c肯定是route.o的前身, 所以进入route.c 注释部分:(意思这个文件是实现路由的,啥也没说相当于)

1
2
3
4
5
 * INET		An implementation of the TCP/IP protocol suite for the LINUX
 *		operating system.  INET is implemented using the  BSD Socket
 *		interface as the means of communication with the user level.
 *
 *		ROUTE - implementation of the IP router.
route.c实现

开头部分大量引入linux和net的.h(header)文件, 这些.h都是包含性的模块列表,相当于入口,因为它里面又包含了一堆include 所以实现net的ipv4 route功能需要用到net自身的库,linux自身的库,这些include都包含在了include文件夹

了解pr_fmt

#define pr_fmt(fmt) "IPv4: " fmt //这里是为了优化日志输出(C语言define http://c.biancheng.net/view/187.html) 看看pr_fmt的实现,grep下发现在include/printk.h里面, C语言已经扔后脑勺了,所以赶紧复习一下, 但是首先看一下注释 大概意思如下:

  • pr_fmt可以用来pr_*()这种宏,来打印printk形式的字符串消息

这个fmt就是传到pr_*()里面的字符串参数

  • 示例用法就是route.c里面的用法
1
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

这样的定义的好处就是每个pr_*()打印出来的结果会多一个prefix, 为什么呢

printk里面的内核pr_fmt定义
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
 * pr_fmt - used by the pr_*() macros to generate the printk format string
 * @fmt: format string passed from a pr_*() macro
 *
 * This macro can be used to generate a unified format string for pr_*()
 * macros. A common use is to prefix all pr_*() messages in a file with a common
 * string. For example, defining this at the top of a source file:
 *
 *        #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 *
 * would prefix all pr_info, pr_emerg... messages in the file with the module
 * name.
 */
 #ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif

/**
 * pr_emerg - Print an emergency-level message
 * @fmt: format string
 * @...: arguments for the format string
 *
 * This macro expands to a printk with KERN_EMERG loglevel. It uses pr_fmt() to
 * generate the format string.
 */
#define pr_emerg(fmt, ...) \
        printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
/**
 * pr_alert - Print an alert-level message
 * @fmt: format string
 * @...: arguments for the format string
 *
 * This macro expands to a printk with KERN_ALERT loglevel. It uses pr_fmt() to
 * generate the format string.
 */

那么先来了解C的语法吧

#ifndef #endif

这个肯定是如果没定义,则定义

#define

C里面define是标识常量的意思 所以这一句#define pr_fmt(fmt) fmt的意思是标识pr_fmt(fmt)用到的地方都变成我们写的一个常量+字符串 看一个我们写的笨拙的例子

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
/**
 * a test for pr_fmt by liuliancao at 2021/06/03.
 *
 */
#include <stdio.h>
#define pr_fmt(fmt) "TEST: " fmt

#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif


int main(void) {
  printf(pr_fmt("start"));
  return 0;
}

运行结果为(记得gcc ./xxx.o编译一下) liuliancao@liuliancao-dev:~/study/C/kernel$ ./a.out TEST: start

这样的好处是啥
  • 这样每次打印我们只需要打印自己的内容,就会自动有模块的开头,减少代码冗余,类似pr_emerg这种也是同理,

减少自定义等级带来的问题

  • 如果定义函数,那调用就要分配资源,通过定义宏,并不占内存预编译后就不存在
  • #开头的命令是预编译命令
route前的准备工作

看了route.c前几行定义,发现dst_entry和sk_buff是路由的关键,而对于整个路由操作,对应了这个核心结构体

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
static struct dst_ops ipv4_dst_ops = {
        .family =		AF_INET,
        .check =		ipv4_dst_check,
        .default_advmss =	ipv4_default_advmss,
        .mtu =			ipv4_mtu,
        .cow_metrics =		ipv4_cow_metrics,
        .destroy =		ipv4_dst_destroy,
        .negative_advice =	ipv4_negative_advice,
        .link_failure =		ipv4_link_failure,
        .update_pmtu =		ip_rt_update_pmtu,
        .redirect =		ip_do_redirect,
        .local_out =		__ip_local_out,
        .neigh_lookup =		ipv4_neigh_lookup,
        .confirm_neigh =	ipv4_confirm_neigh,
};

在231行还发现一个ops(这个看起来是路由表存放和遍历的地方),同样的udp.c等地方也使用了类似定义

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
static void *rt_cache_seq_start(struct seq_file *seq, loff_t *pos)
{
        if (*pos)
                return NULL;
        return SEQ_START_TOKEN;
}

static void *rt_cache_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
        ++*pos;
        return NULL;
}

static void rt_cache_seq_stop(struct seq_file *seq, void *v)
{
}

static int rt_cache_seq_show(struct seq_file *seq, void *v)
{
        if (v == SEQ_START_TOKEN)
                seq_printf(seq, "%-127s\n",
                           "Iface\tDestination\tGateway \tFlags\t\tRefCnt\tUse\t"
                           "Metric\tSource\t\tMTU\tWindow\tIRTT\tTOS\tHHRef\t"
                           "HHUptod\tSpecDst");
        return 0;
}

static const struct seq_operations rt_cache_seq_ops = {
        .start  = rt_cache_seq_start,
        .next   = rt_cache_seq_next,
        .stop   = rt_cache_seq_stop,
        .show   = rt_cache_seq_show,
};

而我们知道linux一切皆是文件,所以下面还有一段seq对应文件的函数操作集合rt_cache_proc_ops, 从这里可以看出这里是对应route程序的调用部分

1
2
3
4
5
6
static const struct proc_ops rt_cache_proc_ops = {
        .proc_open	= rt_cache_seq_open,
        .proc_read	= seq_read,
        .proc_lseek	= seq_lseek,
        .proc_release	= seq_release,
};

然后又看到写了个rt_cpu_seq_ops

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
static const struct seq_operations rt_cpu_seq_ops = {
        .start  = rt_cpu_seq_start,
        .next   = rt_cpu_seq_next,
        .stop   = rt_cpu_seq_stop,
        .show   = rt_cpu_seq_show,
};


static int rt_cpu_seq_open(struct inode *inode, struct file *file)
{
        return seq_open(file, &rt_cpu_seq_ops);
}

static const struct proc_ops rt_cpu_proc_ops = {
        .proc_open	= rt_cpu_seq_open,
        .proc_read	= seq_read,
        .proc_lseek	= seq_lseek,
        .proc_release	= seq_release,
};

可以看到通过这三个代码段,实现了程序对于cpu seq部分的处理, 这个部分路由信息应该是最底层和准确的 总结下: 对于rt结构,通过实现rt_cache_seq_ops、rt_proc_seq_ops、rt_cpu_seq_ops实现对于从文件到路由的抽象映射, 这个在其他的类似udp等的数据结构实现中如出一辙

一些初始化部分
rtacct工具展示包计数工具

这里取出上一次的bytes然后和现在的计数相加,最后写入seq文件,对应的是256种数据字段

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifdef CONFIG_IP_ROUTE_CLASSID
static int rt_acct_proc_show(struct seq_file *m, void *v)
{
        struct ip_rt_acct *dst, *src;
        unsigned int i, j;

        dst = kcalloc(256, sizeof(struct ip_rt_acct), GFP_KERNEL);
        if (!dst)
                return -ENOMEM;

        for_each_possible_cpu(i) {
                src = (struct ip_rt_acct *)per_cpu_ptr(ip_rt_acct, i);
                for (j = 0; j < 256; j++) {
                        dst[j].o_bytes   += src[j].o_bytes;
                        dst[j].o_packets += src[j].o_packets;
                        dst[j].i_bytes   += src[j].i_bytes;
                        dst[j].i_packets += src[j].i_packets;
                }
        }

        seq_write(m, dst, 256 * sizeof(struct ip_rt_acct));
        kfree(dst);
        return 0;
}
#endif
初始化函数探寻执行过程
__net_init & __net_exit
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
static int __net_init ip_rt_do_proc_init(struct net *net)
{
        struct proc_dir_entry *pde;

        pde = proc_create("rt_cache", 0444, net->proc_net,
                          &rt_cache_proc_ops);
        if (!pde)
                goto err1;

        pde = proc_create("rt_cache", 0444,
                          net->proc_net_stat, &rt_cpu_proc_ops);
        if (!pde)
                goto err2;

#ifdef CONFIG_IP_ROUTE_CLASSID
        pde = proc_create_single("rt_acct", 0, net->proc_net,
                        rt_acct_proc_show);
        if (!pde)
                goto err3;
#endif
        return 0;

#ifdef CONFIG_IP_ROUTE_CLASSID
err3:
        remove_proc_entry("rt_cache", net->proc_net_stat);
#endif
err2:
        remove_proc_entry("rt_cache", net->proc_net);
err1:
        return -ENOMEM;
}

可以看出来,net初始化(这里对应路由cache)对应一个pde相当于一个进程在/proc下面,这个column分别是rt_cache的proc_net和proc_net_stat,和rc_acct 其实对应的都是linux下的文

1
2
3
4
5
6
liuliancao@liuliancao-dev:~/projects/linux-5.12.4/include$ cat /proc/net/rt_acct
liuliancao@liuliancao-dev:~/projects/linux-5.12.4/include$ cat /proc/net/rt_cache
Iface   Destination     Gateway         Flags           RefCnt  Use     Metric  Source          MTU     Window  IRTT    TOS     HHRef   HHUptod SpecDst
liuliancao@liuliancao-dev:~/projects/linux-5.12.4/include$ cat /proc/net/stat/rt_cache |head -n 2
entries  in_hit in_slow_tot in_slow_mc in_no_route in_brd in_martian_dst in_martian_src  out_hit out_slow_tot out_slow_mc  gc_total gc_ignored gc_goal_miss gc_dst_overflow in_hlist_search out_hlist_search
0000000d  00000000 0000a2e5 00000001 00000000 0004b320 00000000 00000000  00000000 0000015c 0000002a 00000000 00000000 00000000 00000000 00000000 00000000

可以看出来这里面对应命中和源和目的地址等情况 还对应了一个exit(就是删除对应的proc下面的文件)

1
2
3
4
5
6
7
8
static void __net_exit ip_rt_do_proc_exit(struct net *net)
{
        remove_proc_entry("rt_cache", net->proc_net_stat);
        remove_proc_entry("rt_cache", net->proc_net);
#ifdef CONFIG_IP_ROUTE_CLASSID
        remove_proc_entry("rt_acct", net->proc_net);
#endif
}

可以找一下pde(proc_dir_entry)对应的数据结构(直接在include/linux下面grep下就可以找到)

1
2
3
/*linux/proc_fs.h*/
struct proc_dir_entry;
struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);
  • 简单看下,可以看出来这是一个系统进程对于文件的处理入口,里面有很多内核的公共函数,比如proc_create,通过这个,

可以创建指定mode的文件, 同时通过proc_dir_entry把proc_ops也传了过去

  • 这里其实一直有个疑问,cpu_proc_ops和cache_proc_ops到底是啥区别,目前知道cache_proc_ops在/proc/net/rt_cache这个一般没有内容,

而cpu_proc_ops在/porc/net/status/rt_cache,初步猜想是cpu里面的是真实的数据,而cache这是做一层缓存,默认都去cache找, cache没有再去cpu这个文件找,带着这个疑问继续看下去吧

ipv4_neigh_lookup

路由最重要的就是找邻居,那怎么找,数据存在哪,找的逻辑又是什么呢,看下内核是如何实现的

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
                                           struct sk_buff *skb,
                                           const void *daddr)
{
        const struct rtable *rt = container_of(dst, struct rtable, dst);
        struct net_device *dev = dst->dev;
        struct neighbour *n;

        rcu_read_lock_bh();

        if (likely(rt->rt_gw_family == AF_INET)) {
                n = ip_neigh_gw4(dev, rt->rt_gw4);
        } else if (rt->rt_gw_family == AF_INET6) {
                n = ip_neigh_gw6(dev, &rt->rt_gw6);
        } else {
                __be32 pkey;

                pkey = skb ? ip_hdr(skb)->daddr : *((__be32 *) daddr);
                n = ip_neigh_gw4(dev, pkey);
        }

        if (!IS_ERR(n) && !refcount_inc_not_zero(&n->refcnt))
                n = NULL;

        rcu_read_unlock_bh();

        return n;
}

看入参: 需要传入一个dst_entry,传入一个sk_buff(目测是一个buffer缓冲段存放),传了一个目的地址

路由表的数据结构

第一行是初始化一个路由表,根据dst_entry, 我们看下rtable的定义(猜一下也在顶部定义的route.h里面哈)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
struct rtable {
        struct dst_entry	dst;

        int			rt_genid;
        unsigned int		rt_flags;
        __u16			rt_type;
        __u8			rt_is_input;
        __u8			rt_uses_gateway;

        int			rt_iif;

        u8			rt_gw_family;
        /* Info on neighbour */
        union {
                __be32		rt_gw4;
                struct in6_addr	rt_gw6;
        };

        /* Miscellaneous cached information */
        u32			rt_mtu_locked:1,
                                rt_pmtu:31;

        struct list_head	rt_uncached;
        struct uncached_list	*rt_uncached_list;
};

先来想一个路由表对应了什么,

1
2
3
4
5
6
7
liuliancao@liuliancao-dev:~$ ip r
default via 192.168.10.1 dev ens33 onlink
192.168.10.0/24 dev ens33 proto kernel scope link src 192.168.10.204
liuliancao@liuliancao-dev:~$ cat /proc/net/route
Iface   Destination     Gateway         Flags   RefCnt  Use     Metric  Mask            MTU     Window  IRTT
ens33   00000000        010AA8C0        0003    0       0       0       00000000        0       0       0
ens33   000AA8C0        00000000        0001    0       0       0       00FFFFFF        0       0       0

可以对照如下, dst对应的是目的地址段 rt_genid是路由的id rt_flags对应flag 这个其实对应路由标志 标识不同的路由形式,比如直连,到一个主机,是否可以使用等 neighbour就是下一跳的地址 此外还放了其他额外信息 路由表的数据结构看完了,这个container_of也需要看下, 我现在还没调试好查询,用grep找下哈 liuliancao@liuliancao-dev:~/projects/linux-5.12.4/include$ cat ../net/ipv4/route.c |grep '.h'|grep include|awk -F '[<>]' '{print $2}'|grep -v '^$'|xargs -i grep -H container_of {} 可以看到在linux/kernel.h, ok,打开看看

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/** file: include/linux/kernel.h **/
/**
 * BUILD_BUG_ON_MSG - break compile if a condition is true & emit supplied
 *		      error message.
 * @condition: the condition which the compiler should know is false.
 *
 * See BUILD_BUG_ON for description.
 */
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)

/**
 * container_of - cast a member of a structure out to the containing structure
 * @ptr:	the pointer to the member.
 * @type:	the type of the container struct this is embedded in.
 * @member:	the name of the member within the struct.
 *
 */
#define container_of(ptr, type, member) ({				\
        void *__mptr = (void *)(ptr);					\
        BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&	\
                         !__same_type(*(ptr), void),			\
                         "pointer type mismatch in container_of()");	\
        ((type *)(__mptr - offsetof(type, member))); })

这里看出来如果member或者ptr是空指针则返回msg mismatch 而container_of函数本质上是为了初始化struct,并且顺便判断是否是空指针等信息, 其他暂时不深究

rcu_read lock

ipv4_neigh_lookup还看到有一个rcu_read锁,看看这个锁对应了什么 在首行注释可以看到,RCU(Read-Copy Update)是读写更新控制,注释还有一些文档对于想了解的可以看看

1
2
3
4
5
6
7
8
9
/** file: include/linux/rcupdate.h **/
 * Papers:
 * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
 * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
 *
 * For detailed explanation of Read-Copy Update mechanism see -
 *		http://lse.sourceforge.net/locking/rcupdate.html
 *
 */
rcu_read_lock & rcu_read_unlock

请仔细读一遍注释

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/** file: include/linux/rcupdate.h **/
/**
 * rcu_read_lock() - mark the beginning of an RCU read-side critical section
 *
 * When synchronize_rcu() is invoked on one CPU while other CPUs
 * are within RCU read-side critical sections, then the
 * synchronize_rcu() is guaranteed to block until after all the other
 * CPUs exit their critical sections.  Similarly, if call_rcu() is invoked
 * on one CPU while other CPUs are within RCU read-side critical
 * sections, invocation of the corresponding RCU callback is deferred
 * until after the all the other CPUs exit their critical sections.
 *
 * Note, however, that RCU callbacks are permitted to run concurrently
 * with new RCU read-side critical sections.  One way that this can happen
 * is via the following sequence of events: (1) CPU 0 enters an RCU
 * read-side critical section, (2) CPU 1 invokes call_rcu() to register
 * an RCU callback, (3) CPU 0 exits the RCU read-side critical section,
 * (4) CPU 2 enters a RCU read-side critical section, (5) the RCU
 * callback is invoked.  This is legal, because the RCU read-side critical
 * section that was running concurrently with the call_rcu() (and which
 * therefore might be referencing something that the corresponding RCU
 * callback would free up) has completed before the corresponding
 * RCU callback is invoked.
 *
 * RCU read-side critical sections may be nested.  Any deferred actions
 * will be deferred until the outermost RCU read-side critical section
 * completes.
 *
 * You can avoid reading and understanding the next paragraph by
 * following this rule: don't put anything in an rcu_read_lock() RCU
 * read-side critical section that would block in a !PREEMPTION kernel.
 * But if you want the full story, read on!
 *
 * In non-preemptible RCU implementations (pure TREE_RCU and TINY_RCU),
 * it is illegal to block while in an RCU read-side critical section.
 * In preemptible RCU implementations (PREEMPT_RCU) in CONFIG_PREEMPTION
 * kernel builds, RCU read-side critical sections may be preempted,
 * but explicit blocking is illegal.  Finally, in preemptible RCU
 * implementations in real-time (with -rt patchset) kernel builds, RCU
 * read-side critical sections may be preempted and they may also block, but
 * only when acquiring spinlocks that are subject to priority inheritance.
 */
static __always_inline void rcu_read_lock(void)
{
        __rcu_read_lock();
        __acquire(RCU);
        rcu_lock_acquire(&rcu_lock_map);
        RCU_LOCKDEP_WARN(!rcu_is_watching(),
                         "rcu_read_lock() used illegally while idle");
}

/*
 * So where is rcu_write_lock()?  It does not exist, as there is no
 * way for writers to lock out RCU readers.  This is a feature, not
 * a bug -- this property is what provides RCU's performance benefits.
 * Of course, writers must coordinate with each other.  The normal
 * spinlock primitives work well for this, but any other technique may be
 * used as well.  RCU does not care how the writers keep out of each
 * others' way, as long as they do so.
 */

/**
 * rcu_read_unlock() - marks the end of an RCU read-side critical section.
 *
 * In most situations, rcu_read_unlock() is immune from deadlock.
 * However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
 * is responsible for deboosting, which it does via rt_mutex_unlock().
 * Unfortunately, this function acquires the scheduler's runqueue and
 * priority-inheritance spinlocks.  This means that deadlock could result
 * if the caller of rcu_read_unlock() already holds one of these locks or
 * any lock that is ever acquired while holding them.
 *
 * That said, RCU readers are never priority boosted unless they were
 * preempted.  Therefore, one way to avoid deadlock is to make sure
 * that preemption never happens within any RCU read-side critical
 * section whose outermost rcu_read_unlock() is called with one of
 * rt_mutex_unlock()'s locks held.  Such preemption can be avo*ngIf="true;else elseBlock"ided in
 * a number of ways, for example, by invoking preempt_disable() before
 * critical section's outermost rcu_read_lock().
 *
 * Given that the set of locks acquired by rt_mutex_unlock() might change
 * at any time, a somewhat more future-proofed approach is to make sure
 * that that preemption never happens within any RCU read-side critical
 * section whose outermost rcu_read_unlock() is called with irqs disabled.
 * This approach relies on the fact that rt_mutex_unlock() currently only
 * acquires irq-disabled locks.
 *
 * The second of these two approaches is best in most situations,
 * however, the first approach can also be useful, at least to those
 * developers willing to keep abreast of the set of locks acquired by
 * rt_mutex_unlock().
 *
 * See rcu_read_lock() for more information.
 */
static inline void rcu_read_unlock(void)
{
        RCU_LOCKDEP_WARN(!rcu_is_watching(),
                         "rcu_read_unlock() used illegally while idle");
        __release(RCU);
        __rcu_read_unlock();
        rcu_lock_release(&rcu_lock_map); /* Keep acq info for rls diags. */
}
/**
 * rcu_read_lock_bh() - mark the beginning of an RCU-bh critical section
 *
 * This is equivalent of rcu_read_lock(), but also disables softirqs.
 * Note that anything else that disables softirqs can also serve as
 * an RCU read-side critical section.
 *
 * Note that rcu_read_lock_bh() and the matching rcu_read_unlock_bh()
 * must occur in the same context, for example, it is illegal to invoke
 * rcu_read_unlock_bh() from one task if the matching rcu_read_lock_bh()
 * was invoked from some other task.
 */
static inline void rcu_read_lock_bh(void)
{
        local_bh_disable();
        __acquire(RCU_BH);
        rcu_lock_acquire(&rcu_bh_lock_map);
        RCU_LOCKDEP_WARN(!rcu_is_watching(),
                         "rcu_read_lock_bh() used illegally while idle");
}

/**
 * rcu_read_unlock_bh() - marks the end of a softirq-only RCU critical section
 *
 * See rcu_read_lock_bh() for more information.
 */
static inline void rcu_read_unlock_bh(void)
{
        RCU_LOCKDEP_WARN(!rcu_is_watching(),
                         "rcu_read_unlock_bh() used illegally while idle");
        rcu_lock_release(&rcu_bh_lock_map);
        __release(RCU_BH);
        local_bh_enable();
}
看注释
  1. rcu_read_lock首行注释
  • 介绍了synchronize_rcu函数 当synchronize_rcu在某个cpu上调用时候,如果其他cpu有在RCU-read状态的,那么使用这个函数就保证

函数会等待到其他rcu-read状态都退出的时候才会继续进行,在此之前会block

  • call_cpu类似,注册并等到所有cpu的rcu-read状态都退出时候会收到一个callback,来调用cpu

第二行注释

  1. rcu callback 存在这种可能

a)cpu0进入rcu read状态; b)cpu1触发call_rcu, 申请callback; c)cpu0退出rcu read状态; d)cpu2进入rcu read状态; e)rcu callback被触发; 这里的解释是因为read端程序一般是并发的,所以cpu2可能会早于cpu1进入rcu read状态 也可能有这种情况,在rcu callback被调用之前,可能有其他的rcu callback已经被释放 问题: 在别的callback触发(cpu2),这个callback(cpu1)也可能会触发,触发就会进入触发函数,我猜测 是在这里面进行额外的控制,否则和第一行注释冲突

  1. 第三行注释

rcu read可以嵌套,这个比较好理解,嵌套的底层解锁后上层才会解锁

  1. 第四行

可以不看第五行,但是要知道如下规则: 不要在rcu_read_lock()函数后放置任何导致block !PREEMTION kernel的代码段, 我觉得这里 是因为一旦放了阻塞函数,rcu_read_unlock将无法获得预知的效果,而且认为非抢占式系统中这个是多此一举

  1. 第五行

preempt(抢占) 这在内核是一个编译选项CONFIG_PREEMPTION 在非抢占rcu声明情况(pure TREE_RCU and TINY_RCU), 在RCU read端代码做block是不合法的 在抢占式rcu声明情况下,rcu端代码有可能会被抢占,但是显式的block式非法的 在抢占且实时的系统内核中,rcu read只有当需要获取受优先级约束的自旋锁时候会被抢占并block

  1. 第六行

所以没有rcu_write_block(), 因为没有办法去对rcu reader进行解锁,这是一个特性,不是一个bug 这个特性式rcu实现带来的好处 当然写方必须要注意互相协调,spinlock原语可以很好的解决这种情况,但是任何其他的技术也可以被使用 rcu并不关心有多少writer在外面

  1. rcu_read_lock_lockbh相当于互斥增加软中断的部分,而cu_read_lock_sched则增加禁止抢占的部分
spinlock(自旋锁)(https://blog.csdn.net/zhoutaopower/article/details/86598839

自旋锁,锁如其名,当申请锁后,在那自己旋转,等待锁的释放 在使用自旋锁的时候,会禁止内核抢占,并且禁止同cpu上的中断调用,具体可以看看文章

rcu原理探索

rcu的原理是啥,如何做到lock的行为, 从rcu_read_lock函数内容入手

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/** file: include/linux/rcupdate.h **/
/* ifdef CONFIG_PREEMPT_RCU */
void __rcu_read_lock(void);
void __rcu_read_unlock(void);
/* else */
static __always_inline void rcu_read_lock(void)
{
        __rcu_read_lock();
        __acquire(RCU);
        rcu_lock_acquire(&rcu_lock_map);
        RCU_LOCKDEP_WARN(!rcu_is_watching(),
                         "rcu_read_lock() used illegally while idle");
}
static inline void __rcu_read_lock(void)
{
        preempt_disable();//临时关闭抢占模式
}
static inline void rcu_lock_acquire(struct lockdep_map *map)
{
        lock_acquire(map, 0, 0, 2, 0, NULL, _THIS_IP_);
}

static inline void rcu_lock_release(struct lockdep_map *map)
{
        lock_release(map, _THIS_IP_);
}

#ifdef CONFIG_PROVE_RCU

/**
 * RCU_LOCKDEP_WARN - emit lockdep splat if specified condition is met
 * @c: condition to check
 * @s: informative message
 */
#define RCU_LOCKDEP_WARN(c, s)						\
        do {								\
                static bool __section(".data.unlikely") __warned;	\
                if (debug_lockdep_rcu_enabled() && !__warned && (c)) {	\
                        __warned = true;				\
                        lockdep_rcu_suspicious(__FILE__, __LINE__, s);	\
                }							\
        } while (0)
#else /* #ifdef CONFIG_PROVE_RCU */

#define RCU_LOCKDEP_WARN(c, s) do { } while (0 && (c))

/** file: include/linux/lockdep.h:251 **/
/*
 * Acquire a lock.
 *
 * Values for "read":
 *
 *   0: exclusive (write) acquire
 *   1: read-acquire (no recursion allowed)
 *   2: read-acquire with same-instance recursion allowed
 *
 * Values for check:
 *
 *   0: simple checks (freeing, held-at-exit-time, etc.)
 *   1: full validation
 */
extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
                         int trylock, int read, int check,
                         struct lockdep_map *nest_lock, unsigned long ip);

extern void lock_release(struct lockdep_map *lock, unsigned long ip);

/** file include/linux/compiler_types.h **/
/* __CHECKER__ 开启sparse check模式 */
# define __acquire(x)	__context__(x,1)
# define __release(x)	__context__(x,-1)
/* else make没有check参数情况 */
# define __acquire(x)	(void)0
# define __release(x)	(void)0

所以在非抢占模式下,__rcu_read_lock()啥也不干,而抢占模式下,__rcu_read_lock()让程序禁止抢占 而__acquire让RCU置于某一个值方便后面进行控制, 这里看非sparse check的时候是返回0 可以看到__acquire本质上是通过linux库文件lockdep.h的lock_acquire实现对map的控制, lock_release是实现释放 RCU_LOCKDEP_WARN是如果配置了CONFIG_PROVE_RCU参数,则会有warnning相关内容, 否则啥也不干

总结(https://www.cnblogs.com/bbqzsl/p/6796822.html
  • rcu并不是锁,而是一种同步机制,也没有锁竞争
  • rcu update分为removal和reclaimation

removal相当于copy副本,并把读的指针指向它,这样读端可以安全并发 reclaimation相当于回收,当所有的读都读完释放没有引用时候,就释放这些空间 引用博客: 所以典型的RCU update顺序如下三步:

  1. 移去一个数据结构的指针(s),以使后到的readers不能得到它的引用。
  2. 等待所有已经进行的readers完成RCU读侧(端)临界区。
  3. 在某一时刻,没有任何readers保留数据结构的(旧)引用,此时就可以安全地reclaim。

在route.c里面其实是使用了很多库文件rcuupdate.h, compiler_types.h, lockdep.h实现基础的资源控制

ip_neigh_gw4
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/** file: include/net/route.h:387 **/
static inline struct neighbour *ip_neigh_gw4(struct net_device *dev,
                                             __be32 daddr)
{
        struct neighbour *neigh;

        neigh = __ipv4_neigh_lookup_noref(dev, daddr);
        if (unlikely(!neigh))
                neigh = __neigh_create(&arp_tbl, &daddr, dev, false);

        return neigh;
}
/** file: include/net/arp.h:22 **/
static inline u32 arp_hashfn(const void *pkey, const struct net_device *dev, u32 *hash_rnd)
{
        u32 key = *(const u32 *)pkey;
        u32 val = key ^ hash32_ptr(dev);

        return val * hash_rnd[0];
}
#ifdef CONFIG_INET
static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key)
{
        if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
                key = INADDR_ANY;

        return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev);
}
#else
static inline
struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key)
{
        return NULL;
}
#endif
/** file: include/linux/hash.h:93 **/
/* This really should be called fold32_ptr; it does no hashing to speak of. */
static inline u32 hash32_ptr(const void *ptr)
{
        unsigned long val = (unsigned long)ptr;

#if BITS_PER_LONG == 64
        val ^= (val >> 32);
#endif
        return (u32)val;
}

/** file: include/uapi/linux/in.h:284 **/
/* Address to accept any incoming messages. */
#define	INADDR_ANY		((unsigned long int) 0x00000000)

/** file: include/net/neighbour.h:281 **/
static inline struct neighbour *___neigh_lookup_noref(
        struct neigh_table *tbl,
        bool (*key_eq)(const struct neighbour *n, const void *pkey),
        __u32 (*hash)(const void *pkey,
                      const struct net_device *dev,
                      __u32 *hash_rnd),
        const void *pkey,
        struct net_device *dev)
{
        struct neigh_hash_table *nht = rcu_dereference_bh(tbl->nht);
        struct neighbour *n;
        u32 hash_val;

        hash_val = hash(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift);
        for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]);
             n != NULL;
             n = rcu_dereference_bh(n->next)) {
                if (n->dev == dev && key_eq(n, pkey))
                        return n;
        }

        return NULL;
}

static inline struct neighbour *__neigh_lookup_noref(struct neigh_table *tbl,
                                                     const void *pkey,
                                                     struct net_device *dev)
{
        return ___neigh_lookup_noref(tbl, tbl->key_eq, tbl->hash, pkey, dev);
}

/** file: include/linux/rcupdate.h:565 **/
/**
 * rcu_dereference() - fetch RCU-protected pointer for dereferencing
 * @p: The pointer to read, prior to dereferencing
 *
 * This is a simple wrapper around rcu_dereference_check().
 */
#define rcu_dereference(p) rcu_dereference_check(p, 0)

/**
 * rcu_dereference_bh() - fetch an RCU-bh-protected pointer for dereferencing
 * @p: The pointer to read, prior to dereferencing
 *
 * Makes rcu_dereference_check() do the dirty work.
 */
#define rcu_dereference_bh(p) rcu_dereference_bh_check(p, 0)

/**
 * rcu_dereference_check() - rcu_dereference with debug checking
 * @p: The pointer to read, prior to dereferencing
 * @c: The conditions under which the dereference will take place
 *
 * Do an rcu_dereference(), but check that the conditions under which the
 * dereference will take place are correct.  Typically the conditions
 * indicate the various locking conditions that should be held at that
 * point.  The check should return true if the conditions are satisfied.
 * An implicit check for being in an RCU read-side critical section
 * (rcu_read_lock()) is included.
 *
 * For example:
 *
 *	bar = rcu_dereference_check(foo->bar, lockdep_is_held(&foo->lock));
 *
 * could be used to indicate to lockdep that foo->bar may only be dereferenced
 * if either rcu_read_lock() is held, or that the lock required to replace
 * the bar struct at foo->bar is held.
 *
 * Note that the list of conditions may also include indications of when a lock
 * need not be held, for example during initialisation or destruction of the
 * target struct:
 *
 *	bar = rcu_dereference_check(foo->bar, lockdep_is_held(&foo->lock) ||
 *					      atomic_read(&foo->usage) == 0);
 *
 * Inserts memory barriers on architectures that require them
 * (currently only the Alpha), prevents the compiler from refetching
 * (and from merging fetches), and, more importantly, documents exactly
 * which pointers are protected by RCU and checks that the pointer is
 * annotated as __rcu.
 */
#define rcu_dereference_check(p, c) \
        __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)

#define __rcu_dereference_check(p, c, space) \
({ \
        /* Dependency order vs. p above. */ \
        typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
        RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
        rcu_check_sparse(p, space); \
        ((typeof(*p) __force __kernel *)(________p1)); \
})

/** file: include/net/neighbour.h **/
struct neighbour {
        struct neighbour __rcu	*next;
        struct neigh_table	*tbl;
        struct neigh_parms	*parms;
        unsigned long		confirmed;
        unsigned long		updated;
        rwlock_t		lock;
        refcount_t		refcnt;
        unsigned int		arp_queue_len_bytes;
        struct sk_buff_head	arp_queue;
        struct timer_list	timer;
        unsigned long		used;
        atomic_t		probes;
        __u8			flags;
        __u8			nud_state;
        __u8			type;
        __u8			dead;
        u8			protocol;
        seqlock_t		ha_lock;
        unsigned char		ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))] __aligned(8);
        struct hh_cache		hh;
        int			(*output)(struct neighbour *, struct sk_buff *);
        const struct neigh_ops	*ops;
        struct list_head	gc_list;
        struct rcu_head		rcu;
        struct net_device	*dev;
        u8			primary_key[0];
} __randomize_layout;
struct neigh_table {
        int			family;
        unsigned int		entry_size;
        unsigned int		key_len;
        __be16			protocol;
        __u32			(*hash)(const void *pkey,
                                        const struct net_device *dev,
                                        __u32 *hash_rnd);
        bool			(*key_eq)(const struct neighbour *, const void *pkey);
        int			(*constructor)(struct neighbour *);
        int			(*pconstructor)(struct pneigh_entry *);
        void			(*pdestructor)(struct pneigh_entry *);
        void			(*proxy_redo)(struct sk_buff *skb);
        int			(*is_multicast)(const void *pkey);
        bool			(*allow_add)(const struct net_device *dev,
                                             struct netlink_ext_ack *extack);
        char			*id;
        struct neigh_parms	parms;
        struct list_head	parms_list;
        int			gc_interval;
        int			gc_thresh1;
        int			gc_thresh2;
        int			gc_thresh3;
        unsigned long		last_flush;
        struct delayed_work	gc_work;
        struct timer_list       proxy_timer;
        struct sk_buff_head	proxy_queue;
        atomic_t		entries;
        atomic_t		gc_entries;
        struct list_head	gc_list;
        rwlock_t		lock;
        unsigned long		last_rand;
        struct neigh_statistics	__percpu *stats;
        struct neigh_hash_table __rcu *nht;
        struct pneigh_entry	**phash_buckets;
};
static inline bool neigh_key_eq32(const struct neighbour *n, const void *pkey)
{
        return *(const u32 *)n->primary_key == *(const u32 *)pkey;
}
#define NEIGH_NUM_HASH_RND	4

struct neigh_hash_table {
        struct neighbour __rcu	**hash_buckets;
        unsigned int		hash_shift;
        __u32			hash_rnd[NEIGH_NUM_HASH_RND];
        struct rcu_head		rcu;
};

可以看到ip_neigh_gw4入参是设备加一个32位的ip地址网关,通过arp获取设备和地址信息 结果类似于ip r get xxxx的输出,通过5个参数的hash映射和表对比,最终得到目的地址,需要网关,arp信息等等 2个参数到__ipv4_neigh_lookup_noref里面变成5个参数,这个5个参数的意思首先要弄明白

参数名 意义 定义
&arp_tb1 一个arp表,用于hash查询 e x t e rn struct neigh_t able arp_tb1 (具体见代码段最后)
neigh_key_eq32 每个nb存的时候有pk,这个在比对的时候很重要 见代码段最后,是一个bool值,标记neighbour的pk和传入的pk是否相等
hash_rnd 一个随机32位hash种子,用于防止数据泄露和提供冗余能力 Random seed to fold into hash
arp_hashfn 通过关键字, 设备网关,hash种子计算的唯一匹配标识 见上代码段
&key 搜索关键字 见代码段
dev 设备网关号 见代码段

当次查询生成对应的hashfn放到路由表里面,也就是下一次查询的时候,会遍历路由表,查到返回,查不到就写入 create的逻辑也需要了解

Process Management

websites

  • kernel mod ul e programming

kernel module programming