sched: Add update_current_exec_runtime helper
Wrap repeated code in helper function update_current_exec_runtime for update the exec time of the current. Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20220824082856.15674-1-shangxiaojing@huawei.com
This commit is contained in:
parent
e4fe074d6c
commit
5531ecffa4
|
@ -1333,11 +1333,7 @@ static void update_curr_dl(struct rq *rq)
|
||||||
|
|
||||||
trace_sched_stat_runtime(curr, delta_exec, 0);
|
trace_sched_stat_runtime(curr, delta_exec, 0);
|
||||||
|
|
||||||
curr->se.sum_exec_runtime += delta_exec;
|
update_current_exec_runtime(curr, now, delta_exec);
|
||||||
account_group_exec_runtime(curr, delta_exec);
|
|
||||||
|
|
||||||
curr->se.exec_start = now;
|
|
||||||
cgroup_account_cputime(curr, delta_exec);
|
|
||||||
|
|
||||||
if (dl_entity_is_special(dl_se))
|
if (dl_entity_is_special(dl_se))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1062,11 +1062,7 @@ static void update_curr_rt(struct rq *rq)
|
||||||
|
|
||||||
trace_sched_stat_runtime(curr, delta_exec, 0);
|
trace_sched_stat_runtime(curr, delta_exec, 0);
|
||||||
|
|
||||||
curr->se.sum_exec_runtime += delta_exec;
|
update_current_exec_runtime(curr, now, delta_exec);
|
||||||
account_group_exec_runtime(curr, delta_exec);
|
|
||||||
|
|
||||||
curr->se.exec_start = now;
|
|
||||||
cgroup_account_cputime(curr, delta_exec);
|
|
||||||
|
|
||||||
if (!rt_bandwidth_enabled())
|
if (!rt_bandwidth_enabled())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3158,4 +3158,14 @@ extern int sched_dynamic_mode(const char *str);
|
||||||
extern void sched_dynamic_update(int mode);
|
extern void sched_dynamic_update(int mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline void update_current_exec_runtime(struct task_struct *curr,
|
||||||
|
u64 now, u64 delta_exec)
|
||||||
|
{
|
||||||
|
curr->se.sum_exec_runtime += delta_exec;
|
||||||
|
account_group_exec_runtime(curr, delta_exec);
|
||||||
|
|
||||||
|
curr->se.exec_start = now;
|
||||||
|
cgroup_account_cputime(curr, delta_exec);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _KERNEL_SCHED_SCHED_H */
|
#endif /* _KERNEL_SCHED_SCHED_H */
|
||||||
|
|
|
@ -71,20 +71,17 @@ static void yield_task_stop(struct rq *rq)
|
||||||
static void put_prev_task_stop(struct rq *rq, struct task_struct *prev)
|
static void put_prev_task_stop(struct rq *rq, struct task_struct *prev)
|
||||||
{
|
{
|
||||||
struct task_struct *curr = rq->curr;
|
struct task_struct *curr = rq->curr;
|
||||||
u64 delta_exec;
|
u64 now, delta_exec;
|
||||||
|
|
||||||
delta_exec = rq_clock_task(rq) - curr->se.exec_start;
|
now = rq_clock_task(rq);
|
||||||
|
delta_exec = now - curr->se.exec_start;
|
||||||
if (unlikely((s64)delta_exec < 0))
|
if (unlikely((s64)delta_exec < 0))
|
||||||
delta_exec = 0;
|
delta_exec = 0;
|
||||||
|
|
||||||
schedstat_set(curr->stats.exec_max,
|
schedstat_set(curr->stats.exec_max,
|
||||||
max(curr->stats.exec_max, delta_exec));
|
max(curr->stats.exec_max, delta_exec));
|
||||||
|
|
||||||
curr->se.sum_exec_runtime += delta_exec;
|
update_current_exec_runtime(curr, now, delta_exec);
|
||||||
account_group_exec_runtime(curr, delta_exec);
|
|
||||||
|
|
||||||
curr->se.exec_start = rq_clock_task(rq);
|
|
||||||
cgroup_account_cputime(curr, delta_exec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue