Source-Changes archive

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

CVS commit: [netbsd-10] src



Module Name:    src
Committed By:   martin
Date:           Wed Oct 21 18:50:11 UTC 2026

Modified Files:
        src/sys/kern [netbsd-10]: sys_futex.c
        src/tests/lib/libc/sys [netbsd-10]: t_futex_ops.c

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

        sys/kern/sys_futex.c: revision 1.20
        sys/kern/sys_futex.c: revision 1.21
        sys/kern/sys_futex.c: revision 1.22
        tests/lib/libc/sys/t_futex_ops.c: revision 1.6
        tests/lib/libc/sys/t_futex_ops.c: revision 1.7
        tests/lib/libc/sys/t_futex_ops.c: revision 1.8
        tests/lib/libc/sys/t_futex_ops.c: revision 1.9
        tests/lib/libc/sys/t_futex_ops.c: revision 1.10

sys_futex.c: Fix illustration of futex(2).

In this illustration, we need to _set_ bit 1 to claim ownership, not
_clear_ bit 1 to claim ownership.

No functional change intended -- comment only.

tests/lib/libc/sys/t_futex_ops: Test FUTEX_CMP_REQUEUE edge case.

It must always compare the futex value and fail with EAGAIN on
mismatch, even if there are no waiters.

PR kern/56828: futex calls in Linux emulation sometimes hang

tests/lib/libc/sys/t_futex_ops: Fix FUTEX_CMP_REQUEUE return values.

The return value is the number of waiters woken _or requeued_, not
just the number of waiters woken:

   FUTEX_CMP_REQUEUE
          Returns the total number of waiters that were woken up or
          requeued to the futex for the futex word at uaddr2.  If
          this value is greater than val, then the difference is the
          number of waiters requeued to the futex for the futex word
          at uaddr2.

https://man7.org/linux/man-pages/man2/futex.2.html

PR kern/56828: futex calls in Linux emulation sometimes hang

tests/lib/libc/sys/t_futex_ops: Fix another FUTEX_CMP_REQUEUE case.

PR kern/56828: futex calls in Linux emulation sometimes hang

futex(2): Fix FUTEX_CMP_REQUEUE to always compare even if no waiters.

It must always compare the futex value and fail with EAGAIN on
mismatch, even if there are no waiters.

  FUTEX_CMP_REQUEUE (since Linux 2.6.7)
         This operation first checks whether the location uaddr
         still contains the value val3.  If not, the operation
         fails with the error EAGAIN.  Otherwise, the operation [...]

https://man7.org/linux/man-pages/man2/futex.2.html

PR kern/56828: futex calls in Linux emulation sometimes hang

futex(2): Fix return value of FUTEX_CMP_REQUEUE.

The return value is the number of waiters woken _or requeued_, not
just the number of waiters woken:

   FUTEX_CMP_REQUEUE
          Returns the total number of waiters that were woken up or
          requeued to the futex for the futex word at uaddr2.  If
          this value is greater than val, then the difference is the
          number of waiters requeued to the futex for the futex word
          at uaddr2.

https://man7.org/linux/man-pages/man2/futex.2.html

While here, clarify some of the arguments with comments so it's not
quite so cryptic with val/val2/val3 everywhere.

PR kern/56828: futex calls in Linux emulation sometimes hang


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.4.1 src/sys/kern/sys_futex.c
cvs rdiff -u -r1.5 -r1.5.10.1 src/tests/lib/libc/sys/t_futex_ops.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