Skip to content

Commit

Permalink
anolis: Fix the bug that cfs_rq->h_nr_expel_immune underflow
Browse files Browse the repository at this point in the history
ANBZ: torvalds#378

There are two stages in unthrottle_cfs_rq(), and in the second stage,
cfs_rq->h_nr_expel_immune wasn't updated, and it'll be less than the
actual value.

Once there is only expellee tasks on the cfs_rq, as
cfs_rq->h_nr_expel_immune isn't zero, expellee_only() will return false,
but pick_next_entity() will return NULL as expellee se are moved from
rb_tree to expel_list, which will result that set_next_entity() access
the NULL pointer and then panic.

This patch is to fix this problem.

Fixes: 2df6821("sched/fair: Fix unthrottle_cfs_rq() for leaf_cfs_rq list")
Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com>
Acked-by: Michael Wang <yun.wang@linux.alibaba.com>
  • Loading branch information
Cruz Zhao authored and Cruz Zhao committed Jan 24, 2022
1 parent 87e3403 commit 3c0c767
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -6085,6 +6085,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq)
update_load_avg(cfs_rq, se, UPDATE_TG);

cfs_rq->h_nr_running += task_delta;
update_nr_expel_immune(cfs_rq, se, &immune, ei_delta);

/* end evaluation on encountering a throttled cfs_rq */
if (cfs_rq_throttled(cfs_rq))
Expand Down

0 comments on commit 3c0c767

Please sign in to comment.