diff --git a/app/perf_overlay.conf b/app/perf_overlay.conf new file mode 100644 index 000000000000..1b3359c93c11 --- /dev/null +++ b/app/perf_overlay.conf @@ -0,0 +1,2 @@ +CONFIG_PERFORMANCE_COUNTERS=y +CONFIG_PERFORMANCE_COUNTERS_RUN_AVERAGE=y diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index 029557ce14e6..c860902ac9af 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -238,7 +238,9 @@ enum { (uint32_t)((pcd)->cpu_delta_peak)) #define comp_perf_avg_info(pcd, comp_p) \ - comp_info(comp_p, "perf comp_copy cpu avg %u (current peak %u)",\ + comp_info(comp_p, "perf comp_copy samples %u period %u cpu avg %u peak %u",\ + (uint32_t)((comp_p)->frames), \ + (uint32_t)((comp_p)->period), \ (uint32_t)((pcd)->cpu_delta_sum), \ (uint32_t)((pcd)->cpu_delta_peak)) diff --git a/src/include/sof/schedule/task.h b/src/include/sof/schedule/task.h index c5a4a0a9b2ea..7d828d9f6627 100644 --- a/src/include/sof/schedule/task.h +++ b/src/include/sof/schedule/task.h @@ -14,6 +14,8 @@ #include #include #include +#include + struct comp_dev; struct sof; @@ -72,6 +74,9 @@ struct task { uint32_t cycles_max; uint32_t cycles_cnt; #endif +#if CONFIG_PERFORMANCE_COUNTERS + struct perf_cnt_data pcd; +#endif }; static inline bool task_is_active(struct task *task) diff --git a/src/schedule/zephyr_ll.c b/src/schedule/zephyr_ll.c index cf6ad1d62875..e3d795d151be 100644 --- a/src/schedule/zephyr_ll.c +++ b/src/schedule/zephyr_ll.c @@ -12,7 +12,7 @@ #include #include #include - +#include #include LOG_MODULE_REGISTER(ll_schedule, CONFIG_SOF_LOG_LEVEL); @@ -122,30 +122,18 @@ static void zephyr_ll_task_insert_after_unlocked(struct task *task, struct task static inline enum task_state do_task_run(struct task *task) { - uint32_t cycles0, cycles1, diff; enum task_state state; - cycles0 = k_cycle_get_32(); +#if CONFIG_PERFORMANCE_COUNTERS + perf_cnt_init(&task->pcd); +#endif state = task_run(task); - cycles1 = k_cycle_get_32(); - if (cycles1 > cycles0) - diff = cycles1 - cycles0; - else - diff = UINT32_MAX - cycles0 + cycles1; - - task->cycles_sum += diff; - task->cycles_max = diff > task->cycles_max ? diff : task->cycles_max; - - if (++task->cycles_cnt == 1 << CYCLES_WINDOW_SIZE) { - task->cycles_sum >>= CYCLES_WINDOW_SIZE; - tr_info(&ll_tr, "ll task %p %pU avg %u, max %u", - task, task->uid, task->cycles_sum, task->cycles_max); - task->cycles_sum = 0; - task->cycles_cnt = 0; - task->cycles_max = 0; - } +#if CONFIG_PERFORMANCE_COUNTERS + perf_cnt_stamp(&task->pcd, perf_trace_null, NULL); + task_perf_cnt_avg(&task->pcd, task_perf_avg_info, &ll_tr, task); +#endif return state; }