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
F166438298: D35934.id108534.diff
Thu, Aug 13, 2:06 PM
F166276557: D35934.id108534.diff
Wed, Aug 12, 4:08 PM
Unknown Object (File)
Sun, Aug 9, 11:33 AM
Unknown Object (File)
Fri, Aug 7, 3:24 PM
Unknown Object (File)
Sun, Aug 2, 12:51 AM
Unknown Object (File)
Sat, Aug 1, 6:19 AM
Unknown Object (File)
Thu, Jul 30, 6:33 PM
Unknown Object (File)
Sun, Jul 26, 3:41 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