ANDROID: mm, oom: Prevent extra put_task when oom_evaluate_task is aborted

The previous fix for the oom_evaluate_task abort case leads to an extra
put_task_struct call on oc->chosen_non_negative_adj. Fix this by
resetting oc->chosen_non_negative_adj and avoiding the whole negative
ADJ logic altogether.
Fixes: aef918d19a ("ANDROID: mm, oom: Fix select_bad_process customization")

Bug: 180947519
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I5d649baac17daf1778a198be354823aa0b6a55b4
This commit is contained in:
Suren Baghdasaryan 2021-02-23 12:11:51 -08:00
parent 7ccd5a5389
commit b9b4582292

View File

@ -372,6 +372,7 @@ static int oom_evaluate_task(struct task_struct *task, void *arg)
put_task_struct(oc->chosen_non_negative_adj);
if (oc->chosen)
put_task_struct(oc->chosen);
oc->chosen_non_negative_adj = NULL;
oc->chosen = (void *)-1UL;
return 1;
}
@ -404,8 +405,7 @@ static void select_bad_process(struct oom_control *oc)
* a postive ADJ to kill, kill the task with the positive ADJ
* instead.
*/
if (oc->chosen && oc->chosen != (void *)-1UL &&
oc->chosen->signal->oom_score_adj < 0) {
if (oc->chosen && oc->chosen->signal->oom_score_adj < 0) {
put_task_struct(oc->chosen);
oc->chosen = oc->chosen_non_negative_adj;
oc->chosen_points = oc->chosen_non_negative_adj_points;