All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: Neil Zhang <zhangwm@marvell.com>, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Lei Wen <leiwen@marvell.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH V2] printk: add sleep time into timestamp
Date: Fri, 04 Apr 2014 17:58:12 -0700	[thread overview]
Message-ID: <533F5524.8050500@linaro.org> (raw)
In-Reply-To: <1396322456-5195-1-git-send-email-zhangwm@marvell.com>

On 03/31/2014 08:20 PM, Neil Zhang wrote:
> Add sleep time into timestamp to reflect the actual time since
> sched_clock will be stopped during suspend.
>
> Thanks John Stultz for suggestion to use monotonic_to_bootbased.
>
> Signed-off-by: Neil Zhang <zhangwm@marvell.com>
> ---
>  kernel/printk/printk.c |   16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 4dae9cb..121f792 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -250,6 +250,18 @@ static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
>  static char *log_buf = __log_buf;
>  static u32 log_buf_len = __LOG_BUF_LEN;
>  
> +static u64 print_clock(void)
> +{
> +	struct timespec	ts;
> +	u64 ts_nsec = local_clock();
> +
> +	ts = ns_to_timespec(ts_nsec);
> +	monotonic_to_bootbased(&ts);
> +	ts_nsec = timespec_to_ns(&ts);
> +

Note that this is still problematic as monotonic_to_bootbased currently
doesn't take the required locks to ensure it reads the data atomically.

If it were fixed to take the proper locks, this would risk a deadlock
since there are places where the timekeeping code takes a write on the
seqlock and then may call printk (or WARN_ON).

I suspect if this is going to be done, we need to have the timekeeping
provide the print_clock subsystem the boottime offset when it is changed
so the print_clock logic can manage this w/o grabbing timekeeping locks.
But as I mentioned in reply to Lei's similar patches, I'm not a huge fan
of the added complexity that will be required here when userspace like
syslog can timestamps kernel messages already (so additional rational
will be needed to move this forward).

thanks
-john

      reply	other threads:[~2014-04-05  0:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01  3:20 [PATCH V2] printk: add sleep time into timestamp Neil Zhang
2014-04-05  0:58 ` John Stultz [this message]

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=533F5524.8050500@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=leiwen@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=zhangwm@marvell.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.