video: rockchip: rve: Optimize statistics on bandwidth & cycle

Signed-off-by: Li Huang <putin.li@rock-chips.com>
Change-Id: I9260b41adbc5a1a0bab6be099fd40971324586ce
This commit is contained in:
Li Huang
2022-03-29 14:40:18 +08:00
committed by Tao Huang
parent c2a93573e4
commit 0949545400
6 changed files with 45 additions and 10 deletions

View File

@@ -159,6 +159,10 @@ struct rve_sche_pid_info_t {
pid_t pid;
/* hw total use time, per hrtimer */
u32 hw_time_total;
uint32_t last_job_rd_bandwidth;
uint32_t last_job_wr_bandwidth;
uint32_t last_job_cycle_cnt;
};
struct rve_sche_session_info_t {

View File

@@ -82,7 +82,7 @@ int rve_init_reg(struct rve_job *job);
int rve_get_version(struct rve_scheduler_t *scheduler);
void rve_dump_read_back_reg(struct rve_scheduler_t *scheduler);
void rve_get_monitor_info(struct rve_scheduler_t *scheduler);
void rve_get_monitor_info(struct rve_job *job);
#endif

View File

@@ -171,11 +171,18 @@ static int rve_load_show(struct seq_file *m, void *data)
load = (busy_time_total * 100000 / RVE_LOAD_INTERVAL);
seq_printf(m, "\t load = %d\n", load);
seq_printf(m, "-----------------------------------\n");
seq_printf(m, "---------------- PID INFO ---------------\n");
for (i = 0; i < RVE_MAX_PID_INFO; i++) {
seq_printf(m, "\t [pid: %d] hw_time_total = %llu us\n",
pid_info[i].pid, ktime_to_us(pid_info[i].hw_time_total));
seq_printf(m, "\t\t last_job_rd_bandwidth: %u bytes/s\n",
pid_info[i].last_job_rd_bandwidth);
seq_printf(m, "\t\t last_job_wr_bandwidth: %u bytes/s\n",
pid_info[i].last_job_wr_bandwidth);
seq_printf(m, "\t\t last_job_cycle_cnt/s: %u\n",
pid_info[i].last_job_cycle_cnt);
}
return 0;
}

View File

@@ -66,6 +66,11 @@ static enum hrtimer_restart hrtimer_handler(struct hrtimer *timer)
scheduler->timer.busy_time_record = scheduler->timer.busy_time;
scheduler->timer.busy_time = 0;
/* monitor */
scheduler->session.rd_bandwidth = 0;
scheduler->session.wr_bandwidth = 0;
scheduler->session.cycle_cnt = 0;
for (i = 0; i < RVE_MAX_PID_INFO; i++) {
if (scheduler->session.pid_info[i].pid > 0)
scheduler->session.pid_info[i].hw_time_total = 0;
@@ -80,9 +85,6 @@ static enum hrtimer_restart hrtimer_handler(struct hrtimer *timer)
idr_for_each(&ctx_manager->ctx_id_idr, &rve_ctx_set_debuf_info_cb, ctx_manager);
spin_unlock_irqrestore(&ctx_manager->lock, flags);
/* monitor */
rve_get_monitor_info(scheduler);
}
hrtimer_forward_now(timer, kt);

View File

@@ -398,8 +398,10 @@ void rve_job_done(struct rve_scheduler_t *scheduler, int ret)
error_flag = rve_read(RVE_SWREG6_IVE_WORK_STA, scheduler);
rve_get_monitor_info(job);
if (DEBUGGER_EN(MSG))
pr_err("irq thread work_status[%.8x]\n", error_flag);
pr_info("irq thread work_status[%.8x]\n", error_flag);
/* disable llp enable, TODO: support pause mode */
rve_write(0, RVE_SWLTB3_ENABLE, scheduler);

View File

@@ -8,6 +8,7 @@
#define pr_fmt(fmt) "rve_reg: " fmt
#include "rve_reg.h"
#include "rve_job.h"
void rve_soft_reset(struct rve_scheduler_t *scheduler)
{
@@ -232,10 +233,16 @@ int rve_get_version(struct rve_scheduler_t *scheduler)
return 0;
}
void rve_get_monitor_info(struct rve_scheduler_t *scheduler)
void rve_get_monitor_info(struct rve_job *job)
{
struct rve_sche_pid_info_t *pid_info = NULL;
struct rve_scheduler_t *scheduler = NULL;
unsigned long flags;
uint32_t rd_bandwidth, wr_bandwidth, cycle_cnt;
int i;
scheduler = rve_job_get_scheduler(job);
pid_info = scheduler->session.pid_info;
/* monitor */
if (DEBUGGER_EN(MONITOR)) {
@@ -248,9 +255,22 @@ void rve_get_monitor_info(struct rve_scheduler_t *scheduler)
spin_lock_irqsave(&scheduler->irq_lock, flags);
scheduler->session.rd_bandwidth = rd_bandwidth;
scheduler->session.wr_bandwidth = wr_bandwidth;
scheduler->session.cycle_cnt = cycle_cnt;
for (i = 0; i < RVE_MAX_PID_INFO; i++) {
if (pid_info[i].pid == job->pid) {
pid_info[i].last_job_rd_bandwidth = rd_bandwidth;
pid_info[i].last_job_wr_bandwidth = wr_bandwidth;
pid_info[i].last_job_cycle_cnt = cycle_cnt;
break;
}
}
if (DEBUGGER_EN(MSG))
pr_info("rd_bandwidth = %d, wd_bandwidth = %d, cycle_cnt = %d\n",
rd_bandwidth, wr_bandwidth, cycle_cnt);
scheduler->session.rd_bandwidth += rd_bandwidth;
scheduler->session.wr_bandwidth += wr_bandwidth;
scheduler->session.cycle_cnt += cycle_cnt;
spin_unlock_irqrestore(&scheduler->irq_lock, flags);
}