Page MenuHomeFreeBSD

nanosleep(2): Fix bogus incrementing of rmtp by tc_tick_sbt on [EINTR].
ClosedPublic

Authored by bdrewery on Feb 13 2018, 10:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 22 2024, 10:07 PM
Unknown Object (File)
Jan 20 2024, 4:32 AM
Unknown Object (File)
Jan 16 2024, 1:17 AM
Unknown Object (File)
Jan 10 2024, 2:06 AM
Unknown Object (File)
Dec 16 2023, 7:14 PM
Unknown Object (File)
Nov 29 2023, 11:48 PM
Unknown Object (File)
Oct 6 2023, 5:19 AM
Unknown Object (File)
Sep 6 2023, 10:21 PM
Subscribers

Details

Summary

sbt is the time in the future that the tsleep_sbt() is expected to be completed
at. sbtt is the current time. Depending on the precision with sysctl
kern.timecounter.alloweddeviation the start time may be incremented by
tc_tick_sbt. The same increment is needed for the current time of sbtt before
calculating the difference. The impact of missing this increment is that rmtp
may increase by one tc_tick_sbt on every early [EINTR] return. If the same
struct is passed in for rqtp as rmtp this can result in rqtp effectively
incrementing by tc_tick_sbt and sleeping longer than originally intended .

Sponsored by: Dell EMC
MFC after: 2 weeks

Test Plan

Before:

/usr/tests/lib/libc/sys # /usr/bin/time ./nanosleep_test nanosleep_eintr
nanosleep_test: WARNING: Running test cases outside of kyua(1) is unsupported
nanosleep_test: WARNING: No isolation nor timeout control is being applied; you may get unexpected failures; see atf-test-case(4)
failed: /root/git/freebsd/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c:231: errno: 4 got_info: 1 ts=5.000000242 should be <= tso=5.000000000

failed: nanosleep(2) handled rtmp incorrectly
        0.05 real         0.00 user         0.00 sys

After:

/usr/tests/lib/libc/sys # /usr/bin/time ./nanosleep_test nanosleep_eintr
nanosleep_test: WARNING: Running test cases outside of kyua(1) is unsupported
nanosleep_test: WARNING: No isolation nor timeout control is being applied; you may get unexpected failures; see atf-test-case(4)
passed
        5.00 real         0.00 user         0.00 sys

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 15032
Build 15134: arc lint + arc unit

Event Timeline

Remove unneeded leftover debugging

This revision is now accepted and ready to land.Feb 14 2018, 1:59 PM
markj added inline comments.
contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c
215

I'm not sure that ATF_REQUIRE will DTRT in a child process.

251

I think it's reasonable to use ATF_REQUIRE to check the return values of these syscalls.

contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c
215

It ends up exiting non-zero which the later wait does pickup on. See my testing example.

251

Sure

This revision was automatically updated to reflect the committed changes.