lkml.org 
[lkml]   [2019]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: infinite loop in read_hpet from ktime_get_boot_fast_ns
Hi Peter,

Thanks for the explanation.

On Wed, Jun 12, 2019 at 2:29 PM Peter Zijlstra <peterz@infradead.org> wrote:
> Either local_clock() or cpu_clock(cpu). The sleep hooks are not
> something the consumer has to worry about.

Alright. Just so long as it *is* tracking sleep, then that's fine. If
it isn't some important aspects of the protocol will be violated.

> If an architecture doesn't provide a sched_clock(), you're on a
> seriously handicapped arch. It wraps in ~500 days, and aside from
> changing jiffies_lock to a latch, I don't think we can do much about it.

Are you sure? The base definition I'm looking at uses jiffies:

unsigned long long __weak sched_clock(void)
{
return (unsigned long long)(jiffies - INITIAL_JIFFIES)
* (NSEC_PER_SEC / HZ);
}

On a CONFIG_HZ_1000 machine, jiffies wraps in ~49.7 days:
>>> ((1<<32)-1)/1000/(60*60*24)
49.710269618055555

Why not just use get_jiffies_64()? The lock is too costly on 32bit?

> (the scheduler too expects sched_clock() to not wrap short of the u64
> and so having those machines online for 500 days will get you 'funny'
> results)

Ahh. So if, on the other hand, the whole machine explodes at the wrap
mark, I guess my silly protocol is the least of concerns, and so this
shouldn't matter?

Jason

\
 
 \ /
  Last update: 2019-06-12 14:58    [W:0.069 / U:4.696 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site