[PATCH v1 -next 0/3] Some optimizations about freezer

From: Chen Ridong
Date: Thu Sep 05 2024 - 09:49:59 EST


We optimized the freezer to reduce redundant loops. We add a selftest to
ensure our optimizations cause no harm, and we confirmed that the
performance can be improved.

We tested the following subtree: D, E, F and G each have n children.
A
/ \
B C
/ | \ \
D E F G
/ | \ \
1-n 1-n 1-n 0-n

Our test is to freeze A B C D E F G, and then unfreeze A B C D E F G.
We measured the elapsed time.

BEFORE(ns) AFTER(ns) SAVED(ns)
n=10 142679950 139666014 3,013,936
n=100 199832160 192773032 7,059,128
n=1000 488595100 414901570 73,693,530

As shown above, the larger the value of n, the more significant the time
savings can be. If tested with a deeper hierarchy, the difference could
become even more apparent.

Chen Ridong (3):
cgroup/freezer: Reduce redundant traversal for cgroup_freeze
cgroup/freezer: Reduce redundant propagation for
cgroup_propagate_frozen
cgroup/freezer: Add freeze selftest

include/linux/cgroup-defs.h | 2 +-
kernel/cgroup/freezer.c | 72 ++++++++----
.../testing/selftests/cgroup/test_freezer.sh | 111 ++++++++++++++++++
3 files changed, 160 insertions(+), 25 deletions(-)
create mode 100755 tools/testing/selftests/cgroup/test_freezer.sh

--
2.34.1