History log of /openbsd-src/sys/kern/sys_futex.c (Results 1 – 22 of 22)
Revision Date Author Comments
# abbd98ea 14-Aug-2023 miod <miod@openbsd.org>

Remove non-MULTIPROCESSOR chunk defining copyin32 as copyin now that all
platforms provide it.


# 0d280c5f 14-Aug-2022 jsg <jsg@openbsd.org>

remove unneeded includes in sys/kern
ok mpi@ miod@


# adec12fb 22-Nov-2021 visa <visa@openbsd.org>

Let futex_wait() run without kernel lock

The KERNEL_LOCK() is no longer necessary with rwsleep() and PCATCH
because the sleep machinery now does the locking internally.

OK mpi@


# e6eeb55a 19-Nov-2021 kettenis <kettenis@openbsd.org>

Make futexes work in shared anonymous memory.

ok mpi@


# 3288ea8f 26-May-2021 kettenis <kettenis@openbsd.org>

Fix the return value for the FUTEX_WAIT/FUTEX_WAIT_PRIVATE futex(2)
operation. System calls should return -1 and set errno when they fail.
They should not return an errno value directly. This match

Fix the return value for the FUTEX_WAIT/FUTEX_WAIT_PRIVATE futex(2)
operation. System calls should return -1 and set errno when they fail.
They should not return an errno value directly. This matches how
the Linux version of futex(2) behaves and what Mesa expects. This fixes
a bug in Mesa where a timeout wouldn't be reported properly.

Technically this is an ABI break. But libc and libpthread were changed
to be compatible with both the old and new ABI, and code outside of base
almost certainly expects Linux compatible behaviour. If you have not
rebuilt libc and the last few days, upgrade using a snap.

Mesa issue discovered by jsg@
ok mpi@, deraadt@

show more ...


# 678831be 10-Mar-2021 jsg <jsg@openbsd.org>

spelling

ok gnezdo@ semarie@ mpi@


# 59fcf85e 06-Apr-2020 cheloha <cheloha@openbsd.org>

futex(2): FUTEX_WAIT: rwsleep_nsec(9) at least one nanosecond

mpi@ and I added a warning log to *sleep_nsec(9) last year to smoke
out division-to-zero bugs when converting kernel code from *sleep(9)

futex(2): FUTEX_WAIT: rwsleep_nsec(9) at least one nanosecond

mpi@ and I added a warning log to *sleep_nsec(9) last year to smoke
out division-to-zero bugs when converting kernel code from *sleep(9)
to the new interfaces. It whines if you tell it to sleep for zero
nanoseconds.

Now that rwsleep_nsec(9) is exposed to userspace via futex(2), though,
it is possible to get a legitimate zero-nanosecond timeout from the
user. This can cause a lot of logging, which apparently can cause
hiccups and hangs in Mesa.

As a quick fix we can round the timeout up to one nanosecond and
silence the warning. No logs, no delays, no hiccups or hangs.

--

Aside: it is unclear what we are supposed to do in the FUTEX_WAIT
zero-nanosecond timeout case: block for a tick or return ETIMEDOUT
immediately. The Linux futex(2) manpage does not mention the case.
It'd be nice to knew what the proper behavior is.

--

Prompted by matthieu@. Input from kettenis@ and deraadt@.

Tested by matthieu@, ajacoutot@.

In snaps since Mar 27 2020.

ok ajacoutot@, deraadt@, kettenis@.

show more ...


# e48149fe 20-Mar-2020 cheloha <cheloha@openbsd.org>

futex(2): futex_wait(): ensure timeout is set when calling rwsleep_nsec(9)

rwsleep_nsec(9) will not set a timeout if the nsecs parameter is
equal to INFSLP (UINT64_MAX). We need to limit the durati

futex(2): futex_wait(): ensure timeout is set when calling rwsleep_nsec(9)

rwsleep_nsec(9) will not set a timeout if the nsecs parameter is
equal to INFSLP (UINT64_MAX). We need to limit the duration to
MAXTSLP (UINT64_MAX - 1) to ensure a timeout is set.

show more ...


# e80014c6 14-Jan-2020 mpi <mpi@openbsd.org>

Introduce TIMESPEC_TO_NSEC() and use it to convert userland facing
tsleep(9) to tsleep_nsec(9).

ok bluhm@


# 8b6fe72e 10-Jul-2019 mpi <mpi@openbsd.org>

Stop sleeping at PUSER.

This allows to enforce that sleeping priorities will now always be <
PUSER.

ok visa@, ratchov@


# a51004ae 06-Feb-2019 mpi <mpi@openbsd.org>

Use ktrreltimespec() as the timeout is relative, pointed by matthew@.

ok cheloha@


# 9448fb1b 23-Jan-2019 cheloha <cheloha@openbsd.org>

Sprinkle a pinch of timerisvalid/timespecisvalid over the rest of sys/kern


# 1cd39fe8 18-Jan-2019 cheloha <cheloha@openbsd.org>

futex(2): validate relative timeout before sleeping.

Linux does validation.

Document this new failure case as an EINVAL, like Linux.

"stop waiting" deraadt


# dbb9e73f 30-Aug-2018 visa <visa@openbsd.org>

Split the system-wide list of all futexes into process-specific lists
of private futexes and a shared list of shared futexes. This speeds up
futex lookups.

Tested by and OK krw@
OK mpi@


# 672a12b3 03-Jun-2018 kettenis <kettenis@openbsd.org>

Implement process-shared futexes. These are now the default implementation.
Introduce process-private futexs. These will bypass the uvm mapping lookup
and should be slightly more efficient.

ok vis

Implement process-shared futexes. These are now the default implementation.
Introduce process-private futexs. These will bypass the uvm mapping lookup
and should be slightly more efficient.

ok visa@, mpi@

show more ...


# e6f936ae 24-Apr-2018 pirofti <pirofti@openbsd.org>

Make futex(2) also return ECANCELED in case SA_RESTART was set.

Prodded by and ok mpi@


# 2ed48580 08-Jan-2018 mpi <mpi@openbsd.org>

Do not pass a userland pointer to ktrabstimespec().

Prevents an infinite pagefault/pmap_enter() loop when ktracing apps
doing a lot of futex(2) calls like firefox & chrome.


# 3b07b489 19-Dec-2017 deraadt <deraadt@openbsd.org>

curproc access isn't necessarily as cheap as a local variable access,
so only get it once
ok guenther


# 703735be 13-Aug-2017 guenther <guenther@openbsd.org>

New flag PR_RWLOCK for pool_init(9) makes the pool use rwlocks instead
of mutexes. Use this immediately for the pool_cache futex pools.

Mostly worked out with dlg@ during e2k17
ok mpi@ tedu@


# 607fea69 27-May-2017 kettenis <kettenis@openbsd.org>

Use copyin32(9) to atomically copy the futex from user space.

On !MULTIPROCESSOR kernels we still fall back on copyin(9), but that is
fine. This will break m88k MULTIPROCESSOR kernels.

ok deraadt@

Use copyin32(9) to atomically copy the futex from user space.

On !MULTIPROCESSOR kernels we still fall back on copyin(9), but that is
fine. This will break m88k MULTIPROCESSOR kernels.

ok deraadt@, mpi@, visa@

show more ...


# 41daea4c 30-Apr-2017 mpi <mpi@openbsd.org>

Return ENOSYS for unsupported operation.


# 004d4497 28-Apr-2017 mpi <mpi@openbsd.org>

Add futex(2) syscall based on a sane subset of its Linux equivalent.

The syscall is marked NOLOCK and only FUTEX_WAIT grabs the KERNEL_LOCK()
because of PCATCH and the signal nightmare.

Serializati

Add futex(2) syscall based on a sane subset of its Linux equivalent.

The syscall is marked NOLOCK and only FUTEX_WAIT grabs the KERNEL_LOCK()
because of PCATCH and the signal nightmare.

Serialization of threads is currently done with a global & exclusive
rwlock.

Note that the current implementation still use copyin(9) which is not
guaranteed to be atomic. Committing now such that remaining issues can
be addressed in-tree.

With inputs from guenther@, kettenis@ and visa@.

ok deraadt@, visa@

show more ...