有選擇地為特定參數記錄內核 Ftrace 點 (Logging the kernel Ftrace point selectively for particular arguments)


問題描述

有選擇地為特定參數記錄內核 Ftrace 點 (Logging the kernel Ftrace point selectively for particular arguments)

我想使用 Ftrace 測量一些內核函數的性能,但我想針對參數的特定值選擇性地測量它。這是因為調用相同函數(但參數不同)的相同/其他程序污染了我的 Ftrace 輸出日誌。另外,我不想設置 PID 過濾器,因為它不能解決我的問題(我正在運行多個並行內核線程,並且同一個程序也可以使用不同的參數調用該函數)在不影響的情況下最好的方法是什麼測量?我是否缺少任何 Ftrace 功能(或可能自定義跟踪點)?


參考解法

方法 1:

We can use Conditional Tracepoints for this kinds of case. This patch may also be helpful in understanding. One can check this file ‑ samples\trace_events\trace‑events‑sample.h in linux kernel to see sample examples.

In samples\trace_events\trace‑events‑sample.h, It became crystal‑clear to me after seeing this macro ‑ TRACE_EVENT_CONDITION(). Thanks to the author for providing a detailed documentation there.

Moreover, one can use pre‑defined event‑tracepoints or define a new custom event tracepoint in include/trace/events/*.h and filter the trace logs by adding condition in TRACE_DIR/tracing/events/EVENT/filter. This kernel documentation link is very helpful to understand this.

(by shivankshivank)

參考文件

  1. Logging the kernel Ftrace point selectively for particular arguments (CC BY‑SA 2.5/3.0/4.0)

#perf #performance #linux #profiling #ftrace






相關問題

使用 perf 或其他方式獲取 C 程序的運行時間(或其他統計信息) (Getting running time (or other stats) for C Program using perf or otherwise)

使用 perf_events/oprofile 在 Linux 上分析 JIT 的輸出? (Profiling output of JIT on Linux with perf_events/oprofile?)

如何提出高緩存未命中率示例? (How to come up with a high cache miss rate example?)

perf 關於嵌套函數的最佳結果 (perf top result about nested functions)

Haswell 微架構在 perf 中沒有 Stalled-cycles-backend (Haswell microarchitecture don't have Stalled-cycles-backend in perf)

perf 如何使用 offcore 事件? (How does perf use the offcore events?)

外部化 react 和 react-dom 依賴項是否會增加反應應用程序的加載時間 (Does externalising react and react-dom dependencies give a gain in load time of a react app)

使用 PERF_EVENT_IOC_PERIOD 在運行時更改採樣週期 (Usage of PERF_EVENT_IOC_PERIOD to change sampling period during runtime)

理解 perf stat 輸出中的數字 (Make sense of numbers in perf stat output)

perf_event_open 權限被拒絕,除了使用 sudo 或更改 perf_event_paranoid 文件之外,還有其他方法嗎? (Permission denied on perf_event_open, is there another way than to use sudo or changing the perf_event_paranoid file?)

有選擇地為特定參數記錄內核 Ftrace 點 (Logging the kernel Ftrace point selectively for particular arguments)

性能計數器和 IMC 計數器不匹配 (Performance Counters and IMC Counter Not Matching)







留言討論