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.133.124]) by passt.top (Postfix) with ESMTP id 9C5DB5A004E for ; Thu, 25 Jul 2024 09:51:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721893904; 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=drjtyIj4TKV4b6bpzZvoP0RD5+c3Jjx7gGxIwAa7q8Y=; b=bJGX8sOcAuxA5JDEy+pqJ1yNPt7CyiRTzRkLFshWuBmgrUXE9vYQiDr8gO0PdLp9uV3Hu+ ra+DZK4ZyRkFoKRBux2w6vD2qnNgiyvto/lil3bXcwNsfM2SZaTlvZIEOiDa9V+Gyod5w3 eNvkCOzABDSGcT8WM6CRl46muCV4GUw= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-26-CAahqeNvOLeO2uD_1esMnw-1; Thu, 25 Jul 2024 03:51:37 -0400 X-MC-Unique: CAahqeNvOLeO2uD_1esMnw-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-447f73b3e35so6931011cf.1 for ; Thu, 25 Jul 2024 00:51:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721893896; x=1722498696; 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=drjtyIj4TKV4b6bpzZvoP0RD5+c3Jjx7gGxIwAa7q8Y=; b=u9C0v3NV67I6hhns3bJ3vmIUxe6L8NrA/+lE2gVjwAKcYrfMfW0x9Wrh+nE78UrGZx fPPym5/VAzrixYKlTAH+yPvofZSdmvCseycs1A/zS/IA9dVYDz/SEwQwAIXLT7MHqY/7 ZcgNy7/o4EhFAInQcXh46aWOTHPv5yQ+qGjcN51ceheqUiAWS651UnV0TxoBCH6gYzpl B9PEwLTglRmJjJD868AqD5sW59OO69zv5AdlgVAEchPM0XYXC6bRCTUBjVm1RWfK/9O9 H5Bkv7DH3UxqqO8+Zd4mfvPGvaWY9lbIDjr2As6E+9DqkJiF3xFrshGVphO6QOJZpR4O DR1A== X-Gm-Message-State: AOJu0YxGXvEltmXVJYiawGTkiqFl2m3jK9QTYC5Guc+Fan4b2Xlifu/F MA+vACXMchCXgufl2jx/AKpQC5LYXwKWXS71ZIzQmdYfGuWGwvDwNv0ykEbrBVeR3iiyuX9qzm2 Fvfg7yO25DL5LPc7hW7nHq7qzERofgXisNvDIhNkPqre0IKPCjhUWDRbBVM3F X-Received: by 2002:ac8:5a0c:0:b0:44f:e74f:637 with SMTP id d75a77b69052e-44fe91e7956mr11156101cf.33.1721893896045; Thu, 25 Jul 2024 00:51:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+whaKfOh3Il3eg/4LCOACftVZI6FUsCWMIw/8FSgjvyLdjIa5JNlXDI5qRDAmwbklnQSJYQ== X-Received: by 2002:ac8:5a0c:0:b0:44f:e74f:637 with SMTP id d75a77b69052e-44fe91e7956mr11155931cf.33.1721893895554; Thu, 25 Jul 2024 00:51:35 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8154a71sm3961781cf.38.2024.07.25.00.51.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2024 00:51:34 -0700 (PDT) Date: Thu, 25 Jul 2024 09:51:00 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 04/11] log: Fix sub-second part in relative log time calculation Message-ID: <20240725095050.68524edd@elisabeth> In-Reply-To: References: <20240724215021.3366863-1-sbrivio@redhat.com> <20240724215021.3366863-5-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: DKSLAHDE6ID7LWF55WHXX2JOT4F6K65G X-Message-ID-Hash: DKSLAHDE6ID7LWF55WHXX2JOT4F6K65G 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 Thu, 25 Jul 2024 13:32:52 +1000 David Gibson wrote: > On Wed, Jul 24, 2024 at 11:50:10PM +0200, Stefano Brivio wrote: > > > > [...] > > > > +/** > > + * logtime_fmt_and_arg() - Build format and arguments to print relative log time > > + * @x: Current timestamp > > + */ > > +#define logtime_fmt_and_arg(x) \ > > + "%lli.%04lli", \ > > + ((long long int)(x)->tv_sec - log_start.tv_sec), \ > > + (((long long int)(x)->tv_nsec - log_start.tv_nsec) / (100L * 1000)) > > This doesn't look right. If x->tv_nsec - log_start.tv_nsec is > negative it will produce weird results. Instead you need more complex > logic to carry a sufficient difference in the nsec over into the > seconds difference. Oh, oops, of course. I was hoping to recycle this from the Linux kernel, where we have timespec_sub(), but that implementation looks a bit too complicated for my taste. I'm adding something simpler now. -- Stefano