2016-04-29 32 views
2

我在Raspberry Pi上进行性能测量,并希望获得更高的分辨率,然后只是clock_gettime()。如何使用树莓派时钟计数进行性能测量

因此,我需要启用CPU寄存器PMUSERENR。

根据我的Raspberry Pi上的/ proc/cpuinfo,我有一个“ARMv7处理器rev 5(v7l)”。所以,我下载的架构参考手册,发现我必须使用:

CRn的= C9,OPC1 = 0,CRM = C14,OPC2 = 0

asm ("MCR p15, 0, %0, C9, C14, 0\n\t" :: "r"(1)); 

但一个内核模块中使用此代码时,我得到以下哎呀:

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.604846] Internal error: Oops: 5 [#1] SMP ARM 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.715199] Process insmod (pid: 2944, stack limit = 0xac80e210) 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.722399] Stack: (0xac80fe90 to 0xac810000) 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.727920] fe80:          7f1ba0f8 00007fff 80098128 ac80fea8 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.738472] fea0: 80578128 0000002d 00000000 7f1ba0f8 7f1ba0f8 7f1ba26c 7f1ba264 7f1ba134 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.749092] fec0: ac80e000 8057608c ac80feec ac80fed8 8057608c 00000000 00000000 00000000 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.759724] fee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
[email protected] ~/projects/timer $ 
Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.770389] ff00: 00000000 00000000 00000000 00000000 76f5e948 00007390 00000000 76f7b390 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.781147] ff20: 76f5e948 b91a2390 ac80e000 00000000 ac80ffa4 ac80ff40 8009b6c4 80099714 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.792000] ff40: b919b000 00007390 b91a0598 b91a0457 b91a22c8 0000026c 000002ac 00000000 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.802930] ff60: 00000000 00000000 0000001f 00000020 0000000c 0000000a 00000009 00000000 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.813947] ff80: 7ea4371c 00000000 55afc028 00000080 8000fc28 ac80e000 00000000 ac80ffa8 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.825056] ffa0: 8000fa20 8009b5f0 7ea4371c 00000000 76f74000 00007390 76f5e948 76f74000 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.836170] ffc0: 7ea4371c 00000000 55afc028 00000080 55afbf78 00007390 76f5e948 00000000 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.847338] ffe0: 00000000 7ea436c4 76f55fb4 76ec0534 60000010 76f74000 00000000 00000000 

Message from [email protected] at Apr 29 20:58:12 ... 
kernel:[ 84.880715] Code: e51b3084 e1530005 e2455008 0a000009 (e5953014) 

我是新内核模块,所以我不知道我应该去哪个方向。有没有一种好的方法来调试这些东西?

回答

0

Linux内核附带一个PMU驱动程序。你可以利用它。我会为你写一篇教程,但为什么重新发明轮子,当这家伙解释得这么好: http://www.carbondesignsystems.com/virtual-prototype-blog/using-the-arm-performance-monitor-unit-pmu-linux-driver

+0

很酷,我会试试。但是你知道什么可能会导致我的哎呀?或者这样的错误可能来自哪里? – arm712

+0

好像你在insmod进程中崩溃了,而不是实际的内核模块。如果删除mcr语句并重新编译该模块,insmod是否仍会崩溃?如果是,那么用于编译模块的内核头文件与您实际运行的内核不兼容。你能分享“uname -a”和你的makefile的输出吗? – Jitesh