ANDROID: sched/fair: Do not sync task util with SD_BALANCE_FORK

When android_rvh_select_task_rq_fair is enabled,
the woken-up new fair task's utilization is always updated in
a wakeup path (wake_up_new_task) although it doesn't have to be.
It is because sync_entity_load_avg() is always called in
select_task_rq_fair() with the hook enabled.

Let's see what happened:

The new task's sched_avg->last_update_time should be 0
unless it is updated in attach_entity_cfs_rq() in the wakeup path.

But because sync_entity_load_avg() is called,
sched_avg->last_update_time is updated with cfs_rq->avg.last_update_time
before attach_entity_cfs_rq() is called.

After updated, post_init_entity_util_avg() is called and the half of
spare capacity of rq which the task is assigned to is set to the task's
utilization.

Finally, update_load_avg() is called and check the task's
sched_avg->last_update_time, and update the task's utilization due to
non-zero last_update_time.

- wake_up_new_task()
  - select_task_rq() <-- task's sched_avg->last_update_time is set
  			 if android_rvh_select_task_rq_fair is enabled.
  - post_init_entity_util_avg() <-- task gets the half of spare cap.
    - attach_entity_cfs_rq()
      - update_load_avg <-- update task's utiliztion because
                            task's sched_avg->last_update_time is not 0.

Make sure not to call sync_entity_load_avg() in select_task_rq_fair()
when SD_BALANCE_FORK is also set with the hook.

Bug: 183306209

Signed-off-by: Choonghoon Park <choong.park@samsung.com>
Change-Id: I1fd70bf3d8e5fe1548f2237afd2d3d81134a68ee
This commit is contained in:
Choonghoon Park 2021-03-22 09:54:41 +09:00
parent e26fd78761
commit f25741f047

View File

@ -6801,7 +6801,8 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
int sync = (wake_flags & WF_SYNC) && !(current->flags & PF_EXITING);
int target_cpu = -1;
if (trace_android_rvh_select_task_rq_fair_enabled())
if (trace_android_rvh_select_task_rq_fair_enabled() &&
!(sd_flag & SD_BALANCE_FORK))
sync_entity_load_avg(&p->se);
trace_android_rvh_select_task_rq_fair(p, prev_cpu, sd_flag,
wake_flags, &target_cpu);