Re: x86: Clean up computation of HPET .mult variables

From: Daniel Walker
Date: Tue May 06 2008 - 12:21:33 EST



On Tue, 2008-05-06 at 09:59 -0300, Carlos R. Mafra wrote:
> On Mon 5.May'08 at 20:23:38 -0700, Daniel Walker wrote:
> >
> > On Mon, 2008-05-05 at 23:13 -0300, Carlos R. Mafra wrote:
> > > So the savings in my patch is due to using the period directly, and
> > > not the frequency. That's what my idea was, so if you object then
> > > my attempt was a failure and should be forgotten :-)
> > >
> > > Or maybe I should create a clocksource_period2mult to replace
> > > clocksource_hz2mult and save the extra operation in more places too?
> >
> > The one concern I have is the rounding that is done in the
> > clocksource_hz2mult(). The div_sc doesn't include it ..
>
> So that would be a point in favour of using div_sc(), right?

No, the other way. I think clocksource_hz2mult() is more accurate.

> > You could add a
> > clocksource_period2mult(), that would help out any one later that has a
> > period instead of hz ..
>
> Hmm, clocksource_period2mult() would be just a rename of div_sc(), see
> for example how clocksource_hpet.mult is computed with my patch:
>
> clocksource_hpet.mult = div_sc(hpet_period, FSEC_PER_NSEC, HPET_SHIFT);
>
> However, hpet_clockevent.mult would also require the exchange of
> the first two arguments, due to the different definition of 'mult' in
> clockchips.h and clocksource.h
>
> So I would like to ask if this different definition of mult
> variables in clockevent versus clocksource is intentional or not.

clockevents convert nanoseconds to cycles, clocksources convert cycles
to nanosecond. So the mult would reflect that difference I imagine.

> And do you agree that your first suggestion of using clocksource_hz2mult
> makes the code a bit bigger due to the extra computation of the frequency?

I agree, but the size in this case takes a back seat to accuracy.

Daniel


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/