Commit 548a5b0f authored by Cruz Zhao's avatar Cruz Zhao Committed by Zheng Zengkai
Browse files

sched/core: Fix the bug that task won't enqueue into core tree when update cookie

mainline inclusion
from mainline-v6.0-rc1
commit 91caa5ae
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5OOWG
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=91caa5ae242465c3ab9fd473e50170faa7e944f4



--------------------------------------------------------------------------

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: 6e33cad0("sched: Trivial core scheduling cookie management")
Signed-off-by: default avatarCruz Zhao <CruzZhao@linux.alibaba.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1656403045-100840-2-git-send-email-CruzZhao@linux.alibaba.com


Conflicts:
	kernel/sched/core_sched.c
	[Feature 4feee7d1("sched/core: Forced idle accounting") is not applied.]
Signed-off-by: default avatarLin Shengwang <linshengwang1@huawei.com>
Reviewed-by: default avatarlihua <hucool.lihua@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 54e68ff1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment