From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: Steve <xufeifei1@oppo.com>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] sched: starvation: Autocallibrate the timeout
Date: Wed, 12 Jun 2024 14:21:20 +0200 [thread overview]
Message-ID: <20240612122120.GA118569@pevik> (raw)
In-Reply-To: <20240612112311.10334-1-chrubis@suse.cz>
Hi Cyril,
> Instead of hardcoding the values we attempt to measure the CPU speed and
> set the timeout accordingly. Given that the difference in the duration
> of the test when the kernel is buggy is about 30x we do not have to have
> a precise callibration, just very rough estimate if we are running on a
> server or small ARM board would suffice.
> So we attempt to measure how long does a bussy loop take and base the
s/bussy/busy/
> default timeout on that. On x86_64 CPUs the resulting timeout is about
> double of the value of the actual test runtime and works fine, but we
> need to make sure that the coeficient we divide the result from
> callibrate works for small boards too. So please run the test on as many
> machines as you can and report if we need to make the dividor smaller or
> not.
This looks much better: ppc64le has Timeout per run is 0h 00m 30s (1m 10s
runtime), others (x68_64, s390x, aarch64) have ~ 1 min or less.
Tested-by: Petr Vorel <pvorel@suse.cz>
...
> +static int callibrate(void)
> +{
> + int i;
> + struct timespec start, stop;
> + long long diff;
> +
> + for (i = 0; i < CALLIBRATE_LOOPS; i++) {
> + __asm__ __volatile__ ("" : "+g" (i) : :);
> + }
> +
> + SAFE_CLOCK_GETTIME(CLOCK_MONOTONIC_RAW, &start);
> +
> + for (i = 0; i < CALLIBRATE_LOOPS; i++) {
> + __asm__ __volatile__ ("" : "+g" (i) : :);
> + }
> +
> + SAFE_CLOCK_GETTIME(CLOCK_MONOTONIC_RAW, &stop);
> +
> + diff = tst_timespec_diff_us(stop, start);
> +
> + tst_res(TINFO, "CPU did %i loops in %llius", CALLIBRATE_LOOPS, diff);
> +
> + return diff;
> +}
> static int wait_for_pid(pid_t pid)
> {
> @@ -59,8 +88,11 @@ static void setup(void)
> if (tst_parse_long(str_loop, &loop, 1, LONG_MAX))
> tst_brk(TBROK, "Invalid number of loop number '%s'", str_loop);
> - if (tst_parse_int(str_timeout, &timeout, 1, INT_MAX))
> + if (tst_parse_int(str_timeout, &timeout, 1, INT_MAX)) {
nit: {} brackets are not needed.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> tst_brk(TBROK, "Invalid number of timeout '%s'", str_timeout);
> + } else {
> + timeout = callibrate() / 1000;
> + }
> tst_set_max_runtime(timeout);
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-06-12 12:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 11:23 [LTP] [PATCH v2] sched: starvation: Autocallibrate the timeout Cyril Hrubis
2024-06-12 12:21 ` Petr Vorel [this message]
2024-06-12 18:22 ` Cyril Hrubis
2024-06-13 11:22 ` Anders Roxell
2024-06-27 9:28 ` joe.liu via ltp
2024-06-28 12:49 ` Cyril Hrubis
2024-07-01 9:50 ` joe.liu via ltp
2024-07-02 14:47 ` Cyril Hrubis
2024-07-10 15:55 ` Petr Vorel
2024-07-10 18:12 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240612122120.GA118569@pevik \
--to=pvorel@suse.cz \
--cc=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=xufeifei1@oppo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.