From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 6F5685A004E for ; Fri, 26 Jul 2024 01:16:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1721949365; bh=5H67Mb83RBE9BT8MD67SXQob11Utu4XFGVJUx9s/4hI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PxszoXjucPhJbeoW1QZZEPK5VQjWbMR4Lmb/i5zASnTGjiwBWpvYcjNXUWbAKgVAZ t6rkeYMd9a2TzFVnpPnu2oG3UQD1fN883nFHWjmXWhw3UKkuFK29Bogjsoh/Ie9JEh KibLP22f2HdU/86anSP5n127RnBuk/la3sWEfCBmJo/rHuHTL64lReocnBLOuV5a5M b8n4G2kccsUmDesI1KEEWTctQ/XaTjFfhjC0WG/f07iCifz4ZmFKHSHGqFWSVJPDV2 gw4djm+qdoD8k/hnfgIafyk1aqKPqAkdSwdwNKge9+LDT/IjaXjyXFWdClbukCDNi7 oGwClzvWvsxrA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WVRZs00b0z4wcK; Fri, 26 Jul 2024 09:16:04 +1000 (AEST) Date: Fri, 26 Jul 2024 09:15:59 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 3/3] log: Fetch log times with CLOCK_MONOTONIC, not CLOCK_REALTIME Message-ID: References: <20240725162634.107697-1-sbrivio@redhat.com> <20240725162634.107697-4-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2+F52i+viPgwTRLy" Content-Disposition: inline In-Reply-To: <20240725162634.107697-4-sbrivio@redhat.com> Message-ID-Hash: X7TLBWK5EQHIAVSHNPNLQAAWJLV6PWCN X-Message-ID-Hash: X7TLBWK5EQHIAVSHNPNLQAAWJLV6PWCN X-MailFrom: dgibson@gandalf.ozlabs.org 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 CC: passt-dev@passt.top 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: --2+F52i+viPgwTRLy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > Suggested-by: David Gibson > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson I noticed another pre-existing nit, though.. > --- > log.c | 4 ++-- > passt.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) >=20 > 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; > =20 > 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; > =20 > - 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; > =20 > n =3D 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; > =20 > - clock_gettime(CLOCK_REALTIME, &log_start); > + clock_gettime(CLOCK_MONOTONIC, &log_start); > =20 > arch_avx2_exec(argv); > =20 --=20 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 --2+F52i+viPgwTRLy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmai3K4ACgkQzQJF27ox 2GfZzRAAkS5wXReX3hluIe6ZCNa+bSJINBUfS5xmdToMuLzZKaNmK0EdW12MU1gs 0DTg7pdzfFLTdB3Q6d+jtKJ5lD629MUkEPA0HCSCAUf9whMx/ViEuTydh1gICsrI IYe3yOImgJLxRJJVTgE4pU5MO2nrs6tNGoUs59GnxSBU0cF/5tmddZ+7vxMFMepo eQ6Z4QOg0Rn7f2b8Oj76YBajF+T+LjtupwGgbCl5is3rDqe2/CV6xyulZpgCG38J NupAEp0lJnaVg3tM/x6rwQOwFFhob6oKPepnO03XRgRyg7VvRCbXX4N7pOLsbjqe b4VWaayT/FGuM3AiPC+Ox1xM5QqvopOES++dRuoox6IPLqAdfnd6m6Elc5yM251L eezyZWcVOfxmpk+7VNIYUhrSGgjsjaGilSYcpj/DQiTof0AHbmT2WBEbVt/7GT8o AXDebNeSJsRowvxAgfgDQXINPYlHbf6wK7eBUCOcjxvZJLrCCi9hVhh/MtwU86Mk vKfmf6Qyy5cQw8F7ocg9G1tnlQv4o8ldsAWVmzKy7CXsOFCSZGq3f97/QfL9dDJY SCCFAm6FBQIR3/l1zhUXi9gMa9pZ1jeWzgMQD/mVEyTXLfVmPODlIzNpBxmU6KZ0 XHzR2hHZdf84wdoydL+Ealx/0KBYYwhM97iiMDFneVOravTBBkw= =X+gJ -----END PGP SIGNATURE----- --2+F52i+viPgwTRLy--