[v3,3/3] sched/fair: Simplify update_curr()

Message ID 20231031125928.235685-4-yajun.deng@linux.dev
State New
Headers
Series Use update_current_exec_runtime simplify code |

Commit Message

Yajun Deng Oct. 31, 2023, 12:59 p.m. UTC
  Use update_current_exec_runtime() simplify update_curr().

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
v3: New patch.
---
 kernel/sched/fair.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
  

Patch

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2048138ce54b..ffc000e49db5 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1135,6 +1135,7 @@  static void update_tg_load_avg(struct cfs_rq *cfs_rq)
 static void update_curr(struct cfs_rq *cfs_rq)
 {
 	struct sched_entity *curr = cfs_rq->curr;
+	struct task_struct *curtask = rq_of(cfs_rq)->curr;
 	u64 now = rq_clock_task(rq_of(cfs_rq));
 	u64 delta_exec;
 
@@ -1145,8 +1146,6 @@  static void update_curr(struct cfs_rq *cfs_rq)
 	if (unlikely((s64)delta_exec <= 0))
 		return;
 
-	curr->exec_start = now;
-
 	if (schedstat_enabled()) {
 		struct sched_statistics *stats;
 
@@ -1155,20 +1154,14 @@  static void update_curr(struct cfs_rq *cfs_rq)
 				max(delta_exec, stats->exec_max));
 	}
 
-	curr->sum_exec_runtime += delta_exec;
 	schedstat_add(cfs_rq->exec_clock, delta_exec);
 
 	curr->vruntime += calc_delta_fair(delta_exec, curr);
 	update_deadline(cfs_rq, curr);
 	update_min_vruntime(cfs_rq);
 
-	if (entity_is_task(curr)) {
-		struct task_struct *curtask = task_of(curr);
-
-		trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
-		cgroup_account_cputime(curtask, delta_exec);
-		account_group_exec_runtime(curtask, delta_exec);
-	}
+	update_current_exec_runtime(curtask, now, delta_exec,
+				    entity_is_task(curr));
 
 	account_cfs_rq_runtime(cfs_rq, delta_exec);
 }