lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 20 Aug 2010 14:52:45 -1000
From:	Zachary Amsden <zamsden@...hat.com>
To:	john stultz <johnstul@...ibm.com>
CC:	kvm@...r.kernel.org, Avi Kivity <avi@...hat.com>,
	Marcelo Tosatti <mtosatti@...hat.com>,
	Glauber Costa <glommer@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	linux-kernel@...r.kernel.org
Subject: Re: [KVM timekeeping 17/35] Implement getnsboottime kernel API

On 08/20/2010 02:02 PM, john stultz wrote:
> On Fri, 2010-08-20 at 13:37 -1000, Zachary Amsden wrote:
>    
>> On 08/20/2010 08:39 AM, john stultz wrote:
>>      
>>> On Thu, 2010-08-19 at 22:07 -1000, Zachary Amsden wrote:
>>>
>>>        
>>>> Add a kernel call to get the number of nanoseconds since boot.  This
>>>> is generally useful enough to make it a generic call.
>>>>
>>>>          
>>> Few comments here.
>>>
>>>
>>>        
>>>> Signed-off-by: Zachary Amsden<zamsden@...hat.com>
>>>> ---
>>>>    include/linux/time.h      |    1 +
>>>>    kernel/time/timekeeping.c |   27 +++++++++++++++++++++++++++
>>>>    2 files changed, 28 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/include/linux/time.h b/include/linux/time.h
>>>> index ea3559f..5d04108 100644
>>>> --- a/include/linux/time.h
>>>> +++ b/include/linux/time.h
>>>> @@ -145,6 +145,7 @@ extern void getnstimeofday(struct timespec *tv);
>>>>    extern void getrawmonotonic(struct timespec *ts);
>>>>    extern void getboottime(struct timespec *ts);
>>>>    extern void monotonic_to_bootbased(struct timespec *ts);
>>>> +extern s64 getnsboottime(void);
>>>>
>>>>          
>>> So instead of converting the timespec from getboottime, why did you add
>>> a new interface? Also if not a timespec, why did you pick a s64 instead
>>> of a ktime_t?
>>>
>>>        
>> The new interface was suggested several times, so I'm proposing it.  I'm
>> indifferent to putting it the kernel API or making it internal to KVM.
>> KVM doesn't want to deal with conversions to / from ktime_t; this code
>> uses a lot (too much) math, and it's easy to get wrong when splitting
>> sec / nsec fields.  So s64 seems a natural type for ns values.  I
>> realize it's not entirely consistent with the kernel API, but s64
>> representation for ns seems to be creeping in.
>>      
> I can understand wanting that, way back I was pushing for s64 ns
> representations for most time values, but the ktime_t was considered a
> reasonable compromise to avoid costly 64bit divides to split (sec,nsec)
> on 32bit arches.
>    

We want time in simply parseable formats, so we always end up with sec / 
msec, sec / usec, sec / nsec.  This is simply a convenient 
representation for humans.  Programmers always end up copying this model 
and it causes so many lovely bugs.  How many times can you race while 
reading CMOS Y/M/D/H/S?

Fortunately now that 64-bit computing is nearly pervasive, we can make 
most of these problems go away.

I think gettimefromboot_ns() is a good descriptive name, but slightly 
too long - it would ruin my indentation.  Perhaps getrealtime_ns()?

Zach
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists