Unit 4 kernel-level profiling
内核级别的调优
本章的主要目标是监控,监控工具分别是OProfile,System Tap
OProfile需要特殊硬件的支持而且安装和配置也很麻烦;
System Tap 也是监控工具;
目标是监控,监控的内容是由内核研究人员来分析的;
本章只学习system Tap
对system Tap的objects:
Configure development and production machines for system Tap
Compile a kernel module when given a system Tap scripts
译文:在开发和生产环境中配置system Tap
1.
System Tap
Can profile
.Any system call exposed by the kprobes subsystem
.Captures 100% of events
Compiles a script into a kernel module
.scripting language is similar to awk in style
.scripts are highly portable
Production machines usually do not have compilers
.on development machine: compile script into kernel module
.on production machines: deploy kernel module
.ensure consistent kernel releases on devel and prod
Modinfo modulename | grep vergamic
译文:
编译脚本到内核模块
脚本语言类似awk格式
脚本可移植性比较高
生产环境通常没有编译器
在开发:编译脚本到内核模块
2.
Required packages
On the development machine
Systemtap
Kernel-debuginfo master match running kernel
Kernel-devel master match running kernel
Gcc
On the production machine
Systemtap-runtime
译文:以上介绍了需要安装的软件包
3.
Systemtap scripts
Scripts use dotted notation and support wildcards
Probe kernel.function(“foo”)
Probe kernel.function(“*”).return
See /usr/share/doc/systemtap-*/examples
Include functions
/usr/share/systemtap/tapset
4.1
The stap command
Use on the development machine
Works in up to five passes
.parse script
.resolve symbols against matching kernel-debuginfo
.translate into C
.build kernel module
.load module,run,and unload(requires root privileges!)
Example : get a list of all kernel functions
Stap –p2 –e ‘probe kernel.function(“*”) {} ’ | sort –u
译文:在development machine上
分析脚本—匹配ker-debuginfo的包—翻译成C语言—建立到内核模块—加载模块
4.2
The staprun command
Use on production machines
No compiler needed
Works in a single pass
Load module,run,and unload(requires root privileges)
Example: run a module
Staprun /path/to/module.ko