summaryrefslogtreecommitdiff
path: root/kernel/sched/sched.h
diff options
context:
space:
mode:
authorShang XiaoJing <shangxiaojing@huawei.com>2022-08-24 11:28:56 +0300
committerPeter Zijlstra <peterz@infradead.org>2022-08-27 01:05:35 +0300
commit5531ecffa4b923bc7739e9ea73c552d80af602dc (patch)
tree5fa795ee0847e07754e96043ee214525dc7c551c /kernel/sched/sched.h
parente4fe074d6c359c19b74564fa1364fe48343cfa5d (diff)
downloadlinux-5531ecffa4b923bc7739e9ea73c552d80af602dc.tar.xz
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
Diffstat (limited to 'kernel/sched/sched.h')
-rw-r--r--kernel/sched/sched.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 74130a69d365..da17be6f27fd 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -3158,4 +3158,14 @@ extern int sched_dynamic_mode(const char *str);
extern void sched_dynamic_update(int mode);
#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 */