Re: [PATCH 2/2 v8] printk: Add monotonic, boottime, and realtime timestamps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 08/24/2017 02:50 PM, John Stultz wrote:
> On Thu, Aug 24, 2017 at 6:42 AM, Prarit Bhargava <prarit@xxxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux