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)
Mon, Dec 9, 6:01 AM
Unknown Object (File)
Oct 6 2024, 12:17 AM
Unknown Object (File)
Oct 1 2024, 12:26 AM
Unknown Object (File)
Sep 16 2024, 2:53 AM
Unknown Object (File)
Sep 10 2024, 10:39 PM
Unknown Object (File)
Sep 4 2024, 10:53 AM
Unknown Object (File)
Aug 6 2024, 4:32 AM
Unknown Object (File)
Jul 19 2024, 4:06 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