Skip to content

Commit

Permalink
perf_cnt: use alternate reporting to minimize logging overhead
Browse files Browse the repository at this point in the history
Implement simple alternate reporting for perf_cnt_average()
and task_perf_cnt_avg(). By calling the reporting function only
for every other measurement window, the overhead of reporting
can be filtered out from data. This mostly affects the peak
cycle reporting. For average values reporting has only minimal
impact.

Signed-off-by: Kai Vehmanen <[email protected]>
  • Loading branch information
kv2019i committed Nov 19, 2024
1 parent b34488f commit ccc3429
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/include/sof/lib/perf_cnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ struct perf_cnt_data {
(uint32_t)((pcd)->cpu_delta_peak))
#define task_perf_cnt_avg(pcd, trace_m, arg, class) do { \
(pcd)->cpu_delta_sum += (pcd)->cpu_delta_last; \
if (++(pcd)->period_cnt == 1 << PERF_CNT_CHECK_WINDOW_SIZE) { \
if (!(++(pcd)->period_cnt & MASK(PERF_CNT_CHECK_WINDOW_SIZE - 1, 0))) { \
(pcd)->cpu_delta_sum >>= PERF_CNT_CHECK_WINDOW_SIZE; \
trace_m(pcd, arg, class); \
if ((pcd)->period_cnt & BIT(PERF_CNT_CHECK_WINDOW_SIZE)) \
trace_m(pcd, arg, class); \
(pcd)->cpu_delta_sum = 0; \
(pcd)->period_cnt = 0; \
(pcd)->plat_delta_peak = 0; \
(pcd)->cpu_delta_peak = 0; \
} \
Expand All @@ -115,11 +115,13 @@ struct perf_cnt_data {
*/
#define perf_cnt_average(pcd, trace_m, arg) do { \
(pcd)->cpu_delta_sum += (pcd)->cpu_delta_last; \
if (++(pcd)->period_cnt == 1 << PERF_CNT_CHECK_WINDOW_SIZE) {\
if (!(++(pcd)->period_cnt & MASK(PERF_CNT_CHECK_WINDOW_SIZE - 1, 0))) { \
(pcd)->cpu_delta_sum >>= PERF_CNT_CHECK_WINDOW_SIZE; \
trace_m(pcd, arg); \
(pcd)->peak_mcps_period_cnt &= MASK(PERF_CNT_CHECK_WINDOW_SIZE - 1, 0); \
if ((pcd)->period_cnt & BIT(PERF_CNT_CHECK_WINDOW_SIZE)) { \
trace_m(pcd, arg); \
} \
(pcd)->cpu_delta_sum = 0; \
(pcd)->period_cnt = 0; \
(pcd)->plat_delta_peak = 0; \
(pcd)->cpu_delta_peak = 0; \
(pcd)->peak_mcps_period_cnt = 0; \
Expand Down

0 comments on commit ccc3429

Please sign in to comment.