Linux kernel - yszheda/wiki GitHub Wiki
References
Interrupt
-
split interrupt handling
启动参数
vDSO
- http://man7.org/linux/man-pages/man7/vdso.7.html
- http://lwn.net/Articles/446528/
- https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_MRG/1.3/html/Realtime_Reference_Guide/sect-Realtime_Reference_Guide-System_calls-Virtual_dynamic_shared_object.html
- http://www.linuxjournal.com/content/creating-vdso-colonels-other-chicken
Address Space Layout Randomisation (ASLR)
- https://en.wikipedia.org/wiki/Address_space_layout_randomization
- How do ASLR and DEP work?
- How ASLR protects Linux systems from buffer overflow attacks
Related issues
zero copy
IO
io_uring
《操作系统与存储:解析Linux内核全新异步IO引擎——io_uring设计与实现》(一)
过往同步IO接口
read
/write
pread
/pwrite
:保证多线程lseek
原子性。执行单个pread
或pwrite
系统调用的成本要低于执行lseek
和read
/write
两个系统调用(当然,相对地,执行实际IO的开销通常要远大于执行系统调用,系统调用的性能优势作用有限)。- Scatter-Gather IO:
readv
/writev
preadv
/pwritev
- 带标志位集合的IO:
preadv2
/pwritev2
能设置本次IO的标志,比如RWF_DSYNC、RWF_HIPRI、RWF_SYNC、RWF_NOWAIT、RWF_APPEND。
异步IO:AIO
AIO的缺陷
- AIO不支持缓存操作 -> 写文件性能差
- 仅支持direct IO。不能借助文件系统缓存来缓存当前的IO请求,还存在size对齐(直接操作磁盘,所有写入内存块数量必须是文件系统块大小的倍数,而且要与内存页大小对齐。)等
- 仍然可能被阻塞。语义不完备。
- 拷贝开销大。
- API不友好。每一个IO至少需要两次系统调用才能完成(submit和wait-for-completion)
- 系统调用开销大。
io_uring的设计
解决“拷贝开销大”的问题
kernel space与user space共享ring buffer (producer-consumer):
- 提交、完成请求时节省应用和内核之间的内存拷贝
- 使用 SQPOLL 高级特性时,应用程序无需调用系统调用
- 无锁操作,用memory ordering实现同步,通过几个简单的头尾指针的移动就可以实现快速交互。
io_uring的关键流程
#include <linux/io_uring.h>
int io_uring_setup(u32 entries, struct io_uring_params *p);
int io_uring_enter(unsigned int fd, unsigned int to_submit,
unsigned int min_complete, unsigned int flags,
sigset_t *sig);
int io_uring_register(unsigned int fd, unsigned int opcode,
void *arg, unsigned int nr_args);
《操作系统与存储:解析Linux内核全新异步IO引擎——io_uring设计与实现》(二)
高级特性
Fixed Files模式
Fixed Buffers模式
Polled IO模式
System call
exec
- Please explain exec() function and its family
- source code for execve() and fork() [closed]
- source code for execve()
brk
- [!] What does brk( ) system call do?
- brk() - Unix, Linux System Call
- Linux中brk()系统调用,sbrk(),mmap(),malloc(),calloc()的异同
mmap
/ mmap2
madvise
futex
epoll
sched_yield
- https://linux.die.net/man/2/sched_yield
- Behavior of sched_yield
- What does sched_yield do in this case?
- sched_yield()函数 高级进程管理
- hadoop集群System Cpu消耗过高问题分析 by 杂货店店长
- Alternative to sched_yield()
sleep
memory barrier
module
- TQ2440加载Hello world驱动模块
- ubuntu/debian 模块加载方式
- Howto: Build Linux Kernel Module Against Installed Kernel w/o Full Kernel Source Tree
- Building a Linux kernel module without the exact kernel headers
Module.symvers
__aeabi_unwind_cpp_pr0
DRM
- https://en.wikipedia.org/wiki/Direct_Rendering_Manager
- Linux DRM KMS 驱动简介
- Linux DRM Graphic 显示简单介绍
- Linux graphic subsytem(1)_概述
- Linux graphic subsystem(2)_DRI介绍
realtime
PREEMPT_RT
- [!] A realtime preemption overview
- https://rt.wiki.kernel.org/index.php/Frequently_Asked_Questions
- https://rt.wiki.kernel.org/index.php/Publications
multi-cores
clean linux kernel
Ubuntu
Trouble shooting
error, forbidden warning
- 关闭error, forbidden warning:
kernel/scripts/gcc-wrapper.py
中注释掉interpret_warning(line)