Linux kernel - yszheda/wiki GitHub Wiki

References

Interrupt

启动参数

vDSO

Address Space Layout Randomisation (ASLR)

Related issues

zero copy

IO

io_uring


《操作系统与存储:解析Linux内核全新异步IO引擎——io_uring设计与实现》(一)

过往同步IO接口

  • read/write
  • pread/pwrite:保证多线程lseek原子性。执行单个preadpwrite系统调用的成本要低于执行lseekread/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

brk

mmap / mmap2

madvise

futex

epoll

sched_yield

sleep

memory barrier

module

Module.symvers

__aeabi_unwind_cpp_pr0

DRM

realtime

PREEMPT_RT

multi-cores

clean linux kernel

Ubuntu

Trouble shooting

error, forbidden warning