static void update_curr(struct cfs_rq *cfs_rq) { struct sched_entity *curr = cfs_rq->curr; u64 now = rq_of(cfs_rq)->clock; unsigned long delta_exec; if (unlikely(!curr)) return; /* * Get the amount of time the current task was running * since the last time we changed load (this cannot * overflow on 32 bits): */ delta_exec = (unsigned long)(now - curr->exec_start); if (!delta_exec) return; __update_curr(cfs_rq, curr, delta_exec); curr->exec_start = now; if (entity_is_task(curr)) { struct task_struct *curtask = task_of(curr); trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime); cpuacct_charge(curtask, delta_exec); account_group_exec_runtime(curtask, delta_exec); } }
/* * Update the current hwardware task's runtime statistics. Skip current tasks that * are not in our scheduling class. */ static void update_hw(struct cfs_rq *cfs_rq, struct sched_entity *curr) { /* The ->rq pointer is being set by alloc */ u64 now = rq_of_hw(cfs_rq)->clock; unsigned long delta_exec; if (unlikely(!curr)) return; /* * Idly try to set curr to the given se for the following commands * If curr is being reset during the following command chain that is * ignored up to now */ cfs_rq->curr = curr; /* * Get the amount of time the current task was running * since the last time we changed load (this cannot * overflow on 32 bits): */ delta_exec = (unsigned long)(now - curr->exec_start); if (!delta_exec) return; __update_curr(cfs_rq, curr, delta_exec); curr->exec_start = now; }