diff options
author | Bryan Cantrill <bryan@joyent.com> | 2015-11-24 00:52:37 +0000 |
---|---|---|
committer | Bryan Cantrill <bryan@joyent.com> | 2015-11-24 00:52:37 +0000 |
commit | b5f003d2e8f332c927f56a1acdde16bfcf75b84e (patch) | |
tree | 88c3b30dc78f7dea8e1550f4ea43826946ca6284 | |
parent | 0792257c4de07774eba0702312b89bd28face759 (diff) | |
download | illumos-joyent-b5f003d2e8f332c927f56a1acdde16bfcf75b84e.tar.gz |
OS-4956 trap() acquires p_lock unnecessarily
-rw-r--r-- | usr/src/uts/i86pc/os/trap.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/usr/src/uts/i86pc/os/trap.c b/usr/src/uts/i86pc/os/trap.c index 7aadc17f4a..c88fec6fbe 100644 --- a/usr/src/uts/i86pc/os/trap.c +++ b/usr/src/uts/i86pc/os/trap.c @@ -1480,12 +1480,23 @@ trap(struct regs *rp, caddr_t addr, processorid_t cpuid) ct->t_sig_check = 0; - mutex_enter(&p->p_lock); + /* + * As in other code paths that check against TP_CHANGEBIND, + * we perform the check first without p_lock held -- only + * acquiring p_lock in the unlikely event that it is indeed + * set. This is safe because we are doing this after the + * astoff(); if we are racing another thread setting + * TP_CHANGEBIND on us, we will pick it up on a subsequent + * lap through. + */ if (curthread->t_proc_flag & TP_CHANGEBIND) { - timer_lwpbind(); - curthread->t_proc_flag &= ~TP_CHANGEBIND; + mutex_enter(&p->p_lock); + if (curthread->t_proc_flag & TP_CHANGEBIND) { + timer_lwpbind(); + curthread->t_proc_flag &= ~TP_CHANGEBIND; + } + mutex_exit(&p->p_lock); } - mutex_exit(&p->p_lock); /* * for kaio requests that are on the per-process poll queue, |