All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Prarit Bhargava <prarit@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	John Stultz <john.stultz@linaro.org>,
	Xunlei Pang <pang.xunlei@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	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 2/2] printk, Add printk.clock kernel parameter
Date: Thu, 7 Jan 2016 16:52:36 +0100	[thread overview]
Message-ID: <20160107155236.GO3178@pathway.suse.cz> (raw)
In-Reply-To: <568E867D.8060904@redhat.com>

On Thu 2016-01-07 10:38:37, Prarit Bhargava wrote:
> 
> 
> On 01/07/2016 09:57 AM, Petr Mladek wrote:
> > On Wed 2016-01-06 08:00:34, Prarit Bhargava wrote:
> >> This patch introduces printk.clock=[local|boot|real|tai] allowing a
> >> user to specify an adjusted clock to use with printk timestamps.  The
> >> hardware clock, or the existing functionality, is preserved by default.
> >> +	pr_info("printk: timestamp set to %s clock.\n", printk_clock);
> >> +	return 0;
> >> +}
> >> +
> >> +static struct kernel_param_ops printk_clock_param_ops = {
> >> +	.set =		printk_clock_param_set,
> >> +	.get =		param_get_charp,
> >> +};
> >> +
> >> +module_param_cb(clock, &printk_clock_param_ops, &printk_clock, 0644);
> >> +MODULE_PARM_DESC(clock, "Clock used for printk timestamps.  Can be local (hardware/default), boot, real, or tai.\n");
> > 
> > I have problems to parse this. It seems that the most common style
> > used for possible values is to putthem into brackets. I wonder
> > if this is better readable.
> > 
> > MODULE_PARM_DESC(clock, "Clock used for printk timestamps (local = default, boot, real, tai).");
> > 
> 
> Ah, thanks! :)  I was wondering if there was a coding style preference there
> when I wrote this up.

Heh, I am not sure if there is any coding style for this. I just went
over the output from

      git grep MODULE_PARM_DESC

> > 
> >> +
> >>  /* insert record into the buffer, discard old ones, update heads */
> >>  static int log_store(int facility, int level,
> >>  		     enum log_flags flags, u64 ts_nsec,
> >> @@ -467,7 +544,7 @@ static int log_store(int facility, int level,
> >>  	if (ts_nsec > 0)
> >>  		msg->ts_nsec = ts_nsec;
> >>  	else
> >> -		msg->ts_nsec = local_clock();
> >> +		msg->ts_nsec = printk_get_timestamp();
> > 
> > Hmm, one problem is that each clock returns another type of time.
> > "local" and "boot" clocks returns the number of ns since the boot.
> > While "real" and "tai" clocks returns the number of ns since 1.1.1970
> > or so.
> > 
> > The tools reading the timestamps are confused by this. For example,
> > I get this:
> > 
> > $> echo boot >/sys/module/printk/parameters/clock
> > $> echo local >/sys/module/printk/parameters/clock
> > $> echo real >/sys/module/printk/parameters/clock
> > $> echo tai >/sys/module/printk/parameters/clock
> > $> dmesg | tail -6
> > [    6.976593] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
> > [    6.977168] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
> > [   77.500483] printk: timestamp set to boot clock.
> > [   81.419957] printk: timestamp set to local clock.
> > [1452177961.544909] printk: timestamp set to real clock.
> > [1452177965.224824] printk: timestamp set to tai clock.
> > $> dmesg -T | tail -6
> > [Thu Jan  7 15:44:41 2016] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
> > [Thu Jan  7 15:44:41 2016] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
> > [Thu Jan  7 15:45:52 2016] printk: timestamp set to boot clock.
> > [Thu Jan  7 15:45:56 2016] printk: timestamp set to local clock.
> > [Fri Jan 13 06:30:36 2062] printk: timestamp set to real clock.
> > [Fri Jan 13 06:30:40 2062] printk: timestamp set to tai clock.
> > 
> > Please, note that the last messages looks as they are printed in
> > a far far future ;-)
> 
> Heh :)  I didn't even think of testing that.  I'll have to think about that a
> bit more.  systemd logging must assume boot time/local time.  I'll ping those
> guys with a patch if/when the next version of this gets accepted.

I am not sure how many tools would be affected by this. An easier
solution would be to normalize all times and always save the relative
time since the boot as it is done now.

Best Regards,
Petr

  reply	other threads:[~2016-01-07 15:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06 13:00 [PATCH 0/2] printk, Add a printk.clock kernel parameter Prarit Bhargava
2016-01-06 13:00 ` [PATCH 1/2] kernel, timekeeping, add trylock option to ktime_get_with_offset() Prarit Bhargava
2016-01-06 16:04   ` Jiri Bohac
2016-01-06 16:27     ` Prarit Bhargava
2016-01-06 16:25   ` Petr Mladek
2016-01-06 17:28   ` John Stultz
2016-01-06 17:33     ` John Stultz
2016-01-06 18:06       ` Prarit Bhargava
2016-01-06 18:10         ` Thomas Gleixner
2016-01-06 17:34     ` Thomas Gleixner
2016-01-06 18:09       ` Prarit Bhargava
2016-01-06 18:12         ` Thomas Gleixner
2016-01-06 19:04       ` John Stultz
2016-01-06 19:06         ` Prarit Bhargava
2016-01-06 13:00 ` [PATCH 2/2] printk, Add printk.clock kernel parameter Prarit Bhargava
2016-01-07 14:57   ` Petr Mladek
2016-01-07 15:38     ` Prarit Bhargava
2016-01-07 15:52       ` Petr Mladek [this message]
2016-01-08  9:04         ` Thomas Gleixner
2016-01-06 17:09 ` [PATCH 0/2] printk, Add a " Joe Perches
2016-01-13 12:34 [PATCH 0/2] printk, Add printk.clock kernel parameter [v2] Prarit Bhargava
2016-01-13 12:34 ` [PATCH 2/2] printk, Add printk.clock kernel parameter Prarit Bhargava

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=20160107155236.GO3178@pathway.suse.cz \
    --to=pmladek@suse.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=prarit@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.