From: deraadt Date: Tue, 19 Dec 2017 16:41:43 +0000 (+0000) Subject: curproc access isn't necessarily as cheap as a local variable access, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3b07b489473d508aa238393c6ea8b51dc122ebfe;p=openbsd curproc access isn't necessarily as cheap as a local variable access, so only get it once ok guenther --- 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); }