Re: nginx systemtap使用

1,751 views
Skip to first unread message

agentzh

unread,
Oct 13, 2012, 1:50:23 PM10/13/12
to Wenhua Zhang, openresty
Hello!

2012/10/13 Wenhua Zhang:
> Hi 章老师,
> 您好,
> 之前在微博上看到有些您用flamegraph画的“火焰图”,例如:http://agentzh.org/misc/nginx/lua-resty-redis-flamegraph.svg
> 目前也想用systemtap进行nginx的时间消耗分析,并用flameGraph画出相应的火焰图。
> 能否提供一下您之前画图使用的systemtap脚本作为参考?谢谢
>

我生成纯用户态的火焰图所使用的 systemtap 脚本 a.stp 的源码如下:

global s;
global quit = 0;

probe timer.profile {
if (pid() == target()) {
if (quit) {
foreach (i in s-) {
print_ustack(i);
printf("\t%d\n", @count(s[i]));
}
exit()
} else {
s[ubacktrace()] <<< 1;
}
}
}

probe timer.s(20) {
quit = 1
}

运行这个脚本的一条典型命令行是:

stap --ldd -d /path/to/nginx/sbin/nginx \
-d /path/to/luajit/lib/libluajit-5.1.so.2.0.0 \
--all-modules -D MAXMAPENTRIES=20240 \
-D MAXACTION=20000 \
-D MAXTRACE=100 \
-D MAXSTRINGLEN=4096 \
-D MAXBACKTRACE=100 -x 5857 a.stp > a.out

假设这里测量的 nginx worker 进程的 pid 是 5857. 大约过 20 多秒之后,该命令会退出并生成 a.out
输出文件,然后从此文件生成火焰图文件 a.svg:

perl stackcollapse-stap.pl a.out > a.out2
perl flamegraph.pl a.out2 > a.svg

这里使用的两个 perl 脚本(.pl 文件)来自 Brendan Gregg 放在 GitHub 上的 flamegraph 项目:

https://github.com/brendangregg/FlameGraph

值得提醒的是,在运行 systemtap 脚本期间,被采样的 nginx worker 进程(或者其他任意进程)须是足够繁忙的,否则
systemtap 脚本可能会长时间不退出。一般我在上面第一步运行 stap 之前会先用 ab 工具对 nginx
服务器保持压力,至少得持续到 stap 命令自动退出以后。

当然,利用这种方法也可以绘制核心态 + 用户态的更为完整的火焰图,例如这个例子:

http://agentzh.org/misc/nginx/lua-resty-redis-flamegraph4.svg

这样可以把 kernel 空间中的调用栈也给一起采样了,从而可以得到整个“软件栈”(software stack)的全景图。

此时需要换用类似下面这样的 systemtap 脚本:

global bt;
global quit = 0

probe timer.profile {
if (pid() == target()) {
if (!quit) {
bt[backtrace(), ubacktrace()] <<< 1

} else {

foreach ([sys, usr] in bt- limit 1000) {
print_stack(sys)
print_ustack(usr)
printf("\t%d\n", @count(bt[sys, usr]))
}
exit()
}
}
}

probe timer.s(20) {
quit = 1
}

值得一提的是,建议使用最新的 SystemTap 2.0 发布:

http://sourceware.org/systemtap/ftp/releases/

或者干脆直接使用 systemtap 的 git master HEAD:

git clone git://sourceware.org/git/systemtap.git

从源码编译 systemtap 是推荐的做法。我一般使用类似下面这样的命令构造之:

./configure --prefix=/opt/systemtap --disable-docs
--disable-publican --disable-refdocs && make -j8
sudo make install

PATH=/opt/systemtap/bin:$PATH
export PATH

>
> 目前对Brendan Gregg在博客上写的systemtap的参数不是很理解:
> stap -s 32 -D MAXTRACE=100 -D MAXSTRINGLEN=4096 -D MAXMAPENTRIES=10240 \
> -D MAXACTION=10000 -D STP_OVERLOAD_THRESHOLD=5000000000 --all-modules \
> -ve 'global s; probe timer.profile { s[backtrace()] <<< 1; }
> probe end { foreach (i in s+) { print_stack(i);
> printf("\t%d\n", @count(s[i])); } } probe timer.s(60) { exit(); }' \
> > out.stap-stacks

Brendan 使用的各个 stap 命令行参数的具体含义可以参见 stap -h 的输出。

特别地,其中 -D 选项定义的那些宏的值是为了放宽 systemtap 内部的很多限制。例如,MAXTRACE
宏用于控制调用栈的深度,默认只有 20. 所以当实际的调用栈深度超过 20
时(事实上,经常会超时),但会发生调用栈信息的自动截断,从而影响火焰图的绘制。

其他宏的具体含义可以参考 systemtap 邮件列表中的相关讨论以及 systemtap 自身的源码实现。

Brendan 在这里给出的 systemtap one-liner 是单独对 Linux kernel 进行采样,即得到纯核心态的火焰图 :)

Best regards,
-agentzh

P.S. 同时抄送给 openresty 中文邮件列表:https://groups.google.com/group/openresty
这样其他朋友也可以从我们这里的讨论中获益 :)

agentzh

unread,
Oct 14, 2012, 1:21:35 AM10/14/12
to Wenhua Zhang, openresty
Hello!

2012/10/13 Wenhua Zhang:
> 您好,我在使用您的systemtap脚本时,出现了如下错误:
> Pass 4: compiled C into
> "stap_9bd58f613f10f902accc4171ced91dd4_5524.ko" in
> 7950usr/570sys/10924real ms.
> ERROR: global variable 's' allocation failed
> 是不是跟systemtap的版本有关系?
>

这是因为你的机器内存比较小,而我给出的 stap 命令中把 MAXMAPENTRIES 设得非常大,即 20240. 这个宏直接控制
systemtap 语言中的关联数组类型的变量所分配的空间大小。

20240 这个数值在我的 20GB
内存的笔记本上没有问题,但在你的机器上就可能内存溢出了。你可以按照你的机器配置,将这个配置项设得小一些,比如像 Brendan Gregg
的示范命令中那样置为 10240,或者更小一些。

> ]# stap --version
> Systemtap translator/driver (version 1.6/0.152 non-git sources)

我在上一封邮件中指出了,建议使用 SystemTap 2.0 以上版本。较老版本的 bug 比较多。

>
> 在使用源码编译时,出现如下错误:
> configure: error: elfutils, libdw too old, need 0.148+
>
[...]
>
> 从网上查了一下,elfutils在centos5上的最高版本是0.137.
>

你可以考虑从源码编译一个最新版本的 elfutils,CentOS 5 上的包版本都很古老 :)

Best regards,
-agentzh

P.S. 再次抄送 openresty 中文邮件列表:https://groups.google.com/group/openresty
也建议你直接在那里讨论这样的问题,这样可以有更多人参与 ;)

Wenhua Zhang

unread,
Oct 15, 2012, 1:26:41 AM10/15/12
to agentzh, open...@googlegroups.com
Hi ,
我重新编译了sytemtap 2.0,然后运行以下命令:
/opt/systemtap/bin/stap --ldd -d /usr/sbin/nginx --all-modules -D
MAXMAPENTRIES=5120 -D MAXACTION=20000 -D MAXTRACE=100 -D
MAXSTRINGLEN=4096 -D MAXBACKTRACE=100 -x 16333 a.stp > a.out
WARNING: missing unwind/symbol data for module 'uprobes'
ERROR: Build-id mismatch: "kernel" vs. "vmlinux" byte 1 (0x2d vs 0x33)
address 0xffffffff81508170 rc 0
WARNING: /opt/systemtap/bin/staprun exited with status: 1
Pass 5: run failed. Try again with another '--vp 00001' option.

针对“ERROR: Build-id mismatch: "kernel" vs. "vmlinux" byte 1 (0x2d vs
0x33) address 0xffffffff81508170 rc
0”的错误,参考“http://gekben.gitcd.com/blog/2012/08/16/install-systemtap-on-suse/”,把文件systemtap/runtime/sym.c中的if
(rc || (theory != practice))写成: if (0 && (rc || (theory !=
practice))),然后重新编译:
# /opt/systemtap/bin/stap --ldd -d /usr/sbin/nginx --all-modules -D
MAXMAPENTRIES=5120 -D MAXACTION=2000 -D MAXTRACE=50 -D
MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 16333 a.stp
WARNING: missing unwind/symbol data for module 'uprobes'

但是很长时间没有结果。
请问这是什么原因?

agentzh

unread,
Oct 15, 2012, 1:44:41 AM10/15/12
to Wenhua Zhang, open...@googlegroups.com
Hello!

2012/10/14 Wenhua Zhang:


> # /opt/systemtap/bin/stap --ldd -d /usr/sbin/nginx --all-modules -D
> MAXMAPENTRIES=5120 -D MAXACTION=2000 -D MAXTRACE=50 -D
> MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 16333 a.stp
> WARNING: missing unwind/symbol data for module 'uprobes'
>
> 但是很长时间没有结果。
> 请问这是什么原因?
>

你确认你指定的那个 nginx worker 是足够繁忙的么?如果你的 nginx worker 足够繁忙,当会在 20
秒之后自动退出。我在测试时都是只启用一个 nginx worker 进程,然后用 ab 持续施加压力,直至 stap 命令退出。

Best regards,
-agentzh

agentzh

unread,
Oct 15, 2012, 2:03:18 AM10/15/12
to Wenhua Zhang, open...@googlegroups.com
Hello!

2012/10/14 agentzh <age...@gmail.com>:


>
> 你确认你指定的那个 nginx worker 是足够繁忙的么?如果你的 nginx worker 足够繁忙,当会在 20
> 秒之后自动退出。我在测试时都是只启用一个 nginx worker 进程,然后用 ab 持续施加压力,直至 stap 命令退出。
>

当然,SystemTap 的启动时间也需要考虑进去,特别是首次启动的时间。启动时间是不算在我说的 20 秒之内的。即使在我的
ThinkPad W530 系统上,首次启动也需要 10 多秒的时间(随后再启动就是 1 秒以内了)。

其实我一直想好好优化一下 SystemTap 的启动时间,这是比 JVM 的启动还要夸张啊。。。

Best regards,
-agentzh

Wenhua Zhang

unread,
Oct 15, 2012, 3:56:44 AM10/15/12
to agentzh, open...@googlegroups.com
Hi 章老师,
运行stap时,使用另外3台机器运行ab加压,nginx启动了3个worker进程,“21954”为其中一个worker的PID。

# /opt/systemtap/bin/stap --ldd -d /usr/sbin/nginx --all-modules -D
MAXMAPENTRIES=5120 -D MAXACTION=2000 -D MAXTRACE=50 -D

MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 21954 a.stp --vp 00001 >
a.out
Pass 5: starting run.
WARNING: Missing unwind data for module, rerun with 'stap -d
stap_32956d49a7514625e7674714a68170c7_4108'
WARNING: _stp_read_address failed to access memory location
ERROR: MAXACTION exceeded near operator '{' at
/opt/systemtap/share/systemtap/tapset/linux/ucontext-symbols.stp:113:28
WARNING: Number of errors: 1, skipped probes: 24


WARNING: /opt/systemtap/bin/staprun exited with status: 1

Pass 5: run completed in 10usr/90sys/20437real ms.


Pass 5: run failed. Try again with another '--vp 00001' option.

生成的SVG文件有很多“_init”,见附件。
请问这种情况是否正常?

另外,之前遇到的错误“ERROR: Build-id mismatch: "kernel" vs. "vmlinux" byte 1
(0x2d vs 0x33)
address 0xffffffff81508170 rc 0”,把文件systemtap/runtime/sym.c中的if(rc ||


(theory != practice))写成: if (0 && (rc || (theory

!=practice))),然后重新编译,请问这种解决方法是否会影响systemtap的运行?

运行的机器的环境如下:
# uname -r
2.6.32-279.1.1.el6.x86_64

编译安装了systemtap 2.0:


./configure --prefix=/opt/systemtap --disable-docs --disable-publican
--disable-refdocs

make
make install

谢谢。

生成附件2的命令为(修改了MAXACTION,由2000调整为20000):


# /opt/systemtap/bin/stap --ldd -d /usr/sbin/nginx --all-modules -D

MAXMAPENTRIES=5120 -D MAXACTION=20000 -D MAXTRACE=50 -D
MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 21954 a.stp --vp 00001 >
a.out


WARNING: missing unwind/symbol data for module 'uprobes'

Pass 5: starting run.
WARNING: Missing unwind data for module, rerun with 'stap -d
stap_3f263a8ae4e7ab56f20fd2d7a1b0adae_4371'
WARNING: _stp_read_address failed to access memory location
WARNING: Number of errors: 0, skipped probes: 99
Pass 5: run completed in 0usr/90sys/20488real ms.

nginx-agentzh-stap.svg
nginx-agentzh-stap-2.svg

agentzh

unread,
Oct 15, 2012, 1:56:49 PM10/15/12
to Wenhua Zhang, open...@googlegroups.com
Hello!

2012/10/15 Wenhua Zhang:


> Pass 5: starting run.
> WARNING: Missing unwind data for module, rerun with 'stap -d
> stap_32956d49a7514625e7674714a68170c7_4108'
> WARNING: _stp_read_address failed to access memory location
> ERROR: MAXACTION exceeded near operator '{' at
> /opt/systemtap/share/systemtap/tapset/linux/ucontext-symbols.stp:113:28
> WARNING: Number of errors: 1, skipped probes: 24
> WARNING: /opt/systemtap/bin/staprun exited with status: 1
> Pass 5: run completed in 10usr/90sys/20437real ms.
> Pass 5: run failed. Try again with another '--vp 00001' option.
>
> 生成的SVG文件有很多“_init”,见附件。
> 请问这种情况是否正常?

你的 SVG 看起来完全不正确。你的 systemtap 貌似未能成功获得用户态调用栈。

>
> 另外,之前遇到的错误“ERROR: Build-id mismatch: "kernel" vs. "vmlinux" byte 1
> (0x2d vs 0x33)
> address 0xffffffff81508170 rc 0”,把文件systemtap/runtime/sym.c中的if(rc ||
> (theory != practice))写成: if (0 && (rc || (theory
> !=practice))),然后重新编译,请问这种解决方法是否会影响systemtap的运行?
>

你这里把兼容性检查代码彻底移除,貌似并不是一个好主意 :) 你可以尝试移除 $HOME/.systemtap ?

我建议你先直接尝试系统自带的 systemtap 包?版本老点就老点吧,呵呵。基本能工作就好了。

另外,MAXACTION 确实应当设置得大一些 ;)

Best regards,
-agentzh

Wenhua Zhang

unread,
Oct 15, 2012, 9:21:14 PM10/15/12
to agentzh, open...@googlegroups.com
Hi 章老师,
谢谢您的回复。
我之前尝试了用系统自带的systemtap,但仍然出现问题:
#stap --ldd -d /usr/sbin/nginx --all-modules -D MAXMAPENTRIES=5120 -D

MAXACTION=20000 -D MAXTRACE=50 -D MAXSTRINGLEN=1024 -D
MAXBACKTRACE=100 -x 21954 a.stp --vp 00001 > a.out
Pass 5: starting run.

ERROR: Build-id mismatch: "kernel" vs. "vmlinux" byte 1 (0x2d vs 0x33)
address 0xffffffff81508170 rc 0
WARNING: /usr/bin/staprun exited with status: 1
Pass 5: run completed in 0usr/50sys/84real ms.

Pass 5: run failed. Try again with another '--vp 00001' option.

# which stap
/usr/bin/stap

# stap --version
Systemtap translator/driver (version 1.7/0.152 non-git sources)
Copyright (C) 2005-2012 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
enabled features: AVAHI LIBRPM LIBSQLITE3 NSS BOOST_SHARED_PTR
TR1_UNORDERED_MAP NLS

是否和我装的debug包有关系?
# rpm -qa | grep `uname -r`
kernel-2.6.32-279.1.1.el6.x86_64
kernel-debuginfo-common-x86_64-2.6.32-279.1.1.el6.x86_64
kernel-headers-2.6.32-279.1.1.el6.x86_64
kernel-debuginfo-2.6.32-279.1.1.el6.x86_64
kernel-devel-2.6.32-279.1.1.el6.x86_64
perf-2.6.32-279.1.1.el6.x86_64

”Build-id mismatch“这个问题在网上也有人提出,但没有找到好的解决办法。
谢谢。

Best Wishes,
Wenhua

Wenhua Zhang

unread,
Oct 16, 2012, 1:07:57 AM10/16/12
to agentzh, open...@googlegroups.com
Hi 章老师,
之前的"build-id mismatch"的问题解决了,是因为内核和安装的debuginfo包的build-id不同引起的。
重新安装debuginfo包之后问题不再出现。
#eu-readelf -n /boot/vmlinuz-2.6.32-279.1.1.el6.x86_64 | grep "Build ID"
Build ID: 8c33eab01b34cdde6dbb46ebcb2ae3c9929c836d
#eu-readelf -n /usr/lib/debug/lib/modules/2.6.32-279.1.1.el6.x86_64/vmlinux
| grep "Build ID"
Build ID: 8c33eab01b34cdde6dbb46ebcb2ae3c9929c836d

之后重新运行stap,第一次总是出错:
# /opt/systemtap/bin/stap --ldd -d /usr/sbin/nginx --all-modules -D
MAXMAPENTRIES=5120 -D MAXACTION=20000 -D MAXTRACE=50 -D
MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 21954 a.stp --vp 00001 >
a.out
Pass 5: starting run.
ERROR: error allocating hash
ERROR: global variable 's' allocation failed
WARNING: /opt/systemtap/bin/staprun exited with status: 1
Pass 5: run completed in 0usr/70sys/683real ms.
Pass 5: run failed. Try again with another '--vp 00001' option.

# /opt/systemtap/bin/stap --ldd -d /usr/sbin/nginx --all-modules -D
MAXMAPENTRIES=5120 -D MAXACTION=20000 -D MAXTRACE=50 -D
MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 21954 a.stp --vp 00001 >
a.out
Pass 5: starting run.
WARNING: Missing unwind data for module, rerun with 'stap -d
stap_b4701e846c78c93e13b217f69be297e_18846'
WARNING: _stp_read_address failed to access memory location
WARNING: Number of errors: 0, skipped probes: 99
Pass 5: run completed in 0usr/90sys/20481real ms.

请问上面的一些警告信息是否会影响stap的运行?
谢谢。


2012/10/16 Wenhua Zhang <shiz...@gmail.com>:
nginx-agentzh-stap-4.svg

agentzh

unread,
Oct 16, 2012, 3:00:23 PM10/16/12
to Wenhua Zhang, open...@googlegroups.com
Hello!

On Mon, Oct 15, 2012 at 10:07 PM, Wenhua Zhang wrote:
> 之前的"build-id mismatch"的问题解决了,是因为内核和安装的debuginfo包的build-id不同引起的。
> 重新安装debuginfo包之后问题不再出现。
> #eu-readelf -n /boot/vmlinuz-2.6.32-279.1.1.el6.x86_64 | grep "Build ID"
> Build ID: 8c33eab01b34cdde6dbb46ebcb2ae3c9929c836d
> #eu-readelf -n /usr/lib/debug/lib/modules/2.6.32-279.1.1.el6.x86_64/vmlinux
> | grep "Build ID"
> Build ID: 8c33eab01b34cdde6dbb46ebcb2ae3c9929c836d
>

赞啊,解决了就好 :)

> 之后重新运行stap,第一次总是出错:
> # /opt/systemtap/bin/stap --ldd -d /usr/sbin/nginx --all-modules -D
> MAXMAPENTRIES=5120 -D MAXACTION=20000 -D MAXTRACE=50 -D
> MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 21954 a.stp --vp 00001 >
> a.out
> Pass 5: starting run.
> ERROR: error allocating hash
> ERROR: global variable 's' allocation failed
> WARNING: /opt/systemtap/bin/staprun exited with status: 1
> Pass 5: run completed in 0usr/70sys/683real ms.
> Pass 5: run failed. Try again with another '--vp 00001' option.
>

这个错误还是说你设置的 MAXMAPENTRIES 相对于你的系统内存设置过大了。

> # /opt/systemtap/bin/stap --ldd -d /usr/sbin/nginx --all-modules -D
> MAXMAPENTRIES=5120 -D MAXACTION=20000 -D MAXTRACE=50 -D
> MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 21954 a.stp --vp 00001 >
> a.out
> Pass 5: starting run.
> WARNING: Missing unwind data for module, rerun with 'stap -d
> stap_b4701e846c78c93e13b217f69be297e_18846'
> WARNING: _stp_read_address failed to access memory location
> WARNING: Number of errors: 0, skipped probes: 99
> Pass 5: run completed in 0usr/90sys/20481real ms.
>
> 请问上面的一些警告信息是否会影响stap的运行?

这些错误无所谓了,只要你能生成靠谱的火焰图就好 :)

看来 SystemTap 还是在 Fedora 上最少折腾,呵呵。

Best regards,
-agentzh

azure wang

unread,
Oct 17, 2012, 11:53:38 PM10/17/12
to open...@googlegroups.com

我是从新编译内核搞定的。但是还是不支持用户空间的侦测。需要给内核打补丁,建议用红帽系列。

在 2012-10-18 上午11:49, <pengl...@gmail.com>写道:
在ubuntu上执行
stap --ldd -d /usr/local/openresty/nginx/sbin/nginx --all-modules -D MAXMAPENTRIES=2024  -D MAXACTION=20000    -D MAXTRACE=100  -D MAXSTRINGLEN=4096   -D MAXBACKTRACE=100 -x 2635 a.stp > a.out
提示错误:
WARNING: missing unwind/symbol data for module 'kernel'
user-space facilities not available without kernel CONFIG_UTRACE
Pass 4: compilation failed.  Try again with another '--vp 0001' option.

这个是怎么回事呢,有朋友碰到过么

在 2012年10月14日星期日UTC+8上午1时50分24秒,agentzh写道:

agentzh

unread,
Oct 17, 2012, 11:54:06 PM10/17/12
to open...@googlegroups.com
Hello!

2012/10/17 <pengl...@gmail.com>:


> 在ubuntu上执行
> stap --ldd -d /usr/local/openresty/nginx/sbin/nginx --all-modules -D MAXMAPENTRIES=2024 -D MAXACTION=20000 -D MAXTRACE=100 -D MAXSTRINGLEN=4096 -D MAXBACKTRACE=100 -x 2635 a.stp > a.out
> 提示错误:
> WARNING: missing unwind/symbol data for module 'kernel'
> user-space facilities not available without kernel CONFIG_UTRACE

这个错误是说你的 kernel 没有提供 utrace/uprobes 用户态支持。

Ubuntu 自带的 kernel 一般比较老,并且也没有应用 utrace 补丁。一般有两种解法:

1. 自己给 Ubuntu 自带的老 kernel 应用 utrace 补丁,并重新编译它。chaoslawful 老师写过一篇博客分享过
ubuntu 上的步骤:http://chaoslawful.iteye.com/blog/1463564

2. 将 kernel 升级到官方最新的 3.5 或以上的版本。最新的 kernel 默认包含了 uprobes 机制,不再需要 utrace 补丁了。

Best regards,
-agentzh

Wenhua Zhang

unread,
Oct 19, 2012, 6:32:34 AM10/19/12
to open...@googlegroups.com
Hi,
当执行
/opt/systemtap/bin/stap --ldd -d /usr/local/nginx/sbin/nginx

--all-modules -D MAXMAPENTRIES=5120 -D MAXACTION=20000 -D
MAXTRACE=50 -D MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 25017 a.stp
--vp 00001 > a.out
时出现如下错误:

WARNING: missing unwind/symbol data for module
'stap_97bdcbebec34bca89d728c7b361aa64_24788'
WARNING: missing unwind/symbol data for module 'uprobes'
Pass 5: starting run.
ERROR: probe timer.profile registration error (rc -16)

之前并没有遇到过,请问大家遇到过这种问题吗?这是什么原因引起的呢?
谢谢

agentzh

unread,
Oct 19, 2012, 1:30:58 PM10/19/12
to open...@googlegroups.com
Hello!

2012/10/19 Wenhua Zhang:


> 当执行
> /opt/systemtap/bin/stap --ldd -d /usr/local/nginx/sbin/nginx
> --all-modules -D MAXMAPENTRIES=5120 -D MAXACTION=20000 -D
> MAXTRACE=50 -D MAXSTRINGLEN=1024 -D MAXBACKTRACE=100 -x 25017 a.stp
> --vp 00001 > a.out
> 时出现如下错误:
> WARNING: missing unwind/symbol data for module
> 'stap_97bdcbebec34bca89d728c7b361aa64_24788'
> WARNING: missing unwind/symbol data for module 'uprobes'
> Pass 5: starting run.
> ERROR: probe timer.profile registration error (rc -16)
>
> 之前并没有遇到过,请问大家遇到过这种问题吗?这是什么原因引起的呢?

建议加入 systemtap 官方邮件列表,并在那里报告这样的问题:

http://sourceware.org/systemtap/getinvolved.html

或者直接在其 Bugzilla 系统中建 ticket:

http://sources.redhat.com/bugzilla/enter_bug.cgi?product=systemtap

Best regards,
-agentzh

Wenhua Zhang

unread,
Oct 19, 2012, 11:25:56 PM10/19/12
to open...@googlegroups.com
好的,谢谢。

Wenhua Zhang

unread,
Oct 20, 2012, 1:23:34 AM10/20/12
to Yichun Zhang, open...@googlegroups.com
Hi,
找到原因了。
猜测是因为安装nginx的时候没有安装debuginfo的包,所以导致stap运行的时候找不到symbol。
现在安装了使用rpm打包时产生的debuginfo的包,貌似正常了。

谢谢。

在 2012年10月20日 下午1:11,Wenhua Zhang <shiz...@gmail.com> 写道:
> Hi ,
> 发现产生的svg文件中有很多_init函数,并没有包含nginx运行时的函数。
> 之后在编译nginx的时候已经添加了--with-debug,但是编译的时候不带其它模块时,可以产生正常的火焰图,
> 编译的时候添加其它模块时,产生的火焰图还是包含很多_init。
> 请问您之前遇到过类似问题吗?


> 谢谢
>
>
> 在 2012年10月18日 上午11:54,agentzh <age...@gmail.com> 写道:

Wenhua Zhang

unread,
Oct 20, 2012, 1:11:56 AM10/20/12
to Yichun Zhang, open...@googlegroups.com
Hi ,
发现产生的svg文件中有很多_init函数,并没有包含nginx运行时的函数。
之后在编译nginx的时候已经添加了--with-debug,但是编译的时候不带其它模块时,可以产生正常的火焰图,
编译的时候添加其它模块时,产生的火焰图还是包含很多_init。
请问您之前遇到过类似问题吗?
谢谢


在 2012年10月18日 上午11:54,agentzh <age...@gmail.com> 写道:

俞勇

unread,
May 20, 2015, 10:53:01 PM5/20/15
to open...@googlegroups.com, shiz...@gmail.com
hi:
     我在运营环境使用stap stap版本1.8, 命令是
     sudo stap --ldd -d xxx(xxx为程序路径)  --all-modules -D MAXMAPENTRIES=20480 -D MAXACTION=20000 -D MAXTRACE=40 -D MAXSTRINGLEN=4096 -D MAXBACKTRACE=40 -x 28175 profile.stp --vp 00001 > profile.out
使用的脚本就是你提供的systemtap脚本, 但每次一运行,就报
    ERROR: error allocating hash
ERROR: global variable 'bt' allocation failed
WARNING: /usr/bin/staprun exited with status: 1
的错误

server内存信息
             total       used       free     shared    buffers     cached
Mem:         16008      13686       2321          0        115       1334
-/+ buffers/cache:      12236       3771
Swap:        16384       9650       6733

在测试机上,内存只有2G时,用stap对nginx采样时可以的

Yichun Zhang (agentzh)

unread,
May 27, 2015, 9:42:41 AM5/27/15
to openresty
Hello!

2015-05-21 10:53 GMT+08:00 俞勇:
> 我在运营环境使用stap stap版本1.8, 命令是

systemtap 1.8 太老啦,有很多限制和 bug。

> sudo stap --ldd -d xxx(xxx为程序路径) --all-modules -D MAXMAPENTRIES=20480
> -D MAXACTION=20000 -D MAXTRACE=40 -D MAXSTRINGLEN=4096 -D MAXBACKTRACE=40 -x
> 28175 profile.stp --vp 00001 > profile.out
> 使用的脚本就是你提供的systemtap脚本, 但每次一运行,就报
> ERROR: error allocating hash
> ERROR: global variable 'bt' allocation failed

把 -D MAXMAPENTRIES=20480 这个选项中的 20480 调小一些,可以避免这个错误。

> server内存信息
> total used free shared buffers cached
> Mem: 16008 13686 2321 0 115 1334
> -/+ buffers/cache: 12236 3771
> Swap: 16384 9650 6733

嗯,是空闲内存不足而导致的分配错误。把 map 的大小调小就好了(同时可能需要同时调小采样区间)。

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages