Android 设备不支持 Simpleperf cpu-cycles

Simpleperf cpu-cycles not supported in Android devices

我试图在我的 Android ndk 应用程序中使用 simpleperf 进行分析,但是当我键入 simpleperf record 命令时,系统报告此消息:

simpleperf E 02-08 13:34:47 15380 15380 event_selection_set.cpp:68] Event type 'cpu-cycles' is not supported by the kernel

我读了这个教程:https://android.googlesource.com/platform/system/extras/+/master/simpleperf/README.md

我遵循了以下步骤:

  Make android debuggable=true in the manifest. 

  adb shell setprop security.perf_harden 0 

  adb shell 

  shell@mako:  run-as com.mysample.test

  adb push bin/android/arm/simpleperf /data/local/tmp

  shell@mako: cp /data/local/tmp/simpleperf .

  shell@mako: ./simpleperf record -p  12083 --duration 30

这是否意味着硬件不支持 nexus 4 cpu-cycles 或者我可能没有在内核上激活特定的安全标志?

我正在使用 root 的 nexus 4 设备。

Ndk 版本 13b。

Android 版本:5.1

内核版本:3.4.0-perf-gf75bb4f

pd: 我标记了 perf 标签,因为它与 perf 相似。

提前致谢。

乌奈

Nexus 4 支持 cpu-cycles 事件。我在 git 历史中找不到内核版本 f75bb4f,所以我没有测试相同的内核。我已经通过在 nexus 4 上闪烁 5.1.1 (LMY48T),在 ndk-r13b 中使用 simpleperf 进行了测试,并且它有效。所以我怀疑你使用的内核禁用了 perf 事件,你可以通过在 https://developers.google.com/android/images#occam.

中刷新一个新图像来解决这个问题