linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Prarit Bhargava <prarit@redhat.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org,
	John Stultz <john.stultz@linaro.org>,
	Xunlei Pang <pang.xunlei@linaro.org>,
	Baolin Wang <baolin.wang@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tejun Heo <tj@kernel.org>,
	Peter Hurley <peter@hurleysoftware.com>,
	Vasily Averin <vvs@virtuozzo.com>, Joe Perches <joe@perches.com>
Subject: Re: [PATCH 0/2 v6] printk, Add monotonic and real printk timestamps
Date: Thu, 21 Apr 2016 09:20:41 -0400	[thread overview]
Message-ID: <5718D3A9.6070005@redhat.com> (raw)
In-Reply-To: <20160419085613.GJ6862@pathway.suse.cz>



On 04/19/2016 04:56 AM, Petr Mladek wrote:
> On Mon 2016-04-18 11:30:52, Prarit Bhargava wrote:

> Hmm, If you allow to change the timestamp format only at boot time, it
> will make things easier. I just wonder if it would work correctly for
> early messages. For example, are there any messages printed before
> the real time clock is initialized? Which timestamp will they use?
>
> Also note that you still need to modify the dmesg code. It must
> not add boot_time when real time timestamp is used.
>

I've got a util-linux patch in-hand that does this (sorry for the
cut-and-paste) and I've verified that ctime, delta, iso, notime and
reltime all appear to work 1) without my kernel patches applied,
2) with my kernel patches applied, and 3) with printk.time=[0-3]
as kernel parameters.

diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index cf93331..c49a202 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -1194,9 +1194,31 @@ static int which_time_format(const char *optarg)
 	errx(EXIT_FAILURE, _("unknown time format: %s"), optarg);
 }

-#ifdef TEST_DMESG
+static int needs_boot_time(void)
+{
+	FILE *fd;
+	int ret = 1;
+	int val;
+
+	/*
+	 * Newer kernels have /sys/modules/printk/parameter/time = [0-3]
+	 * where 0 = off, 1 = local clock, 2 = boot time, and 3 = real time.
+	 * If the file isn't present it means the functionality isn't there
+	 * and the boot_time offset is needed.
+	 */
+	fd = fopen("/sys/module/printk/parameters/time", "r");
+	if (!fd)
+		return ret;
+	fscanf(fd, "%d", &val);
+	if (val == 3)
+		ret = 0;
+	fclose(fd);
+	return ret;
+}
+
 static inline int dmesg_get_boot_time(struct timeval *tv)
 {
+#ifdef TEST_DMESG
 	char *str = getenv("DMESG_TEST_BOOTIME");
 	uintmax_t sec, usec;

@@ -1205,12 +1227,15 @@ static inline int dmesg_get_boot_time(struct timeval *tv)
 		tv->tv_usec = usec;
 		return tv->tv_sec >= 0 && tv->tv_usec >= 0 ? 0 : -EINVAL;
 	}
+#endif
+
+	if (needs_boot_time())
+		return get_boot_time(tv);

-	return get_boot_time(tv);
+	tv->tv_sec = 0;
+	tv->tv_usec = 0;
+	return 0;
 }
-#else
-# define dmesg_get_boot_time	get_boot_time
-#endif

 int main(int argc, char *argv[])
 {
-- 
1.8.3.1

> And you need to modify also the other tools, e.g. crash.
>

I spoke with anderson@redhat.com this morning and he agrees
that no change should be necessary for crash.  A quick test shows that
the logging mechanism (dmesg or log) works after the patches are applied
and printk is in REALTIME mode.

IMO dmesg is the big one and I will modify that after I see acceptance
of this patch.

P.

  parent reply	other threads:[~2016-04-21 13:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-23 17:53 [PATCH 0/2 v6] printk, Add monotonic and real printk timestamps Prarit Bhargava
2016-02-23 17:53 ` [PATCH 1/2 v6] lib, switch CONFIG_PRINTK_TIME to int Prarit Bhargava
2016-02-23 17:54 ` [PATCH 2/2 v6] printk, allow different timestamps for printk.time Prarit Bhargava
2016-03-08  7:59 ` [PATCH 0/2 v6] printk, Add monotonic and real printk timestamps Thomas Gleixner
2016-03-08 11:03   ` Prarit Bhargava
2016-03-10 10:00     ` Petr Mladek
2016-03-10 15:35       ` Thomas Gleixner
2016-04-18 15:30       ` Prarit Bhargava
2016-04-19  8:56         ` Petr Mladek
2016-04-20 17:09           ` Prarit Bhargava
2016-04-21 13:20           ` Prarit Bhargava [this message]
2016-04-26 13:00             ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5718D3A9.6070005@redhat.com \
    --to=prarit@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pang.xunlei@linaro.org \
    --cc=peter@hurleysoftware.com \
    --cc=pmladek@suse.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=vvs@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).