summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2017-12-19 16:41:44 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2017-12-19 16:41:44 +0000
commit62b1ec8a4f6d6fdaea666e732e6c65a5b1f0bce4 (patch)
treed2fd4e3ee736602a035cabce56b313ef129ecfc6
parent170aa0eb19b27930ebac9e58852ef870758113d2 (diff)
curproc access isn't necessarily as cheap as a local variable access,
so only get it once ok guenther
-rw-r--r--sys/kern/sys_futex.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/kern/sys_futex.c b/sys/kern/sys_futex.c
index 7c46441d1b9..9d00d0f46d9 100644
--- a/sys/kern/sys_futex.c
+++ b/sys/kern/sys_futex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_futex.c,v 1.4 2017/08/13 20:26:33 guenther Exp $ */
+/* $OpenBSD: sys_futex.c,v 1.5 2017/12/19 16:41:43 deraadt Exp $ */
/*
* Copyright (c) 2016-2017 Martin Pieuchot
@@ -129,12 +129,13 @@ sys_futex(struct proc *p, void *v, register_t *retval)
struct futex *
futex_get(uint32_t *uaddr, int flag)
{
+ struct proc *p = curproc;
struct futex *f;
rw_assert_wrlock(&ftlock);
LIST_FOREACH(f, &ftlist, ft_list) {
- if (f->ft_uaddr == uaddr && f->ft_pid == curproc->p_p->ps_pid) {
+ if (f->ft_uaddr == uaddr && f->ft_pid == p->p_p->ps_pid) {
f->ft_refcnt++;
break;
}
@@ -148,7 +149,7 @@ futex_get(uint32_t *uaddr, int flag)
f = pool_get(&ftpool, PR_WAITOK);
TAILQ_INIT(&f->ft_threads);
f->ft_uaddr = uaddr;
- f->ft_pid = curproc->p_p->ps_pid;
+ f->ft_pid = p->p_p->ps_pid;
f->ft_refcnt = 1;
LIST_INSERT_HEAD(&ftlist, f, ft_list);
}