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
F170983865: D35934.diff
Tue, Sep 8, 12:31 AM
Unknown Object (File)
Sat, Sep 5, 1:21 AM
Unknown Object (File)
Fri, Sep 4, 8:08 PM
Unknown Object (File)
Thu, Sep 3, 4:50 PM
Unknown Object (File)
Thu, Sep 3, 6:21 AM
Unknown Object (File)
Thu, Sep 3, 4:42 AM
Unknown Object (File)
Wed, Sep 2, 9:07 PM
Unknown Object (File)
Tue, Sep 1, 5:06 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