Re: [PATCH RESEND v4] selftests/cgroup: Adjust cpu test duration based on HZ
From: Joe Simmons-Talbott
Date: Fri Jun 26 2026 - 16:19:43 EST
On Fri, Jun 26, 2026 at 06:44:46PM +0200, Michal Koutný wrote:
> 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 for the feedback. I'll send a v5 with those intermediate
variables removed and do the calculatons where they are used to setup
the cpu hog's time values.
Thanks,
Joe