免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: todaygood
打印 上一主题 下一主题

[内核模块] 搞不懂为何有了kprobe了还要systemtap? [复制链接]

论坛徽章:
0
11 [报告]
发表于 2014-01-04 22:02 |只看该作者
回复 7# tempname2
呵呵,比我高的人多了去,譬如你。

   

论坛徽章:
0
12 [报告]
发表于 2014-01-04 22:04 |只看该作者
回复 6# bboytaiwan
不错,发帖的本意就是要挖掘systemtap比kprobe的长处。

   

论坛徽章:
0
13 [报告]
发表于 2014-01-04 22:24 |只看该作者
回复 6# bboytaiwan

请教一下,经常编译出错,怎么办? 不知如何去解决,能说一下对付这种问题一般的方法是?

jun:/Linux/trouble/tools/systemtap/example # cat trace_route.stp



probe kernel.function("*@net/ipv4/route.c" ).return {
        printf("%s <-- %s\n", thread_indent(-1), probefunc())
}
jun:/Linux/trouble/tools/systemtap/example # stap -v trace_route.stp
Pass 1: parsed user script and 89 library script(s) using 70656virt/21520res/2364shr/19812data kb, in 200usr/20sys/223real ms.
Pass 2: analyzed script: 62 probe(s), 20 function(s), 4 embed(s), 2 global(s) using 254572virt/69488res/3524shr/67292data kb, in 630usr/110sys/764real ms.
Pass 3: translated to C into "/tmp/stapMb7Nvr/stap_602ef97f7b0f9c1f59fed946981310fc_22394_src.c" using 252200virt/72564res/6720shr/67292data kb, in 290usr/10sys/301real ms.
/tmp/stapMb7Nvr/stap_602ef97f7b0f9c1f59fed946981310fc_22394_src.c: In function ‘systemtap_module_init’:
/tmp/stapMb7Nvr/stap_602ef97f7b0f9c1f59fed946981310fc_22394_src.c:2541:3: error: implicit declaration of function ‘_stp_vma_init’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
make[3]: *** [/tmp/stapMb7Nvr/stap_602ef97f7b0f9c1f59fed946981310fc_22394_src.o] Error 1
make[2]: *** [_module_/tmp/stapMb7Nvr] Error 2
make[1]: *** [sub-make] Error 2
make: *** [all] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compiled C into "stap_602ef97f7b0f9c1f59fed946981310fc_22394.ko" in 2250usr/560sys/2835real ms.
Pass 4: compilation failed.  Try again with another '--vp 0001' option.

   

论坛徽章:
0
14 [报告]
发表于 2014-01-04 22:41 |只看该作者
回复 8# tempname2

你也承认systemtap的用户体验不是太好吧, 说是一种脚本语言,结果还是要转化成C语言编译,但又加入很多代码,编译出错了还不好定位修改,折腾这个东西真是有些费劲!!
   

论坛徽章:
0
15 [报告]
发表于 2014-01-05 11:30 |只看该作者
我記得ubuntu內建的systemtap有些問題。可以試試看我自己上傳的systemtap: https://launchpad.net/~mimi0213kimo/+archive/test/+packages 回复 13# todaygood


   

论坛徽章:
1
白羊座
日期:2014-01-05 12:42:56
16 [报告]
发表于 2014-01-05 12:47 |只看该作者
本帖最后由 gacad 于 2014-01-05 12:48 编辑

一个全新的性能测量和调试诊断工具,
监控和跟踪运行中的Linux 内核的操作的动态方法。

与一种名为DTrace 的老技术相似,该技术源于Sun Solaris 操作系统。在DTrace 中,开发人员可以用D 编程语言(C 语言的子集,但修改为支持跟踪行为)编写脚本来保存应用编程接口

论坛徽章:
6
金牛座
日期:2013-10-08 10:19:10技术图书徽章
日期:2013-10-14 16:24:09CU十二周年纪念徽章
日期:2013-10-24 15:41:34狮子座
日期:2013-11-24 19:26:19未羊
日期:2014-01-23 15:50:002015年亚洲杯之阿联酋
日期:2015-05-09 14:36:15
17 [报告]
发表于 2014-01-06 09:03 |只看该作者
回复 1# todaygood
systemtap能实现的功能kprobe都可以做,为了用systemtap学习那一套语言有些麻烦,因为不是经常用,过几天就忘了,搞不懂为何有了kprobe了还要systemtap?

大家来谈一谈,你为何用systemtap ?
我能想到的:
1.systemtap较用kprobe写内核模块要安全一些,systemtap脚本不会把系统crash掉,而写内核模块就不一样了. 至于为何安全,还没去研究,毕竟systemtap后面也是要加载内核模块的。

2.systemtap适合不会内核编程,C语言的人士使用,脚本语言方便。说实话对于我这种熟悉内核编程的人来说,相反systemtap还麻烦一些


这两点就很重要了啊。

另外我这边经常用的一点就是,写好systemtap可以在centos和suse间无缝切换,而如果写kprobe的话,就需要自己适配不同的内核版本了。

   

论坛徽章:
0
18 [报告]
发表于 2014-01-06 09:41 |只看该作者
回复 17# 瀚海书香

内核版本切换容易,这个前提是脚本能正确编译通过生成ko文件, 感觉目前这个脚本语言的跨系统编译做得很不好。

我经常碰到在一个系统上stp脚本跑得没问题,换一个内核脚本编译阶段就出问题,譬如上面#13楼的问题。
   

论坛徽章:
2
酉鸡
日期:2013-09-26 11:11:15摩羯座
日期:2014-01-08 13:45:19
19 [报告]
发表于 2014-01-08 13:39 |只看该作者
回复 13# todaygood


    试下helloworld?
这么简单的stp脚本出错的话,应该是你环境没有配置好

论坛徽章:
0
20 [报告]
发表于 2014-01-08 16:28 |只看该作者
回复 19# hejianet


    jun:/Linux/trouble/tools/systemtap/example # stap -v hello.stp
Pass 1: parsed user script and 89 library script(s) using 70660virt/21520res/2364shr/19816data kb, in 200usr/30sys/476real ms.
Pass 2: analyzed script: 1 probe(s), 1 function(s), 0 embed(s), 0 global(s) using 71188virt/22280res/2472shr/20344data kb, in 0usr/0sys/49real ms.
Pass 3: translated to C into "/tmp/stapIGTcfX/stap_8f09c1af3ea1607e23732126905e0e61_964_src.c" using 71188virt/22820res/2960shr/20344data kb, in 0usr/0sys/0real ms.
Pass 4: compiled C into "stap_8f09c1af3ea1607e23732126905e0e61_964.ko" in 10710usr/1690sys/17946real ms.
Pass 5: starting run.
hello world
Pass 5: run completed in 20usr/60sys/387real ms.
jun:/Linux/trouble/tools/systemtap/example # cat hello.stp
probe begin
{
printf("hello world\n")
exit()
}

jun:/Linux/trouble/tools/systemtap/example # stap -v trace_route.stp
Pass 1: parsed user script and 89 library script(s) using 70660virt/21528res/2364shr/19816data kb, in 200usr/20sys/221real ms.
Pass 2: analyzed script: 62 probe(s), 20 function(s), 4 embed(s), 2 global(s) using 254572virt/69488res/3524shr/67292data kb, in 670usr/350sys/8707real ms.
Pass 3: translated to C into "/tmp/stapjiABQJ/stap_2f7c773e1a90df417f431118bb8ecda8_22394_src.c" using 252200virt/72564res/6720shr/67292data kb, in 300usr/10sys/595real ms.
/tmp/stapjiABQJ/stap_2f7c773e1a90df417f431118bb8ecda8_22394_src.c: In function ‘systemtap_module_init’:
/tmp/stapjiABQJ/stap_2f7c773e1a90df417f431118bb8ecda8_22394_src.c:2541:3: error: implicit declaration of function ‘_stp_vma_init’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
make[3]: *** [/tmp/stapjiABQJ/stap_2f7c773e1a90df417f431118bb8ecda8_22394_src.o] Error 1
make[2]: *** [_module_/tmp/stapjiABQJ] Error 2
make[1]: *** [sub-make] Error 2
make: *** [all] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compiled C into "stap_2f7c773e1a90df417f431118bb8ecda8_22394.ko" in 2250usr/530sys/2972real ms.
Pass 4: compilation failed.  Try again with another '--vp 0001' option.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP