From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 2E7B85A031C; Thu, 25 Jul 2024 18:26:34 +0200 (CEST) From: Stefano Brivio To: passt-dev@passt.top, David Gibson Subject: [PATCH 3/3] log: Fetch log times with CLOCK_MONOTONIC, not CLOCK_REALTIME Date: Thu, 25 Jul 2024 18:26:34 +0200 Message-ID: <20240725162634.107697-4-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240725162634.107697-1-sbrivio@redhat.com> References: <20240725162634.107697-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 3O6E6HIX4OJBXP52QYTTB4JWBLCDYNGN X-Message-ID-Hash: 3O6E6HIX4OJBXP52QYTTB4JWBLCDYNGN X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We report relative timestamps in logs, so we want to avoid jumps in the system time. Suggested-by: David Gibson Signed-off-by: Stefano Brivio --- 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)) 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); -- 2.43.0