]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests: cgroup: Add cg_read_key_long_poll() to poll a cgroup key with retries
authorGuopeng Zhang <zhangguopeng@kylinos.cn>
Wed, 3 Dec 2025 11:56:29 +0000 (19:56 +0800)
committerTejun Heo <tj@kernel.org>
Mon, 8 Dec 2025 18:44:54 +0000 (08:44 -1000)
commit311ead1be05d2348e89f873337c8375e856e1abb
tree7bd5f66f4ef12c999dac7355591cbd7565d00278
parent3309b63a2281efb72df7621d60cc1246b6286ad3
selftests: cgroup: Add cg_read_key_long_poll() to poll a cgroup key with retries

Introduce a new helper function `cg_read_key_long_poll()` in
cgroup_util.h. This function polls the specified key in a cgroup file
until it matches the expected value or the retry limit is reached,
with configurable wait intervals between retries.

This helper is particularly useful for handling asynchronously updated
cgroup statistics (e.g., memory.stat), where immediate reads may
observe stale values, especially on busy systems. It allows tests and
other utilities to handle such cases more flexibly.

Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
Suggested-by: Michal Koutný <mkoutny@suse.com>
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
tools/testing/selftests/cgroup/lib/cgroup_util.c
tools/testing/selftests/cgroup/lib/include/cgroup_util.h