Page MenuHomeFreeBSD

PowerPC: Switch to more accurate unit to avoid division rounding
ClosedPublic

Authored by pdk_semihalf.com on Feb 19 2018, 12:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 21, 7:12 PM
Unknown Object (File)
Tue, Nov 12, 2:56 AM
Unknown Object (File)
Mon, Nov 4, 7:41 PM
Unknown Object (File)
Oct 9 2024, 6:38 PM
Unknown Object (File)
Sep 25 2024, 10:10 AM
Unknown Object (File)
Sep 24 2024, 6:20 PM
Unknown Object (File)
Sep 22 2024, 1:38 PM
Unknown Object (File)
Sep 22 2024, 12:12 AM
Subscribers
None

Details

Summary

On POWER8 architecture there is a timer with 512Mhz frequency.
It has about 1,95ns period, but it is rounded to 1ns which is not accurate.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

I think this breaks 32-bit builds since ps_per_tick is too small there. I think it needs to be bumped to uint64_t.

Changed type of ps_per_tick to uint64_t

This revision was not accepted when it landed; it landed in state Needs Review.Feb 20 2018, 7:31 AM
This revision was automatically updated to reflect the committed changes.

Just a comment on uint64_t: ps is 10^12, which is 36 bits to represent 1s, so switching to uint64_t will gives the most safety, especially given that the howmany macro isn't careful about overflow. Since it's just used in DELAY, and we know n for delay is usually small except in some crazy old ISA drivers, it likely worked or closely worked with 32-bit types. It wouldn't hit problems until several hundred or maybe thousand milliseconds if the back of the envelop numbers I just ran are right....
I'd be tempted in DELAY to s/u_quad_t/uint64_t/g since the quad name for that type is discouraged, but it's not a bug deal either way.
Quibbles aside, this was a good change before the change to 64-bit, and is a better change with that change as clocks will only get faster from here.