Page MenuHomeFreeBSD

pps: Simplify the nsec calculation in pps_event()
Needs ReviewPublic

Authored by sebastian.huber_embedded-brains.de on Jul 26 2022, 8:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 8, 7:17 AM
Unknown Object (File)
Thu, Oct 30, 2:06 AM
Unknown Object (File)
Oct 10 2025, 1:06 PM
Unknown Object (File)
Oct 9 2025, 4:16 PM
Unknown Object (File)
Oct 9 2025, 4:16 PM
Unknown Object (File)
Oct 9 2025, 2:43 PM
Unknown Object (File)
Sep 26 2025, 11:50 PM
Unknown Object (File)
Sep 14 2025, 7:47 PM

Details

Reviewers
phk
gnn
delphij
Summary

The new calculation should have less problems with integer overflows.

Consider the following sample values with a tcount of 2000000100 and a
tc_frequency of 2000000000 (2GHz). The scale is 9223372036. Then scale *
tcount is 18446744994337203600 which is larger than
UINT64_MAX (18446744073709551615). The result is 49.

In the new calculation, 1000000000 * tcount is 2000000100000000000 which is
less than UINT64_MAX. This yields after the division with tc_frequency the
correct result of 1000000050.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46581
Build 43470: arc lint + arc unit