OSDN Git Service

psi: Fix cpu.pressure for cpu.max and competing cgroups
authorJohannes Weiner <hannes@cmpxchg.org>
Mon, 16 Mar 2020 19:13:31 +0000 (15:13 -0400)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 20 Mar 2020 12:06:18 +0000 (13:06 +0100)
commitb05e75d611380881e73edc58a20fd8c6bb71720b
tree3d641b57b42e934d7518f22a13f3a74cd76f6ff7
parent46a87b3851f0d6eb05e6d83d5c5a30df0eca8f76
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
include/linux/psi_types.h
kernel/sched/core.c
kernel/sched/psi.c
kernel/sched/stats.h