From: john stultz <johnstul@us.ibm.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Jon Hunter <jon-hunter@ti.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH 1/2] Dynamic Tick: Prevent clocksource wrapping during idle
Date: Wed, 27 May 2009 13:20:15 -0700 [thread overview]
Message-ID: <1243455615.7440.17.camel@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.00.0905271731070.3397@localhost.localdomain>
On Wed, 2009-05-27 at 18:01 +0200, Thomas Gleixner wrote:
> On Wed, 27 May 2009, Jon Hunter wrote:
> > + */
> > +s64 timekeeping_max_deferment(void)
> > +{
> > + s64 max_nsecs;
> > + u64 max_cycles;
> > +
> > + /*
> > + * Calculate the maximum number of cycles that we can pass to the
> > + * cyc2ns function without overflowing a 64-bit signed result. The
> > + * maximum number of cycles is equal to ULLONG_MAX/clock->mult which
> > + * is equivalent to the below.
> > + * max_cycles < (2^63)/clock->mult
> > + * max_cycles < 2^(log2((2^63)/clock->mult))
> > + * max_cycles < 2^(log2(2^63) - log2(clock->mult))
> > + * max_cycles < 2^(63 - log2(clock->mult))
> > + * max_cycles < 1 << (63 - log2(clock->mult))
> > + * Please note that we add 1 to the result of the log2 to account for
> > + * any rounding errors, ensure the above inequality is satisfied and
> > + * no overflow will occur.
> > + */
> > + max_cycles = 1ULL << (63 - (ilog2(clock->mult) + 1));
> > +
> > + /*
> > + * The actual maximum number of cycles we can defer the clocksource is
> > + * determined by the minimum of max_cycles and clock->mask.
> > + */
> > + max_cycles = min(max_cycles, clock->mask);
> > + max_nsecs = cyc2ns(clock, max_cycles);
>
> Why do you want to recalculate the whole stuff over and over ?
>
> That computation can be done when the clock source is initialized or
> any fundamental change of the clock parameters happens.
>
> Stick that value into the clocksource struct and just read it out.
Sigh.
I was hoping to avoid hanging another bit of junk off of the clocksource
struct.
But I guess we could compute that value on registration and keep it
around. Changes to mult could effect things, but should be well within
the 6% safety net we give ourselves.
> > + /*
> > + * To ensure that the clocksource does not wrap whilst we are idle,
> > + * limit the time the clocksource can be deferred by 6.25%. Please
> > + * note a margin of 6.25% is used because this can be computed with
> > + * a shift, versus say 5% which would require division.
> > + */
> > + max_nsecs = max_nsecs - (max_nsecs >> 4);
> > +
> > + if (max_nsecs < 0)
> > + max_nsecs = 0;
>
> How does "max_nsecs = max_nsecs - (max_nsecs >> 4)" ever become
> negative ?
Fair point. Now we've limited the overflow case, we shouldn't trip
negative values.
thanks
-john
next prev parent reply other threads:[~2009-05-27 20:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-27 14:49 [PATCH 1/2] Dynamic Tick: Prevent clocksource wrapping during idle Jon Hunter
2009-05-27 16:01 ` Thomas Gleixner
2009-05-27 20:20 ` john stultz [this message]
2009-05-27 20:32 ` Thomas Gleixner
2009-05-28 20:21 ` Jon Hunter
2009-05-28 20:36 ` Thomas Gleixner
2009-05-28 21:10 ` Jon Hunter
2009-05-28 21:43 ` John Stultz
2009-05-28 22:16 ` Thomas Gleixner
2009-05-29 19:43 ` Jon Hunter
2009-05-30 1:00 ` Jon Hunter
2009-06-04 19:29 ` Jon Hunter
2009-06-25 19:10 ` Jon Hunter
2009-05-27 18:15 ` john stultz
2009-05-27 20:54 ` Alok Kataria
2009-05-27 21:12 ` Thomas Gleixner
-- strict thread matches above, loose matches on Subject: below --
2009-07-28 0:00 [PATCH 0/2] Dynamic Tick: Enabling longer sleep times on 32-bit Jon Hunter
2009-07-28 0:00 ` [PATCH 1/2] Dynamic Tick: Prevent clocksource wrapping during idle Jon Hunter
2009-08-18 17:45 [PATCH 0/2] Dynamic Tick: Enabling longer sleep times on 32-bit machines Jon Hunter
2009-08-18 17:45 ` [PATCH 1/2] Dynamic Tick: Prevent clocksource wrapping during idle Jon Hunter
2009-08-18 19:25 ` Thomas Gleixner
2009-08-18 20:42 ` Jon Hunter
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=1243455615.7440.17.camel@localhost.localdomain \
--to=johnstul@us.ibm.com \
--cc=jon-hunter@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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.