All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Nicolas Pitre <nico@fluxnic.net>
Cc: Linus Walleij <linus.walleij@stericsson.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Colin Cross <ccross@google.com>,
	John Stultz <johnstul@us.ibm.com>, Ingo Molnar <mingo@redhat.com>,
	Rabin Vincent <rabin.vincent@stericsson.com>
Subject: Re: [PATCH] clocksource: document some basic concepts
Date: Mon, 15 Nov 2010 22:13:04 +0100	[thread overview]
Message-ID: <1289855584.2109.559.camel@laptop> (raw)
In-Reply-To: <alpine.LFD.2.00.1011151453370.6448@xanadu.home>

On Mon, 2010-11-15 at 15:06 -0500, Nicolas Pitre wrote:
> On Mon, 15 Nov 2010, Peter Zijlstra wrote:
> 
> > On Mon, 2010-11-15 at 11:33 +0100, Linus Walleij wrote:
> > > +The sched_clock() function may wrap only on unsigned long long boundaries,
> > > +i.e. after 64 bits. Since this is a nanosecond value this will mean it wraps
> > > +after circa 585 years. (For most practical systems this means "never".)
> 
> This is not necessarily the case.  Some implementations require a 
> scaling factor too, making the number of remaining bits smaller than 64.  
> See arch/arm/mach-pxa/time.c:sched_clock() for example, which has a 
> maximum range of 208 days.  Of course, in practice we don't really care 
> if sched_clock() wraps each 208 days, unlike for clock-source.

Right, its like sched_clock() would go backwards and we loose some
precision during that jiffy (assuming the arch uses
HAVE_UNSTABLE_SCHED_CLOCK), nothing too horrible.

> > Currently true, John Stultz was going to look into ammending this by
> > teaching the kernel/sched_clock.c bits about early wraps (and a way for
> > architectures to specify this)
> > 
> > #define SCHED_CLOCK_WRAP_BITS 48
> > 
> > ...
> > 
> > #ifdef SCHED_CLOCK_WRAP_BITS
> >   /* handle short wraps */
> > #endif
> 
> Is this worth supporting?  I'd simply use the low 32 bits and extend it 
> to 63 bits using cnt32_to_63(). If the low 32 bits are wrapping too 
> fast, then just shifting them down a few positions first should do the 
> trick.  That certainly would have a much faster result.

Whatever works, dealing with the wrap is only a few shifts.

  reply	other threads:[~2010-11-15 21:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-15 10:33 [PATCH] clocksource: document some basic concepts Linus Walleij
2010-11-15 10:48 ` Peter Zijlstra
2010-11-15 10:50   ` Peter Zijlstra
2010-11-15 19:48   ` john stultz
2010-11-15 20:06   ` Nicolas Pitre
2010-11-15 21:13     ` Peter Zijlstra [this message]
2010-11-15 16:34 ` Randy Dunlap
2010-11-15 19:45 ` john stultz

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=1289855584.2109.559.camel@laptop \
    --to=peterz@infradead.org \
    --cc=ccross@google.com \
    --cc=johnstul@us.ibm.com \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nico@fluxnic.net \
    --cc=rabin.vincent@stericsson.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 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.