From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 3/3] log: Fetch log times with CLOCK_MONOTONIC, not CLOCK_REALTIME
Date: Fri, 26 Jul 2024 09:15:59 +1000 [thread overview]
Message-ID: <ZqLcr0k5Nsl4clm-@zatzit> (raw)
In-Reply-To: <20240725162634.107697-4-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2099 bytes --]
On Thu, Jul 25, 2024 at 06:26:34PM +0200, Stefano Brivio wrote:
> We report relative timestamps in logs, so we want to avoid jumps in
> the system time.
>
> Suggested-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
I noticed another pre-existing nit, though..
> ---
> log.c | 4 ++--
> passt.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/log.c b/log.c
> index 9474bad..0fb25b7 100644
> --- a/log.c
> +++ b/log.c
> @@ -68,7 +68,7 @@ void vlogmsg(bool newline, int pri, const char *format, va_list ap)
> struct timespec tp;
>
> if (debug_print) {
> - clock_gettime(CLOCK_REALTIME, &tp);
> + clock_gettime(CLOCK_MONOTONIC, &tp);
> fprintf(stderr, logtime_fmt_and_arg(&tp));
> fprintf(stderr, ": ");
> }
> @@ -382,7 +382,7 @@ void logfile_write(bool newline, int pri, const char *format, va_list ap)
> char buf[BUFSIZ];
> int n;
>
> - if (clock_gettime(CLOCK_REALTIME, &now))
> + if (clock_gettime(CLOCK_MONOTONIC, &now))
We have two separate calls to get the time for "this" message. I
think this means under the right circumstances we could have
essentially the same message logged to different places with
(slightly) different times. That seems needlessly confusing. It
would be nice to have a single point at which we capture the time for
a single message.
> return;
>
> n = snprintf(buf, BUFSIZ, logtime_fmt_and_arg(&now));
> diff --git a/passt.c b/passt.c
> index 72ad704..6401730 100644
> --- a/passt.c
> +++ b/passt.c
> @@ -207,7 +207,7 @@ int main(int argc, char **argv)
> struct timespec now;
> struct sigaction sa;
>
> - clock_gettime(CLOCK_REALTIME, &log_start);
> + clock_gettime(CLOCK_MONOTONIC, &log_start);
>
> arch_avx2_exec(argv);
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-07-25 23:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 16:26 [PATCH 0/3] Fixes for log timestamps Stefano Brivio
2024-07-25 16:26 ` [PATCH 1/3] log, util: Fix sub-second part in relative log time calculation Stefano Brivio
2024-07-25 23:11 ` David Gibson
2024-07-25 16:26 ` [PATCH 2/3] log: Initialise timestamp for relative log time also if we use a log file Stefano Brivio
2024-07-25 16:26 ` [PATCH 3/3] log: Fetch log times with CLOCK_MONOTONIC, not CLOCK_REALTIME Stefano Brivio
2024-07-25 23:15 ` David Gibson [this message]
2024-07-26 9:32 ` Stefano Brivio
2024-07-29 1:12 ` David Gibson
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=ZqLcr0k5Nsl4clm-@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).