aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2020-03-16 15:13:31 -0400
committerPeter Zijlstra <peterz@infradead.org>2020-03-20 13:06:18 +0100
commitb05e75d611380881e73edc58a20fd8c6bb71720b (patch)
tree3d641b57b42e934d7518f22a13f3a74cd76f6ff7 /kernel/sched/core.c
parentsched/core: Distribute tasks within affinity masks (diff)
downloadwireguard-linux-b05e75d611380881e73edc58a20fd8c6bb71720b.tar.xz
wireguard-linux-b05e75d611380881e73edc58a20fd8c6bb71720b.zip
psi: Fix cpu.pressure for cpu.max and competing cgroups
For simplicity, cpu pressure is defined as having more than one runnable task on a given CPU. This works on the system-level, but it has limitations in a cgrouped reality: When cpu.max is in use, it doesn't capture the time in which a task is not executing on the CPU due to throttling. Likewise, it doesn't capture the time in which a competing cgroup is occupying the CPU - meaning it only reflects cgroup-internal competitive pressure, not outside pressure. Enable tracking of currently executing tasks, and then change the definition of cpu pressure in a cgroup from NR_RUNNING > 1 to NR_RUNNING > ON_CPU which will capture the effects of cpu.max as well as competition from outside the cgroup. After this patch, a cgroup running `stress -c 1` with a cpu.max setting of 5000 10000 shows ~50% continuous CPU pressure. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20200316191333.115523-2-hannes@cmpxchg.org
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 014d4f793313..c1f923d647ee 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4091,6 +4091,8 @@ static void __sched notrace __schedule(bool preempt)
*/
++*switch_count;
+ psi_sched_switch(prev, next, !task_on_rq_queued(prev));
+
trace_sched_switch(preempt, prev, next);
/* Also unlocks the rq: */