Re: [PATCH RESEND v4] selftests/cgroup: Adjust cpu test duration based on HZ

From: Michal Koutný

Date: Fri Jun 26 2026 - 12:45:15 EST


On Thu, Jun 25, 2026 at 04:33:04PM -0400, Joe Simmons-Talbott <joest@xxxxxxxxxx> wrote:
> static int test_cpucg_max_nested(const char *root)
> {
> int ret = KSFT_FAIL;
> + long hz = get_config_hz();
> long quota_usec = 1000;
> long default_period_usec = 100000; /* cpu.max's default period */
> long duration_seconds = 1;
>
> - long duration_usec = duration_seconds * USEC_PER_SEC;
> + long duration_usec, duration_sec, duration_nsec;
> long usage_usec, n_periods, remainder_usec, expected_usage_usec;
> char *parent, *child;
> char quota_buf[32];
>
> + duration_usec = duration_seconds * USEC_PER_SEC * 1000 / hz;
> + duration_sec = duration_usec / USEC_PER_SEC;
> + duration_nsec = duration_usec % USEC_PER_SEC * NSEC_PER_USEC;

Oh, that's duration in so many units and the seconds is there twice. (I
understand why you did that for the rescale but) could you pick more
descriptive/distinctive names then and ideally keep it simple :-p

Thanks,
Michal

Attachment: signature.asc
Description: PGP signature