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 C73345A031C for ; Thu, 25 Jul 2024 05:47:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1721879255; bh=X8a8NE4IXRR9AchmXPmCejrYTE2fRvv4gVpFa6AKRHg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cvNSsaShcRJcj3LWyhug90SH+ayEqqgsHaHyQAsnPClSod0YCjI+w5j8mgnnGnGK7 sGEhxghAHN7pI9Tm8aDuQe5uAhCjbY0c+0A2H/otVPVjFEaVMuUrY+Mtqz2rbGdkGY 337KM1LzLUqSahzR0RE5Hfihv8wkf2aF+IHYotbNsN+80dhRa7+gqCOVmWYEfqxfVQ +QPibxYVD+Use6D6CeURXa/2nhbgRGq9hd0W39+DW13Bh0lw5C+x9HblvysybZMvyH KeIg5jpIo5DUzH/k/0ANAG1EJK4w8ZMJqR0cD08H1roTfa1dL8rmdBY0wRcUlgsta6 t3dIzuo78guFA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WTxfb4cvCz4x3p; Thu, 25 Jul 2024 13:47:35 +1000 (AEST) Date: Thu, 25 Jul 2024 13:35:25 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 05/11] log: Initialise timestamp for relative log time also if we use a log file Message-ID: References: <20240724215021.3366863-1-sbrivio@redhat.com> <20240724215021.3366863-6-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+bFIqCCZgcyaY3P4" Content-Disposition: inline In-Reply-To: <20240724215021.3366863-6-sbrivio@redhat.com> Message-ID-Hash: FWWFPQMCCLDUIAAQGYX2MVUDG2FKHE5J X-Message-ID-Hash: FWWFPQMCCLDUIAAQGYX2MVUDG2FKHE5J 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: --+bFIqCCZgcyaY3P4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 24, 2024 at 11:50:11PM +0200, Stefano Brivio wrote: > ...not just for debug messages. Otherwise, timestamps in the log file > are consistent but the starting point is not zero. >=20 > Do this right away as we enter main(), so that the resulting > timestamps are as closely as possible relative to when we start. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson It does occur to me, though... when we're using relative timestamps, should we be using the monotonic clock instead of the realtime clock? > --- > log.c | 4 +--- > log.h | 1 + > passt.c | 2 ++ > 3 files changed, 4 insertions(+), 3 deletions(-) >=20 > diff --git a/log.c b/log.c > index f57a54f..5f24c16 100644 > --- a/log.c > +++ b/log.c > @@ -40,7 +40,7 @@ static size_t log_written; /* Currently used bytes in = log file */ > static size_t log_cut_size; /* Bytes to cut at start on rotation */ > static char log_header[BUFSIZ]; /* File header, written back on cuts */ > =20 > -static struct timespec log_start; /* Start timestamp */ > +struct timespec log_start; /* Start timestamp */ > =20 > int log_trace; /* --trace mode enabled */ > bool log_conf_parsed; /* Logging options already parsed */ > @@ -154,8 +154,6 @@ void __openlog(const char *ident, int option, int fac= ility) > { > (void)option; > =20 > - clock_gettime(CLOCK_REALTIME, &log_start); > - > if (log_sock < 0) { > struct sockaddr_un a =3D { .sun_family =3D AF_UNIX, }; > =20 > diff --git a/log.h b/log.h > index 51ddafa..e03199c 100644 > --- a/log.h > +++ b/log.h > @@ -44,6 +44,7 @@ void logmsg_perror(int pri, const char *format, ...) > extern int log_trace; > extern bool log_conf_parsed; > extern bool log_runtime; > +extern struct timespec log_start; > =20 > void trace_init(int enable); > #define trace(...) \ > diff --git a/passt.c b/passt.c > index eed74ec..72ad704 100644 > --- a/passt.c > +++ b/passt.c > @@ -207,6 +207,8 @@ int main(int argc, char **argv) > struct timespec now; > struct sigaction sa; > =20 > + clock_gettime(CLOCK_REALTIME, &log_start); > + > arch_avx2_exec(argv); > =20 > isolate_initial(); --=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 --+bFIqCCZgcyaY3P4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmahx/wACgkQzQJF27ox 2GduhA/9FyQ6y3xp5PnvXzisiWqmnovol5KBomjtSN5oFQZkqfxzZ3GpFJZ5QCgA 4dNnXAbXoyMU0/VPDZ81zZGsZYgSDhrgHlDMCDwblrHzWEOstnJLvzs8MaAgXDyo 8MYmBGU2SoGEl0ggwMCEf2bjqM8pjW9WVlRaNMHbonl1MGTVOZ8GtkvaF1WyURlh +CktwjbyMkU1lVCbsixvMO6GVNOyyZSl/TCMhMS4eGXegH8u0jzFBClkRIQ0CIpE 8L8d45CmECAU5ks07HDFxM8xC8yASFJZIhfSKB9KegCO55MMOYBD/51MOnyGAS1F OI7Q/1Ic2n6f4Ivoh7IuQN5jtVca0LGyrfHP3IhHevXjngbB+criRB5ACyiq5Wml lHowf1IQCu6eBGtqu4bxyGQ1dimoe99o9TN2pS1dAWkVkkvk5hcw5rbE01XiFIQc k3lWX9FgdYf2gk/vfcJeYvsHAclXvaJ4tTr81TJwxuBMGzXqrEvpC0WgqR94PDNG v2l68SlXSECLnypmCEq6jRR26TbmvIATpLLl46br3my/7pt3FvtIYwHzJFuuzJkY ImIkLP/5dce7O9+GjZyV+L6kYUac9n9BGozcWdZ0+oysYhPxxKuhilS9ES0rnep5 v/6GU9RCmpSXjOOzMYN3LBFTkeSrM4xGXzI5OHceXA/AqQD8F/c= =RQiS -----END PGP SIGNATURE----- --+bFIqCCZgcyaY3P4--