From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6923943D04; Wed, 20 Mar 2024 15:38:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1601402B9; Wed, 20 Mar 2024 15:38:58 +0100 (CET) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mails.dpdk.org (Postfix) with ESMTP id 35A164029F for ; Wed, 20 Mar 2024 15:38:57 +0100 (CET) Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6e8f765146fso408465b3a.0 for ; Wed, 20 Mar 2024 07:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710945536; x=1711550336; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=RPkASB14n1mVabsUssUlcCU2EeXJNnSyljgBnD/vXsI=; b=b0Xf7RgBL1rJqj+CDcwlrZqrKdxApfcMXUBpLq+ROL+t5yMj1c3/7k75yCBahKwSko zGSpeUBMDb7VR1ovRJCiSJKc3LSDru/1i2UWIje7XPnUtSZTuCYtxkIcwx1LpoEgsfqQ igOOndFnpCCo6XczrwitaRSUwYHqDNejIyAtycanC/JQCr1Gw79uYH2XJKfAgxloB+gh /Ki2ZxaEakKUmssoH2cRKofl1eEgRlJqHoWM67Xzvd74h3GCSKveJDB8aGxSkm4+laOz 6EtuscoXA0pIimnm5YC89t8zfUfk2z5M8Yi38O8iwZ4IosGVZDE7oJfbifFmzVMSULdE u8Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710945536; x=1711550336; h=content-transfer-encoding:mime-version: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=RPkASB14n1mVabsUssUlcCU2EeXJNnSyljgBnD/vXsI=; b=btWhnjRI2HOGXbgI/sHPNoCjKoMKEJRokVumcQN8P5N8iu1UAVds9VC6YwDnxedB9H M+NYsM/s+CiMeWTD4jZxpyC84ig15sPlujGVibSfmuGm1LvUR+skQElEJnTWTXVO/JHp zPjYDNfYiNU1wKtgYmBkpuCFHjWqBimZnPFciXtLhCuJ8whZQ0ZSBZnkQXVZuyg4DCRF o1mMP80AokRS+v+CmAWg6MmDZwEdkktUpioXltY4Y9ItXDNm67eoSwd9NGUnLFP0+VPC Yi0iFAG7owVjThlclxBiAUbZxLLxA8PBT3xYscSsuWT2HEJ2jD2T+0QaerFHasaoIKEr FGOQ== X-Gm-Message-State: AOJu0YyLFfB85bp4Hh0LhUp7Rj6ZqNwTTgf//MtSn8ROxYFZDCzU7mDC hpUQnis8mmEeoR1Xo0LYfadaMTLGo9tqeHja7aNYUyjmUyBxYg3iW42EuuU9/SY= X-Google-Smtp-Source: AGHT+IGsTq20YLkzTHVwRdRerlRjTY2F9s+rxvrrEMzceW/ttMy1wiPHATibkw1Cp4smijLW5rjfBw== X-Received: by 2002:a05:6a00:3c8d:b0:6e4:f048:30d9 with SMTP id lm13-20020a056a003c8d00b006e4f04830d9mr20198461pfb.3.1710945536104; Wed, 20 Mar 2024 07:38:56 -0700 (PDT) Received: from hermes.local (204-195-123-203.wavecable.com. [204.195.123.203]) by smtp.gmail.com with ESMTPSA id v4-20020aa799c4000000b006e6f1eab2f9sm10489269pfi.159.2024.03.20.07.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 07:38:55 -0700 (PDT) Date: Wed, 20 Mar 2024 07:38:53 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: Subject: Re: [PATCH v9 5/5] eal: add option to put timestamp on console output Message-ID: <20240320073853.3bf06e51@hermes.local> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F310@smartserver.smartshare.dk> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240318220432.7486-1-stephen@networkplumber.org> <20240318220432.7486-6-stephen@networkplumber.org> <98CBD80474FA8B44BF855DF32C47DC35E9F2FE@smartserver.smartshare.dk> <20240319085136.1d4e2897@hermes.local> <98CBD80474FA8B44BF855DF32C47DC35E9F30C@smartserver.smartshare.dk> <20240319203352.1d58cec5@hermes.local> <98CBD80474FA8B44BF855DF32C47DC35E9F310@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, 20 Mar 2024 09:34:21 +0100 Morten Br=C3=B8rup wrote: > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > Sent: Wednesday, 20 March 2024 04.34 > >=20 > > On Tue, 19 Mar 2024 17:13:35 +0100 > > Morten Br=C3=B8rup wrote: > > =20 > > > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > > > Sent: Tuesday, 19 March 2024 16.52 > > > > > > > > On Tue, 19 Mar 2024 08:37:30 +0100 > > > > Morten Br=C3=B8rup wrote: > > > > =20 > > > > > > static ssize_t > > > > > > console_log_write(__rte_unused void *c, const char *buf, size_= t =20 > > > > size) =20 > > > > > > { > > > > > > + struct timespec ts; > > > > > > ssize_t ret; > > > > > > > > > > > > - /* write on stderr */ > > > > > > - ret =3D fwrite(buf, 1, size, stderr); > > > > > > + if (timestamp_enabled) { > > > > > > + clock_gettime(CLOCK_MONOTONIC, &ts); > > > > > > + ts.tv_sec -=3D log_started.tv_sec; > > > > > > + ts.tv_nsec -=3D log_started.tv_nsec; =20 > > > > > > > > > > Please log the absolute CLOCK_MONOTONIC instead of subtracting =20 > > > > log_started, so timestamps can be easily compared with timestamps f= rom > > > > other processes. > > > > > > > > > > > > No, was trying to do what kernel dmesg does. =20 > > > > > > What do you mean? Doesn't the kernel output CLOCK_MONOTONIC timestamp= s =20 > > (without offset)? =20 > > > > > > And by "timestamps from other processes" I also mean timestamps in lo= g =20 > > messages from the kernel itself. =20 > > > =20 > >=20 > > If you look at dmesg command that formats the messages, it has lots of > > timestamp options. > > Next version will support more of these. > >=20 > > --time-format format > > Print timestamps using the given format, which can be ctime, > > reltime, delta or iso. The first three formats are aliases of > > the time-format-specific options. The iso format is a dmesg > > implementation of the ISO-8601 timestamp format. The purpose > > of this format is to make the comparing of timestamps between > > two systems, and any other parsing, easy. The definition of > > the iso timestamp is: > > YYYY-MM-DDHH:MM:SS,=E2=86=90+> > UTC>. =20 >=20 > That's formatting. >=20 > I'm talking about the initial offset. >=20 > The kernel's "log start time" is set to system start timestamp. >=20 > Your "log start time" is set to application start timestamp: >=20 > +void > +eal_log_enable_timestamp(void) > +{ > + timestamp_enabled =3D true; > + clock_gettime(CLOCK_MONOTONIC, &log_started); > +} >=20 > So, different offset. I prefer using the same offset. Monotonic has no absolute zero time and can be quite large so offsetting seemed most logical. Also, the kernel does not make boot time monotonic clock value available. Other options are REALTIME or BOOTTIME. But both of these get quite large.