From: Cyril Hrubis <chrubis@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
Eirik Fuller <efuller@redhat.com>, Waiman Long <llong@redhat.com>,
LTP List <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH] clock_gettime04: set threshold based on the clock tick rate
Date: Mon, 28 Mar 2022 10:58:13 +0200 [thread overview]
Message-ID: <YkF4pVQXMqEO32r2@yuki> (raw)
In-Reply-To: <CAEemH2fVf8tMbY4R_O-BrSy7vtmyGgNq3NbYF=LfjyHDbDgkBg@mail.gmail.com>
Hi!
> > clock_getres(CLOCK_REALTIME_COARSE, &res);
> >
> > delta = 5 + (res.tv_nsec / 1000000) * 5;
> >
>
> Sounds reasonable.
>
> But I don't understand why you multiply 5 for the resolution
> (in milliseconds) here. Or, a wiser choice is to get the real
> resolution for each clockid? i.e.
I did multiply it with 5 just to add some error margin. I guess that we
can as well multiply it with 2 if that works well enough.
I do not think that we should get resolution for each clock, the COARSE
clock should have the worst resolution of all clocks.
> --- a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
> +++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c
> @@ -92,23 +92,27 @@ static struct time64_variants variants[] = {
>
> static void setup(void)
> {
> - delta = 1000/sysconf(_SC_CLK_TCK) + 5;
> - if (tst_is_virt(VIRT_ANY)) {
> - tst_res(TINFO, "Running in a virtual machine, multiply the
> delta by 10.");
> - delta *= 10;
> - }
> -
> find_clock_gettime_vdso(&ptr_vdso_gettime, &ptr_vdso_gettime64);
> }
>
> static void run(unsigned int i)
> {
> struct tst_ts ts;
> + struct timespec res;
> long long start, end = 0, diff, slack;
> struct time64_variants *tv;
> int count = 10000, ret;
> unsigned int j;
>
> + clock_getres(clks[i], &res);
> + tst_res(TINFO, "%s: resolution is %ldns", tst_clock_name(clks[i]),
> res.tv_nsec);
> +
> + delta = 5 + res.tv_nsec/1000000;
> + if (tst_is_virt(VIRT_ANY)) {
> + delta *= 10;
> + tst_res(TINFO, "Multiply the delta by 10 in virtual
> machine: %lld", delta);
> + }
> +
> do {
> for (j = 0; j < ARRAY_SIZE(variants); j++) {
> /* Refresh time in start */
>
> --
> Regards,
> Li Wang
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-03-28 8:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 4:00 [LTP] [PATCH] clock_gettime04: set threshold based on the clock tick rate Li Wang
2022-03-25 10:13 ` Cyril Hrubis
2022-03-26 13:17 ` Li Wang
2022-03-28 8:58 ` Cyril Hrubis [this message]
2022-03-28 9:54 ` Li Wang
2022-03-28 10:13 ` Li Wang
2022-03-28 10:24 ` Li Wang
2022-03-28 12:41 ` Cyril Hrubis
2022-03-25 14:26 ` Waiman Long
2022-03-26 13:28 ` Li Wang
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=YkF4pVQXMqEO32r2@yuki \
--to=chrubis@suse.cz \
--cc=efuller@redhat.com \
--cc=liwang@redhat.com \
--cc=llong@redhat.com \
--cc=ltp@lists.linux.it \
--cc=viresh.kumar@linaro.org \
/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.