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)
Feb 17 2024, 7:06 PM
Unknown Object (File)
Feb 17 2024, 4:58 PM
Unknown Object (File)
Feb 17 2024, 4:57 PM
Unknown Object (File)
Feb 17 2024, 4:22 PM
Unknown Object (File)
Jan 7 2024, 8:54 PM
Unknown Object (File)
Dec 20 2023, 3:02 AM
Unknown Object (File)
Dec 13 2023, 6:28 AM
Unknown Object (File)
Dec 12 2023, 4:51 PM
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 Not Applicable
Unit
Tests Not Applicable

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.