sched/walt: fix busy time accounting for tasks moving between groups

Currently the code subtracts busy time when a task is being migrated.
IOW migrate_busy_time_subtraction is called in set_task_cpu hook.

And the code adds busy time in an after-migration enqueue IOW
enqueue_after_migration is seen set in enqueue hook.

Both the above operations happen under the prev_cpu and next cpu rq
lock respt.

Now a task could exit or enter group after the migration and before
the enqueue i.e. transfer_busy_time could be called when
enqueue_after_migration is set. This could lead to -ve load bugs as
we have  only subtracted the load and not added it.

To address this, complete the addition step in
transfer_busy_time() itself,  prior to moving the busy time,
if a task is found to be migrating.

Change-Id: Ifa7a2b017763392431dfa5407ec9dbde76d90019
Signed-off-by: Abhijeet Dharmapurikar <quic_adharmap@quicinc.com>
This commit is contained in:
Abhijeet Dharmapurikar 2022-06-24 14:37:13 -07:00 committed by Sai Harshini Nimmala
parent 2c7855a1a8
commit 8c2844c025

View File

@ -1237,7 +1237,6 @@ static void migrate_busy_time_addition(struct task_struct *p, int new_cpu, u64 w
if (is_ed_enabled() && is_ed_task(p, wallclock))
dest_wrq->ed_task = p;
wts->enqueue_after_migration = 0;
wts->new_cpu = -1;
}
@ -3406,6 +3405,12 @@ static void transfer_busy_time(struct rq *rq,
new_task = is_new_task(p);
if (wts->enqueue_after_migration != 0) {
wallclock = walt_sched_clock();
migrate_busy_time_addition(p, cpu_of(rq), wallclock);
wts->enqueue_after_migration = 0;
}
cpu_time = &wrq->grp_time;
if (event == ADD_TASK) {
migrate_type = RQ_TO_GROUP;
@ -4232,6 +4237,7 @@ static void android_rvh_enqueue_task(void *unused, struct rq *rq, struct task_st
if (wts->enqueue_after_migration != 0) {
wallclock = walt_sched_clock();
migrate_busy_time_addition(p, cpu_of(rq), wallclock);
wts->enqueue_after_migration = 0;
}
wts->prev_on_rq = 1;