We optimized the freezer to reduce redundant loops, and we add helper to make code concise. We tested the following subtree: 0 / | \ \ A B C 1 / | \ \ A B C 2 ..... n / | \ A B C We tested is by following steps: 1. freeze 0 2. unfreeze 0 3. freeze 0 4. freeze 1 We measured the elapsed time(ns). n=10 freeze 0 unfreeze 0 freeze 0 freeze 1 BEFORE 106179390 94016050 110423650 95063770 AFTER 96473608 91054188 94936398 93198510 n=50 freeze 0 unfreeze 0 freeze 0 freeze 1 BEFORE 109506660 105643800 105970220 96948940 AFTER 105244651 97357482 97517358 88466266 n=100 freeze 0 unfreeze 0 freeze 0 freeze 1 BEFORE 127944210 122049330 120988900 101232850 AFTER 117298106 107034146 105696895 91977833 As shown above, after optimizations, we can save elapsed time. By freezing 0 and subsequently freezing 1, the elapsed time is consistent, indicating that our optimizations are highly effective. --- v2: - open code inside the loop of cgroup_freeze instead of inline function. - add helper to make code concise. - remove selftest script(There are hierarchy test in test_freeze.c, I think that is enough for this series). Chen Ridong (3): cgroup/freezer: Reduce redundant traversal for cgroup_freeze cgroup/freezer: Add cgroup CGRP_FROZEN flag update helper cgroup/freezer: Reduce redundant propagation for cgroup_propagate_frozen include/linux/cgroup-defs.h | 6 +- kernel/cgroup/freezer.c | 110 ++++++++++++++++++------------------ 2 files changed, 59 insertions(+), 57 deletions(-) -- 2.34.1