如何使用 Raspberry Pi 时钟计数进行性能测量
How to use Raspberry Pi Clock Count for performance measurement
我在 Raspberry Pi 上进行性能测量,并希望获得比 clock_gettime() 更高的分辨率。
因此我需要启用 CPU 寄存器 PMUSERENR。
根据我的 Raspberry Pi 上的 /proc/cpuinfo,我有一个 "ARMv7 Processor 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 syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.604846] Internal error: Oops: 5 [#1] SMP ARM
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.715199] Process insmod (pid: 2944, stack limit = 0xac80e210)
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.722399] Stack: (0xac80fe90 to 0xac810000)
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.727920] fe80: 7f1ba0f8 00007fff 80098128 ac80fea8
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.738472] fea0: 80578128 0000002d 00000000 7f1ba0f8 7f1ba0f8 7f1ba26c 7f1ba264 7f1ba134
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.749092] fec0: ac80e000 8057608c ac80feec ac80fed8 8057608c 00000000 00000000 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.759724] fee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
pi@raspberrypi ~/projects/timer $
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.770389] ff00: 00000000 00000000 00000000 00000000 76f5e948 00007390 00000000 76f7b390
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.781147] ff20: 76f5e948 b91a2390 ac80e000 00000000 ac80ffa4 ac80ff40 8009b6c4 80099714
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.792000] ff40: b919b000 00007390 b91a0598 b91a0457 b91a22c8 0000026c 000002ac 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.802930] ff60: 00000000 00000000 0000001f 00000020 0000000c 0000000a 00000009 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.813947] ff80: 7ea4371c 00000000 55afc028 00000080 8000fc28 ac80e000 00000000 ac80ffa8
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.825056] ffa0: 8000fa20 8009b5f0 7ea4371c 00000000 76f74000 00007390 76f5e948 76f74000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.836170] ffc0: 7ea4371c 00000000 55afc028 00000080 55afbf78 00007390 76f5e948 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.847338] ffe0: 00000000 7ea436c4 76f55fb4 76ec0534 60000010 76f74000 00000000 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.880715] Code: e51b3084 e1530005 e2455008 0a000009 (e5953014)
我是内核模块的新手,所以我不知道该往哪个方向走。有什么好的调试方法吗?
Linux内核自带PMU驱动。你可以利用它。我会为你写一个教程,但是既然这个人解释得很好,为什么还要重新发明轮子:
http://www.carbondesignsystems.com/virtual-prototype-blog/using-the-arm-performance-monitor-unit-pmu-linux-driver
我在 Raspberry Pi 上进行性能测量,并希望获得比 clock_gettime() 更高的分辨率。
因此我需要启用 CPU 寄存器 PMUSERENR。
根据我的 Raspberry Pi 上的 /proc/cpuinfo,我有一个 "ARMv7 Processor 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 syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.604846] Internal error: Oops: 5 [#1] SMP ARM
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.715199] Process insmod (pid: 2944, stack limit = 0xac80e210)
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.722399] Stack: (0xac80fe90 to 0xac810000)
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.727920] fe80: 7f1ba0f8 00007fff 80098128 ac80fea8
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.738472] fea0: 80578128 0000002d 00000000 7f1ba0f8 7f1ba0f8 7f1ba26c 7f1ba264 7f1ba134
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.749092] fec0: ac80e000 8057608c ac80feec ac80fed8 8057608c 00000000 00000000 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.759724] fee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
pi@raspberrypi ~/projects/timer $
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.770389] ff00: 00000000 00000000 00000000 00000000 76f5e948 00007390 00000000 76f7b390
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.781147] ff20: 76f5e948 b91a2390 ac80e000 00000000 ac80ffa4 ac80ff40 8009b6c4 80099714
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.792000] ff40: b919b000 00007390 b91a0598 b91a0457 b91a22c8 0000026c 000002ac 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.802930] ff60: 00000000 00000000 0000001f 00000020 0000000c 0000000a 00000009 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.813947] ff80: 7ea4371c 00000000 55afc028 00000080 8000fc28 ac80e000 00000000 ac80ffa8
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.825056] ffa0: 8000fa20 8009b5f0 7ea4371c 00000000 76f74000 00007390 76f5e948 76f74000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.836170] ffc0: 7ea4371c 00000000 55afc028 00000080 55afbf78 00007390 76f5e948 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.847338] ffe0: 00000000 7ea436c4 76f55fb4 76ec0534 60000010 76f74000 00000000 00000000
Message from syslogd@raspberrypi at Apr 29 20:58:12 ...
kernel:[ 84.880715] Code: e51b3084 e1530005 e2455008 0a000009 (e5953014)
我是内核模块的新手,所以我不知道该往哪个方向走。有什么好的调试方法吗?
Linux内核自带PMU驱动。你可以利用它。我会为你写一个教程,但是既然这个人解释得很好,为什么还要重新发明轮子: http://www.carbondesignsystems.com/virtual-prototype-blog/using-the-arm-performance-monitor-unit-pmu-linux-driver