[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ftydqeu3zxmgdvkz6f4jrf4qyrs72ar7jc4j3khlkyi4mditfe@g62znohovca7>
Date: Thu, 14 Aug 2025 18:18:47 +0200
From: Michal Koutný <mkoutny@...e.com>
To: Tiffany Yang <ynaffit@...gle.com>
Cc: linux-kernel@...r.kernel.org, John Stultz <jstultz@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>, Stephen Boyd <sboyd@...nel.org>,
Anna-Maria Behnsen <anna-maria@...utronix.de>, Frederic Weisbecker <frederic@...nel.org>,
Tejun Heo <tj@...nel.org>, Johannes Weiner <hannes@...xchg.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, Pavel Machek <pavel@...nel.org>,
Roman Gushchin <roman.gushchin@...ux.dev>, Chen Ridong <chenridong@...wei.com>, kernel-team@...roid.com,
Jonathan Corbet <corbet@....net>, Shuah Khan <shuah@...nel.org>, cgroups@...r.kernel.org,
linux-doc@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [RFC PATCH v3 2/2] cgroup: selftests: Add tests for freezer time
On Mon, Aug 04, 2025 at 08:29:42PM -0700, Tiffany Yang <ynaffit@...gle.com> wrote:
> +static int test_cgfreezer_time_empty(const char *root)
> +{
> + int ret = KSFT_FAIL;
> + char *cgroup = NULL;
> + long prev, curr;
> + int i;
> +
> + cgroup = cg_name(root, "cg_time_test_empty");
> + if (!cgroup)
> + goto cleanup;
> +
> + /*
> + * 1) Create an empty cgroup and check that its freeze time
> + * is 0.
> + */
> + if (cg_create(cgroup))
> + goto cleanup;
> +
> + curr = cg_check_freezetime(cgroup);
> + if (curr) {
> + if (curr < 0)
> + ret = KSFT_SKIP;
> + else
> + debug("Expect time (%ld) to be 0\n", curr);
> +
> + goto cleanup;
> + }
if (curr < 0) {
ret = KSFT_SKIP;
goto cleanup;
}
if (curr > 0) {
debug("Expect time (%ld) to be 0\n", curr);
goto cleanup;
}
I might like the version with less indentation and explicit guards. It's
only minor stylistic issue.
> +
> + /*
> + * 2) Freeze the cgroup. Check that its freeze time is
> + * larger than 0.
> + */
> + if (cg_freeze_nowait(cgroup, true))
> + goto cleanup;
> + prev = curr;
> + curr = cg_check_freezetime(cgroup);
> + if (curr <= prev) {
Here and...
> + debug("Expect time (%ld) > 0\n", curr);
> + goto cleanup;
> + }
> +
> + /*
> + * 3) Sleep for 100 us. Check that the freeze time is at
> + * least 100 us larger than it was at 2).
> + */
> + usleep(100);
> + prev = curr;
> + curr = cg_check_freezetime(cgroup);
> + if ((curr - prev) < 100) {
...here
I'm slightly worried it may cause test flakiness on systems with too
coarse clock granularity.
Is the first check anyhow meaningful? (I think it's only as strong as
checking return value of the preceding write(2) to cgroup.freeze.)
Would it compromise your use case if the latter check was at least
1000 μs (based on other usleeps in cgroup selftests)? (Ditto for other
100 μs checks.)
Or does anything guarantee the minimal precision in common selftest
environments?
Thanks,
Michal
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists