latencytop深度了解你的Linux系统的延迟(4)

这个脚本设计应该是支持进程ID, 但是结果写成了线程ID,属于bug!!!

动手改下吧:

[shell]
$ diff -u latencytap.stp.orig latencytap.stp
--- latencytap.stp.orig 2011-02-17 22:02:40.000000000 +0800
+++ latencytap.stp 2011-03-29 20:43:51.000000000 +0800
@@ -15,7 +15,7 @@
global this_sleep;
global debug = 0;

-function log_event:long (p:long) { return (!traced_pid || traced_pid == p) }
+function log_event:long (p:long) { return (!traced_pid || traced_pid == task_pid(p)) }

#func names from hex addresses
function func_backtrace:string (ips:string)
@@ -50,14 +50,14 @@
# check to see if task is in appropriate state:
# TASK_INTERRUPTIBLE 1
# TASK_UNINTERRUPTIBLE 2
- if (log_event($p->pid) && (s & 3)) {
+ if (log_event($p) && (s & 3)) {
dequeue[$p] = gettimeofday_us();
}
}

probe kernel.trace(“activate_task”) !,
kernel.function(“activate_task”) {
- if (!log_event($p->pid)) next
+ if (!log_event($p)) next

a = gettimeofday_us()
d = dequeue[$p]

#再来一次
$ sudo stap –all-modules /usr/share/doc/systemtap/examples/profiling/latencytap.stp -x $$

[/shell]

这下终于爽了,旧内核用systemtap版本的,新内核用内核版本的,世界和谐!

通过对线上MySQL的诊断发现大部分时间花在mutex锁的竞争上来,我说过了,我会收拾你的,等着瞧!

玩得开心!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/24566.html