From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 76F565A031A for ; Mon, 29 Jul 2024 03:16:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1722215760; bh=iftai4NU5zzAUl04QTh+mSagyPVFwW+s0me6imOw2Sg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KudQhTW8XCObmHmVp2W8I+7/OC1Mx32pXI5EW1imwUB/l0C7MPuYbTTjXFMppJPB6 fPMID2S5lQMj1Nbnl6R1NalzqZ06WvcDnyPJBWQtuDhsOULwJRP4kSsi+CDQDc4Idw ZuGm/LSympsqf+1ss5zjapAD/QyxcTh+F5zORuyJzbwGd3CBVh6vFXHcWNDokUE41Y CBbfa1B14wl+BMV0DN8kLsuUW/JHkf40tg1xBgsA+0KABBtQWwXR6lBFVRb142poZW Bq5c0wgEzSdUD7DD3y8njQUVYhIyfy2eLsKlw2RDHFeHZiJ+4lYad1ZFXXc6sUJIp1 hZ9vcIEZYUV8A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WXL5r6PDHz4x4c; Mon, 29 Jul 2024 11:16:00 +1000 (AEST) Date: Mon, 29 Jul 2024 11:12:30 +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> <20240726113249.2a28f056@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Wg3eISj2zlkHZoAF" Content-Disposition: inline In-Reply-To: <20240726113249.2a28f056@elisabeth> Message-ID-Hash: XIJYXYYFWZNEE2RK32HIJYCN3IWEITW3 X-Message-ID-Hash: XIJYXYYFWZNEE2RK32HIJYCN3IWEITW3 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: --Wg3eISj2zlkHZoAF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 26, 2024 at 11:32:57AM +0200, Stefano Brivio wrote: > On Fri, 26 Jul 2024 09:15:59 +1000 > David Gibson wrote: >=20 > > 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 =20 > >=20 > > Reviewed-by: David Gibson > >=20 > > I noticed another pre-existing nit, though.. > >=20 > > > --- > > > 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 *for= mat, 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 c= har *format, va_list ap) > > > char buf[BUFSIZ]; > > > int n; > > > =20 > > > - if (clock_gettime(CLOCK_REALTIME, &now)) > > > + if (clock_gettime(CLOCK_MONOTONIC, &now)) =20 > >=20 > > 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. >=20 > This never happens because, in vlogmsg(): >=20 > bool debug_print =3D (log_mask & LOG_MASK(LOG_DEBUG)) && > log_file =3D=3D -1; Ah, good point. > > That seems needlessly confusing. It would be nice to have a single > > point at which we capture the time for a single message. >=20 > ...but yes, it might be confusing. A single clock_gettime() call would > need a bit of refactoring in vlogmsg(). I have a draft patch, I'll send soon. --=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 --Wg3eISj2zlkHZoAF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmam7HkACgkQzQJF27ox 2GcRnw/+IbEvaYtz+YFtWZVMUehvxAxrVeghwojLD4e9blsRVAKqbRGCh1XA9wpW 8wZcCsfM0FrN6ZLCPSCzYDfhi7c1gUpFuEeOo3blwFjAK0o1y5j2LuV64wImTwRJ KqO96sa2afzrqd7z0aI60O5UwX9GpfvbSpZT17Fa3uHHOxoe+BjOrYXNS9/Dsr3w /6IKriQXiFq8GtGrVjvec88ehWjttRoVY7kLHqTjAatuzazxYajofj5ng2PPo78T W9oKc+DH41Fm6M1kf+re782yj+Paw/x991lga/XcwSTsGUHfXMfdzWTeikQUZNLp Iua3Pt3I+Z8RDkCXuEa0uf89sI852sZYbUPrySQ/YINpBZF75i/yxRRAF+cm6uJr nmmCtIpAtefl1qKNPpDNyLp+Z1XQUKAr4dmO9+lp9G2I97swm0V0c6147Eu3sx5q Ry38yHTzofOInfhsx5pr5jhkJ3O52ZpTfggwXC4KfFmnbn/Fs8YbLWUjQvjjK97z x6iyd/8qp/fm54uTlKiMH3bcbkNL6K81QS/5sYJkG81MweBlotunmeyAfvYEQYtu OTAQWt3IWCEE0bpHzVFgC6D+qHQelrT3MkQ82p/qpGU18znnRjPndWthxQguLpMU xTTlOSlLoK12F12pERJasoVDKhKtE1iv1TwMfKCwQLpfEcpREOM= =b3g7 -----END PGP SIGNATURE----- --Wg3eISj2zlkHZoAF--