linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Prarit Bhargava <prarit@redhat.com>
To: John Stultz <john.stultz@linaro.org>, Joel Fernandes <joelaf@google.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Mark Salyzyn <salyzyn@android.com>,
	Jonathan Corbet <corbet@lwn.net>, Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Christoffer Dall <cdall@linaro.org>,
	Deepa Dinamani <deepa.kernel@gmail.com>,
	Ingo Molnar <mingo@kernel.org>,
	Joel Fernandes <joelaf@google.com>,
	Kees Cook <keescook@chromium.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	"Luis R. Rodriguez" <mcgrof@kernel.org>,
	Nicholas Piggin <npiggin@gmail.com>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>,
	Olof Johansson <olof@lixom.net>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH 2/2 v8] printk: Add monotonic, boottime, and realtime timestamps
Date: Fri, 25 Aug 2017 10:46:21 -0400	[thread overview]
Message-ID: <dac013d8-e70d-a89a-b2fb-d7651df983b0@redhat.com> (raw)
In-Reply-To: <CALAqxLUd4nEiayhEMCRCmDm4NrU+4T_VkmafRxJepbGQUg-iEQ@mail.gmail.com>



On 08/24/2017 02:50 PM, John Stultz wrote:
> On Thu, Aug 24, 2017 at 6:42 AM, Prarit Bhargava <prarit@redhat.com> wrote:
>> --- a/include/linux/timekeeping.h
>> +++ b/include/linux/timekeeping.h
>> @@ -239,6 +239,7 @@ static inline u64 ktime_get_raw_ns(void)
>>  extern u64 ktime_get_mono_fast_ns(void);
>>  extern u64 ktime_get_raw_fast_ns(void);
>>  extern u64 ktime_get_boot_fast_ns(void);
>> +extern u64 ktime_get_real_offset(void);
>>
>>  /*
>>   * Timespec interfaces utilizing the ktime based ones
>> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
>> index fc47863f629c..dd972bc5c88b 100644
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c
> ...
>> + * printk_get_real_ns: - Return a realtime timestamp for printk messages
>> + * On 32-bit systems selecting the real clock printk timestamp may lead to
>> + * unlikely situations where a timestamp is wrong because the real time offset
>> + * is read without the protection of a sequence lock.
>> + */
>> +static u64 printk_get_real_ns(void)
>> +{
>> +       return ktime_get_mono_fast_ns() + ktime_get_real_offset();
>> +}
>> +
> ...
>> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
>> index d111039e0245..de07bb5ffef5 100644
>> --- a/kernel/time/timekeeping.c
>> +++ b/kernel/time/timekeeping.c
>> @@ -508,6 +508,11 @@ u64 notrace ktime_get_boot_fast_ns(void)
>>  }
>>  EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);
>>
>> +u64 ktime_get_real_offset(void)
>> +{
>> +       return ktime_to_ns(tk_core.timekeeper.offs_real);
>> +}
>> +
> 
> Apologies! One last nit here.  So if we're going to export
> ktime_get_real_offset(), folks are going to use it, and there is no
> documentation about its very sketchy behavioral limits as an
> interface, except elsewhere in the printk code.
> 
> Instead of doing that, could you export a
> __ktime_get_real_fast_ns_unsafe() function, which has its limits
> (calculating the realtime w/o locks, thus may return completely bad
> values occasionally) clearly documented in the timekeeping code?

np.  I'm going to copy the code for

u64 notrace ktime_get_boot_fast_ns(void)

but I'm unsure why the function is marked "notrace", and if
__ktime_get_real_fast_ns_unsafe() must be as well?  I don't see anything in the
git log that indicates why the function is notrace.

I've added Joel to this thread ...

P.

  reply	other threads:[~2017-08-25 14:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 13:42 [PATCH 0/2 v8] printk: Add new timestamps Prarit Bhargava
2017-08-24 13:42 ` [PATCH 1/2 v8] time: Make fast functions return 0 before timekeeping is initialized Prarit Bhargava
2017-08-24 13:42 ` [PATCH 2/2 v8] printk: Add monotonic, boottime, and realtime timestamps Prarit Bhargava
2017-08-24 18:50   ` John Stultz
2017-08-25 14:46     ` Prarit Bhargava [this message]
2017-08-25 14:58       ` Steven Rostedt
2017-08-25  4:52   ` Sergey Senozhatsky

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=dac013d8-e70d-a89a-b2fb-d7651df983b0@redhat.com \
    --to=prarit@redhat.com \
    --cc=Jason@zx2c4.com \
    --cc=akpm@linux-foundation.org \
    --cc=cdall@linaro.org \
    --cc=corbet@lwn.net \
    --cc=deepa.kernel@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=joelaf@google.com \
    --cc=john.stultz@linaro.org \
    --cc=jpoimboe@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mingo@kernel.org \
    --cc=npiggin@gmail.com \
    --cc=olof@lixom.net \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=salyzyn@android.com \
    --cc=sboyd@codeaurora.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tglx@linutronix.de \
    /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).