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
F110368562: D14433.id39491.diff
Mon, Feb 17, 10:41 AM
Unknown Object (File)
Mon, Feb 10, 9:06 PM
Unknown Object (File)
Thu, Jan 23, 9:35 AM
Unknown Object (File)
Thu, Jan 23, 8:11 AM
Unknown Object (File)
Jan 10 2025, 4:40 AM
Unknown Object (File)
Dec 3 2024, 8:01 AM
Unknown Object (File)
Nov 30 2024, 12:09 PM
Unknown Object (File)
Nov 27 2024, 9:19 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.