错误信息是:"ERROR: module version mismatch (#1 SMP Tue Sep 1210:10:26 CDT 2017 vs #1 SMP Tue Sep 1222:26:13 UTC 2017)"。
解决"ERROR: module version mismatch"问题stap运行的时候加上-v参数,打印更多信息看看还有没有更多线索:
# stap -e 'probe begin{printf("Hello, World"); exit();}' -v Pass 1: parsed user script and 470 library scripts using 228224virt/41280res/3348shr/38020data kb, in 330usr/20sys/346real ms. Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using 229148virt/42332res/3536shr/38944data kb, in 0usr/0sys/6real ms. Pass 3: using cached /root/.systemtap/cache/0b/stap_0bc9e27aef7a1de50ea41889a27fc524_1010.c Pass 4: using cached /root/.systemtap/cache/0b/stap_0bc9e27aef7a1de50ea41889a27fc524_1010.ko Pass 5: starting run. ERROR: module version mismatch (#1 SMP Tue Sep 12 10:10:26 CDT 2017 vs #1 SMP Tue Sep 12 22:26:13 UTC 2017), release 3.10.0-693.2.2.el7.x86_64 WARNING: /usr/bin/staprun exited with status: 1 Pass 5: run completed in 0usr/10sys/38real ms. Pass 5: run failed. [man error::pass5]
查看c文件,vi /root/.systemtap/cache/0b/stap_0bc9e27aef7a1de50ea41889a27fc524_1010.c,搜错误信息"module version mismatch",能搜到报错发生在下面的第13行,至于UTS_RELEASE和UTS_VERSION是在哪里设置的,直接Google一把。
#ifndef STP_NO_VERREL_CHECK
const char* release = UTS_RELEASE;
#ifdef STAPCONF_GENERATED_COMPILE
const char* version = UTS_VERSION;
#endif
might_sleep();
if (strcmp (release, "3.10.0-693.2.2.el7.x86_64")) {
_stp_error ("module release mismatch (%s vs %s)", release, "3.10.0-693.2.2.el7.x86_64");
rc = -EINVAL;
}
#ifdef STAPCONF_GENERATED_COMPILE
if (strcmp (utsname()->version, version)) {
_stp_error ("module version mismatch (%s vs %s), release %s", version, utsname()->version, release);
rc = -EINVAL;
}
#endif
#endif
有两篇文章里面提到了同样的坑,文章连接在底部的参考中。在kernel-devel包的所以文件中搜以下变量UTS_VERSION,
# rpm -ql kernel-devel | xargs grep UTS_VERSION /usr/src/kernels/3.10.0-693.2.2.el7.x86_64/include/generated/compile.h:#define UTS_VERSION "#1 SMP Tue Sep 12 10:10:26 CDT 2017"
可以看到在compile.h中有#define UTS_VERSION "#1 SMP Tue Sep 12 10:10:26 CDT 2017". 这个是不是很熟悉... 对比下上面运行stap的报错信息, module mismatch的时间就是这个。文件compile.h是自动生成的,可能和当时编译时的时间相关。但是stap要求这个也和当前系统uname -a里面的时间完全一直,如果下个CentOS原生的kernel-devel应该就没这个问题。
解决问题的另一个简单方法就是直接修改这个compile.h文件,原来的文件如下:
# cat /usr/src/kernels/3.10.0-693.2.2.el7.x86_64/include/generated/compile.h /* This file is auto generated, version 1 */ /* SMP */ #define UTS_MACHINE "x86_64" #define UTS_VERSION "#1 SMP Tue Sep 12 10:10:26 CDT 2017" #define LINUX_COMPILE_BY "mockbuild" #define LINUX_COMPILE_HOST "sl7-uefisign.fnal.gov" #define LINUX_COMPILER "gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) "
修改define UTS_VERSION那一行,如下:
#define UTS_VERSION "#1 SMP Tue Sep 12 10:10:26 CDT 2017" -> #define UTS_VERSION "#1 SMP Tue Sep 12 22:26:13 UTC 2017"
再次运行stap: