From: Roman Zippel <zippel@linux-m68k.org>
To: john stultz <johnstul@us.ibm.com>
Cc: lkml <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH 2/5] introduce CLOCK_MONOTONIC_RAW
Date: Wed, 26 Mar 2008 04:41:11 +0100 [thread overview]
Message-ID: <200803260441.12155.zippel@linux-m68k.org> (raw)
In-Reply-To: <1205805818.28128.91.camel@localhost>
Hi,
On Tuesday 18. March 2008, john stultz wrote:
> > 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).
I didn't looked at the code, what I meant was moving it close to it, so it's
done at the same time.
> 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.
You could use a shift (e.g. SHIFT_HZ for non NO_HZ), to scale these value up a
little.
> > 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.
It's not cruft, littering the code with unnecessary static variables is IMO
worse. In OO terms this would be an abstract base class, the actual
implementation only needs to provide a few functions and otherwise doesn't
really have to worry about all the details.
Splitting the structure is certainly an option, but hiding related variables
as static is IMO not a good choice.
> I'm still not sold on the multiple clocks with multiple notions of time
> idea you keep on bringing up.
Well, here are some ideas where I think it might be useful, it would make it
possible to chain clocks with different frequencies:
- SMP systems with slighty different clock frequencies.
- instead of deactivating an unstable tsc clock, delay activation until we
know it's stable.
- deactivate a tsc (which stops during sleep) before sleep and resync when
needed.
- use different clocks for timer purposes (e.g. jiffies and a slow clock).
(The last point would make IMO more acceptable to use hrtimer for more trivial
purposes, if it were at least possible to select the used clock.)
> > > + 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?
The extra resolution is still there, as it doesn't make any sense to use a
shift larger than 32.
> How does adding the extra shifting to convert from the clocksource scale
> to the NTP_SCALE_SHIFT value simplify the shifting?
NTP_SCALE_SHIFT is a constant and a very simple shift, which produces better
code.
There are two ways to use the nsec value here:
1. nsec_now = (((cycle_new - cycle_last) * mult) + nsec) >> shift
2. nsec_now = ((cycle_new - cycle_last) * mult) >> shift +
nsec >> NTP_SCALE_SHIFT
Both do the same under the condition that the gettime operation is not
significantly shorter than 1nsec, but the second version can generate
slightly better code. I intended to use the first for xtime_nsec, but instead
the value is still splitted at every timer interrupt.
For the raw time please at least get rid of the splitting of raw_nsec in
update_wall_time(). From the monotonic_raw value you only need the tv_sec
part and the tv_nsec part can be calculated as above.
bye, Roman
next prev parent reply other threads:[~2008-03-26 4:40 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
2008-03-18 2:27 ` john stultz
2008-03-26 3:41 ` Roman Zippel [this message]
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=200803260441.12155.zippel@linux-m68k.org \
--to=zippel@linux-m68k.org \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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