From: visa Date: Mon, 22 Nov 2021 14:57:17 +0000 (+0000) Subject: Let futex_wait() run without kernel lock X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=adec12fb6180510f1389bde829dd46887fac6bf8;p=openbsd 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@ --- diff --git a/sys/kern/sys_futex.c b/sys/kern/sys_futex.c index 1cd3e714bdd..b9303a91cc4 100644 --- a/sys/kern/sys_futex.c +++ b/sys/kern/sys_futex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_futex.c,v 1.19 2021/11/19 15:58:36 kettenis Exp $ */ +/* $OpenBSD: sys_futex.c,v 1.20 2021/11/22 14:57:17 visa Exp $ */ /* * Copyright (c) 2016-2017 Martin Pieuchot @@ -104,31 +104,25 @@ sys_futex(struct proc *p, void *v, register_t *retval) if (op & FUTEX_PRIVATE_FLAG) flags |= FT_PRIVATE; + rw_enter_write(&ftlock); switch (op) { case FUTEX_WAIT: case FUTEX_WAIT_PRIVATE: - KERNEL_LOCK(); - rw_enter_write(&ftlock); error = futex_wait(uaddr, val, timeout, flags); - rw_exit_write(&ftlock); - KERNEL_UNLOCK(); break; case FUTEX_WAKE: case FUTEX_WAKE_PRIVATE: - rw_enter_write(&ftlock); *retval = futex_wake(uaddr, val, flags); - rw_exit_write(&ftlock); break; case FUTEX_REQUEUE: case FUTEX_REQUEUE_PRIVATE: - rw_enter_write(&ftlock); *retval = futex_requeue(uaddr, val, g, (u_long)timeout, flags); - rw_exit_write(&ftlock); break; default: error = ENOSYS; break; } + rw_exit_write(&ftlock); return error; }