video: driver: enable memory tracking in stats handler
track internal memory usage periodically and print memory usage stats using stats handler. Change-Id: Idd16647dbe4aab3fc617a8f7fc0d3c81f459bb5d Signed-off-by: Govindaraj Rajagopal <quic_grajagop@quicinc.com>
This commit is contained in:
@@ -111,7 +111,7 @@ enum vidc_msg_prio {
|
|||||||
#define i_vpr_hp(inst, __fmt, ...) \
|
#define i_vpr_hp(inst, __fmt, ...) \
|
||||||
dprintk_inst(VIDC_HIGH | VIDC_PERF, "high", inst, __fmt, ##__VA_ARGS__)
|
dprintk_inst(VIDC_HIGH | VIDC_PERF, "high", inst, __fmt, ##__VA_ARGS__)
|
||||||
#define i_vpr_hs(inst, __fmt, ...) \
|
#define i_vpr_hs(inst, __fmt, ...) \
|
||||||
dprintk_inst(VIDC_HIGH | VIDC_STAT, "high", inst, __fmt, ##__VA_ARGS__)
|
dprintk_inst(VIDC_HIGH | VIDC_STAT, "stat", inst, __fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
#define dprintk_core(__level, __level_str, __fmt, ...) \
|
#define dprintk_core(__level, __level_str, __fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
@@ -181,4 +181,9 @@ void msm_vidc_debugfs_update(void *inst,
|
|||||||
int msm_vidc_check_ratelimit(void);
|
int msm_vidc_check_ratelimit(void);
|
||||||
void msm_vidc_show_stats(void *inst);
|
void msm_vidc_show_stats(void *inst);
|
||||||
|
|
||||||
|
static inline bool is_stats_enabled(void)
|
||||||
|
{
|
||||||
|
return !!(msm_vidc_debug & VIDC_STAT);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -496,6 +496,7 @@ void msm_vidc_stats_handler(struct work_struct *work);
|
|||||||
int schedule_stats_work(struct msm_vidc_inst *inst);
|
int schedule_stats_work(struct msm_vidc_inst *inst);
|
||||||
int cancel_stats_work_sync(struct msm_vidc_inst *inst);
|
int cancel_stats_work_sync(struct msm_vidc_inst *inst);
|
||||||
void msm_vidc_print_stats(struct msm_vidc_inst *inst);
|
void msm_vidc_print_stats(struct msm_vidc_inst *inst);
|
||||||
|
void msm_vidc_print_memory_stats(struct msm_vidc_inst *inst);
|
||||||
enum msm_vidc_buffer_type v4l2_type_to_driver(u32 type,
|
enum msm_vidc_buffer_type v4l2_type_to_driver(u32 type,
|
||||||
const char *func);
|
const char *func);
|
||||||
int msm_vidc_buf_queue(struct msm_vidc_inst *inst, struct msm_vidc_buffer *buf);
|
int msm_vidc_buf_queue(struct msm_vidc_inst *inst, struct msm_vidc_buffer *buf);
|
||||||
|
@@ -2156,6 +2156,9 @@ int msm_vdec_start_cmd(struct msm_vidc_inst *inst)
|
|||||||
/* print final buffer counts & size details */
|
/* print final buffer counts & size details */
|
||||||
msm_vidc_print_buffer_info(inst);
|
msm_vidc_print_buffer_info(inst);
|
||||||
|
|
||||||
|
/* print internal buffer memory usage stats */
|
||||||
|
msm_vidc_print_memory_stats(inst);
|
||||||
|
|
||||||
rc = msm_vidc_process_resume(inst);
|
rc = msm_vidc_process_resume(inst);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
@@ -1009,6 +1009,9 @@ int msm_venc_start_cmd(struct msm_vidc_inst *inst)
|
|||||||
/* print final buffer counts & size details */
|
/* print final buffer counts & size details */
|
||||||
msm_vidc_print_buffer_info(inst);
|
msm_vidc_print_buffer_info(inst);
|
||||||
|
|
||||||
|
/* print internal buffer memory usage stats */
|
||||||
|
msm_vidc_print_memory_stats(inst);
|
||||||
|
|
||||||
rc = msm_vidc_process_resume(inst);
|
rc = msm_vidc_process_resume(inst);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
@@ -1077,6 +1077,8 @@ int msm_vidc_close(void *instance)
|
|||||||
inst_lock(inst, __func__);
|
inst_lock(inst, __func__);
|
||||||
/* print final stats */
|
/* print final stats */
|
||||||
msm_vidc_print_stats(inst);
|
msm_vidc_print_stats(inst);
|
||||||
|
/* print internal buffer memory usage stats */
|
||||||
|
msm_vidc_print_memory_stats(inst);
|
||||||
msm_vidc_print_residency_stats(core);
|
msm_vidc_print_residency_stats(core);
|
||||||
msm_vidc_session_close(inst);
|
msm_vidc_session_close(inst);
|
||||||
msm_vidc_change_state(inst, MSM_VIDC_CLOSE, __func__);
|
msm_vidc_change_state(inst, MSM_VIDC_CLOSE, __func__);
|
||||||
|
@@ -2760,7 +2760,7 @@ void msm_vidc_print_stats(struct msm_vidc_inst *inst)
|
|||||||
bitrate_kbps = (inst->stats.data_size * 8 * 1000) / (dt_ms * 1024);
|
bitrate_kbps = (inst->stats.data_size * 8 * 1000) / (dt_ms * 1024);
|
||||||
|
|
||||||
i_vpr_hs(inst,
|
i_vpr_hs(inst,
|
||||||
"stats: counts (etb,ebd,ftb,fbd): %u %u %u %u (total %llu %llu %llu %llu), achieved bitrate %lldKbps fps %u/s, frame rate %u, operating rate %u, priority %u, dt %ums\n",
|
"counts (etb,ebd,ftb,fbd): %u %u %u %u (total %llu %llu %llu %llu), achieved bitrate %lldKbps fps %u/s, frame rate %u, operating rate %u, priority %u, dt %ums\n",
|
||||||
etb, ebd, ftb, fbd, inst->debug_count.etb, inst->debug_count.ebd,
|
etb, ebd, ftb, fbd, inst->debug_count.etb, inst->debug_count.ebd,
|
||||||
inst->debug_count.ftb, inst->debug_count.fbd,
|
inst->debug_count.ftb, inst->debug_count.fbd,
|
||||||
bitrate_kbps, achieved_fps, frame_rate, operating_rate, priority, dt_ms);
|
bitrate_kbps, achieved_fps, frame_rate, operating_rate, priority, dt_ms);
|
||||||
@@ -2770,6 +2770,63 @@ void msm_vidc_print_stats(struct msm_vidc_inst *inst)
|
|||||||
inst->stats.time_ms = time_ms;
|
inst->stats.time_ms = time_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void msm_vidc_print_memory_stats(struct msm_vidc_inst *inst)
|
||||||
|
{
|
||||||
|
static enum msm_vidc_buffer_type buf_type_arr[9] = {
|
||||||
|
MSM_VIDC_BUF_BIN,
|
||||||
|
MSM_VIDC_BUF_ARP,
|
||||||
|
MSM_VIDC_BUF_COMV,
|
||||||
|
MSM_VIDC_BUF_NON_COMV,
|
||||||
|
MSM_VIDC_BUF_LINE,
|
||||||
|
MSM_VIDC_BUF_DPB,
|
||||||
|
MSM_VIDC_BUF_PERSIST,
|
||||||
|
MSM_VIDC_BUF_VPSS,
|
||||||
|
MSM_VIDC_BUF_PARTIAL_DATA,
|
||||||
|
};
|
||||||
|
u32 count_arr[9];
|
||||||
|
u32 size_arr[9];
|
||||||
|
u32 size_kb_arr[9];
|
||||||
|
u64 total_size = 0;
|
||||||
|
struct msm_vidc_buffers *buffers;
|
||||||
|
int cnt;
|
||||||
|
|
||||||
|
if (!inst) {
|
||||||
|
i_vpr_e(inst, "%s: invalid params\n", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reset array values */
|
||||||
|
memset(&count_arr, 0, sizeof(count_arr));
|
||||||
|
memset(&size_arr, 0, sizeof(size_arr));
|
||||||
|
memset(&size_kb_arr, 0, sizeof(size_kb_arr));
|
||||||
|
|
||||||
|
/* populate buffer details */
|
||||||
|
for (cnt = 0; cnt < 9; cnt++) {
|
||||||
|
buffers = msm_vidc_get_buffers(inst, buf_type_arr[cnt], __func__);
|
||||||
|
if (!buffers)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
size_arr[cnt] = buffers->size;
|
||||||
|
count_arr[cnt] = buffers->min_count;
|
||||||
|
size_kb_arr[cnt] = (size_arr[cnt] * count_arr[cnt]) / 1024;
|
||||||
|
total_size += size_arr[cnt] * count_arr[cnt];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* print internal memory stats */
|
||||||
|
i_vpr_hs(inst,
|
||||||
|
"%s %u kb(%ux%d) %s %u kb(%ux%d) %s %u kb(%ux%d) %s %u kb(%ux%d) %s %u kb(%ux%d) %s %u kb(%ux%d) %s %u kb(%ux%d) %s %u kb(%ux%d) %s %u kb(%ux%d) total %llu kb\n",
|
||||||
|
buf_name(buf_type_arr[0]), size_kb_arr[0], size_arr[0], count_arr[0],
|
||||||
|
buf_name(buf_type_arr[1]), size_kb_arr[1], size_arr[1], count_arr[1],
|
||||||
|
buf_name(buf_type_arr[2]), size_kb_arr[2], size_arr[2], count_arr[2],
|
||||||
|
buf_name(buf_type_arr[3]), size_kb_arr[3], size_arr[3], count_arr[3],
|
||||||
|
buf_name(buf_type_arr[4]), size_kb_arr[4], size_arr[4], count_arr[4],
|
||||||
|
buf_name(buf_type_arr[5]), size_kb_arr[5], size_arr[5], count_arr[5],
|
||||||
|
buf_name(buf_type_arr[6]), size_kb_arr[6], size_arr[6], count_arr[6],
|
||||||
|
buf_name(buf_type_arr[7]), size_kb_arr[7], size_arr[7], count_arr[7],
|
||||||
|
buf_name(buf_type_arr[8]), size_kb_arr[8], size_arr[8], count_arr[8],
|
||||||
|
(total_size / 1024));
|
||||||
|
}
|
||||||
|
|
||||||
int schedule_stats_work(struct msm_vidc_inst *inst)
|
int schedule_stats_work(struct msm_vidc_inst *inst)
|
||||||
{
|
{
|
||||||
struct msm_vidc_core *core;
|
struct msm_vidc_core *core;
|
||||||
@@ -2779,6 +2836,11 @@ int schedule_stats_work(struct msm_vidc_inst *inst)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_stats_enabled()) {
|
||||||
|
i_vpr_h(inst, "%s: stats not enabled. Skip scheduling\n", __func__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hfi session is already closed and inst also going to be
|
* Hfi session is already closed and inst also going to be
|
||||||
* closed soon. So skip scheduling new stats_work to avoid
|
* closed soon. So skip scheduling new stats_work to avoid
|
||||||
|
@@ -480,6 +480,9 @@ int msm_vidc_start_streaming(struct msm_vidc_inst *inst, struct vb2_queue *q)
|
|||||||
/* print final buffer counts & size details */
|
/* print final buffer counts & size details */
|
||||||
msm_vidc_print_buffer_info(inst);
|
msm_vidc_print_buffer_info(inst);
|
||||||
|
|
||||||
|
/* print internal buffer memory usage stats */
|
||||||
|
msm_vidc_print_memory_stats(inst);
|
||||||
|
|
||||||
buf_type = v4l2_type_to_driver(q->type, __func__);
|
buf_type = v4l2_type_to_driver(q->type, __func__);
|
||||||
if (!buf_type)
|
if (!buf_type)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -556,6 +559,9 @@ int msm_vidc_stop_streaming(struct msm_vidc_inst *inst, struct vb2_queue *q)
|
|||||||
msm_vidc_flush_buffer_stats(inst);
|
msm_vidc_flush_buffer_stats(inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* print internal buffer memory usage stats */
|
||||||
|
msm_vidc_print_memory_stats(inst);
|
||||||
|
|
||||||
i_vpr_h(inst, "Streamoff: %s successful\n", v4l2_type_name(q->type));
|
i_vpr_h(inst, "Streamoff: %s successful\n", v4l2_type_name(q->type));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user