Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: [netbsd-10] src/sys/kern



Module Name:    src
Committed By:   martin
Date:           Sun Oct 25 11:20:38 UTC 2026

Modified Files:
        src/sys/kern [netbsd-10]: sys_futex.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1399):

        sys/kern/sys_futex.c: revision 1.26

futex(2): Avoid returning early on timeout.

Rounding in the arithmetic leading into cv_timedwait_sig, and any
skew between the timecounter used by clock_gettime and the hardclock
timer used to wake cv_timedwait_sig, can lead cv_timedwait_sig to
wake up before the deadline as observable by clock_gettime.
futex(FUTEX_WAIT) is not supposed to do that, so ignore when
cv_timedwait_sig returns EWOULDBLOCK -- we'll notice the deadline has
passed in the next iteration anyway, if it has actually passed.

While here, make sure that we never pass less than 1 tick to
cv_timedwait_sig -- that turns it into cv_wait_sig, to wait
indefinitely with no timeout.

With this change, I have not seen any failures as reported in:

PR kern/59132: t_futex_ops:futex_wait_timeout_* sometimes fails on
early wakeup

Some instrumentation in futex_wait to count when cv_timedwait_sig
returns early as measured by clock_gettime (not committed in this
change, just local experiments) supports this hypothesis for the
symptoms observed in the PR.


To generate a diff of this commit:
cvs rdiff -u -r1.18.4.2 -r1.18.4.3 src/sys/kern/sys_futex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index