From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 409B95A004F for ; Fri, 26 Jul 2024 11:33:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721986417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=toeii8l6wqvoIYUxA7OiADlLeqrekaSQii8OBJ2XtO8=; b=X/FU50tP94gv76iCnv6X+1X/AN+QLwEH1uzjj0X6qtchJ3ndShcxvUQz/ckJCO84UbCsrU Ikw/W/LUYXj9KoHoCVPe82yZAxqrLkBk9vwqj6J5gC0qB/Km17F5oseRNoyWCms19GEkO/ R73NRxsd0S4y5GtMof031Gb63tyCEYM= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-vH734x73NeKgoZERqh57tA-1; Fri, 26 Jul 2024 05:33:35 -0400 X-MC-Unique: vH734x73NeKgoZERqh57tA-1 Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-5d5b62ee8b9so770520eaf.1 for ; Fri, 26 Jul 2024 02:33:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721986414; x=1722591214; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=toeii8l6wqvoIYUxA7OiADlLeqrekaSQii8OBJ2XtO8=; b=mOoSXU8NDWiPe5K9ala6E5VWvdDHNWHwSM2I40e2BG3LkuQJfm5S04gEvhEcaCWtxz RhyfQ1NqHj9SLRmgVbFMgLmi7lsl3+bC2xSsRqSlM2X1yY/JffDkExmOCzC7gqPUVgXu 0VHvrOOiup2KyurbxTlG947wRpKiswvlvD4kpDP5TDIl/XLq8uLKsoX+N8d8PGmbtGQt x11QhVQDUtts7iFvdqfJUCuXBOqrkW3n30eMWM/L5xLne/nWYadfWQZ+m10LQf3DEk7e 3v+E2TMssKWi83kOBpi/YtCmASZJrExKYIs9PBvxJD/QmUmOAp4fnJTItaZl0f22A77L EVpg== X-Gm-Message-State: AOJu0YyJmseMeW52x7B6zMqa601xQcjeVKtoE/2PJhbaSM1dDhIiaVro 6JaxgAb/09o6EpK6f1Iz11YK1Yeo7mlx0tLx8kDdP432um9IA4SNZSowEbWOu82uEPAVePRoA5U mstwi1QJn3v8znIK6AQzwKsU4EZNX7iFxirNMvj4jVPQ0otHwWP7toktR+5UY X-Received: by 2002:a05:6358:5290:b0:1ac:62e5:7648 with SMTP id e5c5f4694b2df-1acfb969818mr577666555d.20.1721986414069; Fri, 26 Jul 2024 02:33:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvCXL6EzJXjKlWMSNpoSWsy/7YSkdOws3abp7NPQeY2HRb+vjvXMH2ddMBNzP169Gol/PERA== X-Received: by 2002:a05:6358:5290:b0:1ac:62e5:7648 with SMTP id e5c5f4694b2df-1acfb969818mr577664155d.20.1721986413542; Fri, 26 Jul 2024 02:33:33 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3fb090e2sm14909236d6.138.2024.07.26.02.33.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jul 2024 02:33:32 -0700 (PDT) Date: Fri, 26 Jul 2024 11:32:57 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 3/3] log: Fetch log times with CLOCK_MONOTONIC, not CLOCK_REALTIME Message-ID: <20240726113249.2a28f056@elisabeth> In-Reply-To: References: <20240725162634.107697-1-sbrivio@redhat.com> <20240725162634.107697-4-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: DLEC7S7XUG6BQJWCIIHQDDIIUGC6MA3C X-Message-ID-Hash: DLEC7S7XUG6BQJWCIIHQDDIIUGC6MA3C X-MailFrom: sbrivio@redhat.com 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: On Fri, 26 Jul 2024 09:15:59 +1000 David Gibson wrote: > 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 > > 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(-) > > > > 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. This never happens because, in vlogmsg(): bool debug_print = (log_mask & LOG_MASK(LOG_DEBUG)) && log_file == -1; > That seems needlessly confusing. It would be nice to have a single > point at which we capture the time for a single message. ...but yes, it might be confusing. A single clock_gettime() call would need a bit of refactoring in vlogmsg(). -- Stefano