Page MenuHomeFreeBSD

Fix 32-bit overflow on latency measurements
ClosedPublic

Authored by imp on Aug 24 2017, 5:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 7:49 PM
Unknown Object (File)
Mar 14 2024, 11:27 PM
Unknown Object (File)
Jan 23 2024, 4:45 AM
Unknown Object (File)
Dec 29 2023, 12:58 AM
Unknown Object (File)
Dec 23 2023, 3:54 PM
Unknown Object (File)
Dec 22 2023, 11:29 PM
Unknown Object (File)
Dec 2 2023, 7:15 PM
Unknown Object (File)
Dec 2 2023, 2:34 AM
Subscribers

Details

Reviewers
scottl
ken
mjoras
Group Reviewers
cam
Summary

o Allow I/O scheduler to gather times on 32-bit systems. We do this by shifting

the sbintime_t over by 8 bits and truncating to 32-bits. This gives us 8.24
time. This is sufficient both in range (256 seconds is about 128x what current
users need) and precision (60ns easily meets the 1ms smallest bucket size
measurements). 64-bit systems are unchanged. Centralize all the time math so
it's easy to tweak tha range / precision tradeoffs in the future.

o While I'm here, the I/O scheduler should be using periph_data rather than

sim_data since it is operating on behalf of the periph.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 11225
Build 11603: arc lint + arc unit

Event Timeline

mjoras added inline comments.
sys/cam/cam_iosched.h
48

If we're being pedantic the maximum interval is actually 255 seconds + the maximum fractional second which gives nearly 256 seconds in total but not quite. Maybe add a ~ to indicate it is almost 256?

49

For my own curiosity, where does the ~2s requirement come from?

sys/cam/cam_iosched.h
48

256s - 232picoseconds.

49

1.024ms is the upper bound for the power-of-two latency histogram, which is what this data drives.

The integer handling looks correct. It is definitely better than the defined-but-bad behavior of truncating the non-fractional bits of sbintime_t on ILP32. Using unsigned values everywhere makes all the operations well-defined and reasonable.

This revision is now accepted and ready to land.Aug 24 2017, 8:04 PM