Re: [PATCH v4 1/3] selftests: cgroup: Add cg_read_key_long_poll() to poll a cgroup key with retries

From: Shakeel Butt

Date: Tue Dec 02 2025 - 14:24:51 EST


On Mon, Nov 24, 2025 at 08:38:14PM +0800, Guopeng Zhang wrote:
> 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@xxxxxxxxxx>
> Suggested-by: Michal Koutný <mkoutny@xxxxxxxx>

Reviewed-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>