public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: lkml <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH 2/5] introduce CLOCK_MONOTONIC_RAW
Date: Mon, 17 Mar 2008 19:03:38 -0700	[thread overview]
Message-ID: <1205805818.28128.91.camel@localhost> (raw)
In-Reply-To: <Pine.LNX.4.64.0803150536290.1791@scrub.home>


On Sat, 2008-03-15 at 05:50 +0100, Roman Zippel wrote:
> Hi,
> 
> On Fri, 14 Mar 2008, john stultz wrote:
> 
> > My solution is to introduce CLOCK_MONOTONIC_RAW. This exposes a
> > nanosecond based time value, that increments starting at bootup and has
> > no frequency adjustments made to it what so ever.
> 
> A general comment: the raw clock doesn't need any adjustments, so updates 
> don't have to be done that frequently and you can move most of that logic 
> into second_overflow().

You're suggesting adding MONTONIC_RAW code to ntp.c ?  That doesn't make
much sense to me (the whole point is its not ntp adjusted). Even if you
mean just inside the "if (clock->xtime_nsec >= (u64)NSEC_PER_SEC ..."
conditional, then that means we don't get to leverage the
cycles_interval, and cycle_last, values, so all of that would have to be
duplicated and managed. Which I'm not sure it would save us much more
then the extra add and compare here.


> > @@ -439,6 +475,7 @@ static void clocksource_adjust(s64 offset)
> >  void update_wall_time(void)
> >  {
> >  	cycle_t offset;
> > +	static u64 raw_snsec; /* shifted raw nanosecnds */
> >  
> >  	/* Make sure we're fully resumed: */
> >  	if (unlikely(timekeeping_suspended))
> 
> IMO that's really a clock property, so this belongs in the clock 
> structure.
> (Some day we may want to have multiple active clocks for various purposes 
> and thus export multiple raw clocks.)

I disagree. I think that crufts up the clocksource structure (which is
ideally just a simple hw counter abstraction), with timekeeping state.

I'm still not sold on the multiple clocks with multiple notions of time
idea you keep on bringing up. But if/when we cross that bridge, maybe it
would be better to add a timekeeping_clock mid-layer abstraction that
keeps the clocksource specific timekeeping state. That way we don't add
lots of complexity for the clocksource driver writers to deal with and
we allow the clocksources to be better re-purposed (for maybe more sane
things like performance counters) without getting too bloated.

> > @@ -466,6 +504,11 @@ void update_wall_time(void)
> >  			second_overflow();
> >  		}
> >  
> > +		if (raw_snsec >= (u64)NSEC_PER_SEC << clock->shift) {
> > +			raw_snsec -= (u64)NSEC_PER_SEC << clock->shift;
> > +			monotonic_raw.tv_sec++;
> > +		}
> > +	
> 
> You don't really have to use clock->shift as a scale, thus simplifying the 
> shifting here (e.g. by using NTP_SCALE_SHIFT).
> I'm thinking about doing this for e.g. xtime_nsec as well.

Could you explain this more? 

Given the clocksources have different shift values, why should we not
keep the extra resolution? 

How does adding the extra shifting to convert from the clocksource scale
to the NTP_SCALE_SHIFT value simplify the shifting?

thanks
-john



  reply	other threads:[~2008-03-18  2:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-15  4:04 [PATCH 0/5] time/ntp changes john stultz
2008-03-15  4:05 ` [PATCH 1/5] split clocksource adjustment from clockosurce mult john stultz
2008-03-15  4:06   ` [PATCH 2/5] introduce CLOCK_MONOTONIC_RAW john stultz
2008-03-15  4:10     ` [PATCH 3/5] cleanups ntp.c (from Ingo) john stultz
2008-03-15  4:12       ` [PATCH 4/5] ntp.c code flow clenaups " john stultz
2008-03-15  4:15         ` [PATCH 5/5] make more ntp values static john stultz
2008-03-15  5:09           ` Roman Zippel
2008-03-15  4:52         ` [PATCH 4/5] ntp.c code flow clenaups (from Ingo) Roman Zippel
2008-03-15  5:04           ` John Stultz
2008-03-15 12:39         ` Ingo Oeser
2008-03-15 17:24           ` Roman Zippel
2008-03-15  5:06       ` [PATCH 3/5] cleanups ntp.c " Roman Zippel
2008-03-15  9:32       ` Jörg-Volker Peetz
2008-03-15 17:23         ` Roman Zippel
2008-03-15  4:50     ` [PATCH 2/5] introduce CLOCK_MONOTONIC_RAW Roman Zippel
2008-03-18  2:03       ` john stultz [this message]
2008-03-18  2:27         ` john stultz
2008-03-26  3:41         ` Roman Zippel
2008-03-15  4:28   ` [PATCH 1/5] split clocksource adjustment from clockosurce mult Roman Zippel
2008-03-15  5:07     ` 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=1205805818.28128.91.camel@localhost \
    --to=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=zippel@linux-m68k.org \
    /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