1. 首 届 中 国 e B P F 研 讨 会
www.ebpftravel.com
框架开发经验分享
杨润青@华为
Linux Tracing System浅析
&
2. 首 届 中 国 e B P F 研 讨 会
Linux Tracing System浅析
“Kprobe,Tracepoint,Linux Auditing
subsystem(auditd),SystemTap,LTTng,perf,trace-
cmd,eBPF,bpftrace,BCC …“
• 这些专业词语是什么意思?
• 它们之间有什么关系?
• 每种tracing技术的优缺点是什么?
• 为什么eBPF会从中脱颖而出,近年来得到广泛关注?
3. 首 届 中 国 e B P F 研 讨 会
* Figure inspired by https://static.sched.com/hosted_files/osseu19/5f/unified-tracing-platform-oss-eu-2019.pdf
• 数据源:提供数据的来源
• Tracing 框架:负责对接数据源,采集解析发送数据,并对用户态提供接口
• 前端工具/库: 对接Tracing框架,直接与用户交互,负责采集配置和数据分析
Linux Tracing System浅析
5. 首 届 中 国 e B P F 研 讨 会
* Figure inspired by https://static.sched.com/hosted_files/osseu19/5f/unified-tracing-platform-oss-eu-2019.pdf
• 数据源:提供数据的来源
• Tracing 框架:负责对接数据源,采集解析发送数据,并对用户态提供接口
• 前端工具/库: 对接Tracing框架,直接与用户交互,负责采集配置和数据分析
Linux Tracing System浅析
6. 首 届 中 国 e B P F 研 讨 会
Linux Tracing System 发展历程
• 1999年,LTT (Linux Trace Toolkit)发布 (没有被引入内核)
• 2004年4月,Linux Auditing subsystem(auditd)被引入内核2.6.6-rc1
通过修改内核代码,添加工具专用的数据源
Linux Auditing Subsystem通过在syscall和文件操作等内核源代码上
插入自定义的hook函数(通常以audit_开头)来实现syscall和文件行为
的监控
内核源码:2.6.6-rc1
7. 首 届 中 国 e B P F 研 讨 会
Linux Tracing System 发展历程
• 1999年,LTT (Linux Trace Toolkit)发布
• 2004年4月,Linux Auditing subsystem(auditd)被引入内核2.6.6-rc1
通过修改内核代码,添加工具专用的数据源
Tracing框架和数据源解耦,数据源由专用演进为通用
• 2005年4月,动态探针技术 Kprobe被引入内核(v2.6.11.7)
• 2008年10月 ,静态探针技术 Tracepoint 被引入内核(v2.6.28)
However, statically declaring an instrumentation site for dynamic
activation typically incurs a non-zero performance overhead due to the
test and branch required to skip the instrumentation call.
性能差
强耦合
I identified the need to decouple instrumentation from the tracer. The
idea is that adding instrumentation to the Linux kernel is a task better
performed by contributors and experts of each individual kernel subsystem.
—— LTTng和Tracepoint的作者,Mathieu Desnoyers的2009年毕业论文