]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
sched,psi: Handle potential task count underflow bugs more gracefully
authorCharan Teja Reddy <charante@codeaurora.org>
Fri, 16 Apr 2021 15:02:16 +0000 (20:32 +0530)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 19 May 2021 08:32:17 +0000 (10:32 +0200)
commita1e022b0c79a8df98e275a461d1de34d01e713d8
treed305ed6f6f900de872a8d1076e8c7feb40ec7a6e
parent0dabfe8be4f21cff233b9e03d1c9f690b4824029
sched,psi: Handle potential task count underflow bugs more gracefully

BugLink: https://bugs.launchpad.net/bugs/1928857
[ Upstream commit 9d10a13d1e4c349b76f1c675a874a7f981d6d3b4 ]

psi_group_cpu->tasks, represented by the unsigned int, stores the
number of tasks that could be stalled on a psi resource(io/mem/cpu).
Decrementing these counters at zero leads to wrapping which further
leads to the psi_group_cpu->state_mask is being set with the
respective pressure state. This could result into the unnecessary time
sampling for the pressure state thus cause the spurious psi events.
This can further lead to wrong actions being taken at the user land
based on these psi events.

Though psi_bug is set under these conditions but that just for debug
purpose. Fix it by decrementing the ->tasks count only when it is
non-zero.

Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Link: https://lkml.kernel.org/r/1618585336-37219-1-git-send-email-charante@codeaurora.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
kernel/sched/psi.c