sched/psi: Cache parent psi_group to speed up group iteration
authorChengming Zhou <zhouchengming@bytedance.com>
Thu, 25 Aug 2022 16:41:10 +0000 (00:41 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 9 Sep 2022 09:08:33 +0000 (11:08 +0200)
commitdc86aba751e2867244411adda1562f6664747019
treea3da212be6c190b5585ee4f9761c4177ad4f19c6
parent57899a6610e67ba26fa3251ebbef4a5ed21efc5d
sched/psi: Cache parent psi_group to speed up group iteration

We use iterate_groups() to iterate each level psi_group to update
PSI stats, which is a very hot path.

In current code, iterate_groups() have to use multiple branches and
cgroup_parent() to get parent psi_group for each level, which is not
very efficient.

This patch cache parent psi_group in struct psi_group, only need to get
psi_group of task itself first, then just use group->parent to iterate.

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Link: https://lore.kernel.org/r/20220825164111.29534-10-zhouchengming@bytedance.com
include/linux/psi_types.h
kernel/sched/psi.c