1,看到內核宏是否支持perf功能
perf top -g
查看linux 內核宏定義
CONFIG_PERF_EVENTS=y
CONFIG_HAVE_PERF_EVENTS=y
CONFIG_FRAME_POINTER=y # 確保幀指針支持以捕獲完整堆棧
2,使用perf top -g 報錯
Access to performance monitoring and observability operations is limited. │
│Consider adjusting /proc/sys/kernel/perf_event_paranoid setting to open │
│access to performance monitoring and observability operations for processes│
│without CAP_PERFMON, CAP_SYS_PTRACE or CAP_SYS_ADMIN Linux capability. |
│More information can be found at 'Perf events and tool security' document: │
│https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html