]> git.baikalelectronics.ru Git - kernel.git/commit
sched/core: Fix the bug that task won't enqueue into core tree when update cookie
authorCruz Zhao <CruzZhao@linux.alibaba.com>
Tue, 28 Jun 2022 07:57:23 +0000 (15:57 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 21 Jul 2022 08:39:39 +0000 (10:39 +0200)
commit016c5d1c3310972c4664abbc43019f9b9656a822
tree4fdeb5b61871c6bb1049644e1f1ef9c0e4ebaee2
parent2b4ce33eaa092d486d6a30085846f7a79e171370
sched/core: Fix the bug that task won't enqueue into core tree when update cookie

In function sched_core_update_cookie(), a task will enqueue into the
core tree only when it enqueued before, that is, if an uncookied task
is cookied, it will not enqueue into the core tree until it enqueue
again, which will result in unnecessary force idle.

Here follows the scenario:
  CPU x and CPU y are a pair of SMT siblings.
  1. Start task a running on CPU x without sleeping, and task b and
     task c running on CPU y without sleeping.
  2. We create a cookie and share it to task a and task b, and then
     we create another cookie and share it to task c.
  3. Simpling core_forceidle_sum of task a and b from /proc/PID/sched

And we will find out that core_forceidle_sum of task a takes 30%
time of the sampling period, which shouldn't happen as task a and b
have the same cookie.

Then we migrate task a to CPU x', migrate task b and c to CPU y', where
CPU x' and CPU y' are a pair of SMT siblings, and sampling again, we
will found out that core_forceidle_sum of task a and b are almost zero.

To solve this problem, we enqueue the task into the core tree if it's
on rq.

Fixes: 9e93437f3275("sched: Trivial core scheduling cookie management")
Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1656403045-100840-2-git-send-email-CruzZhao@linux.alibaba.com
kernel/sched/core_sched.c