summaryrefslogtreecommitdiff
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-08-06 08:44:55 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-08-06 08:44:55 +0000
commitb0be597016d19c50ca454147735a79cd2fed10ff (patch)
tree45fa5dc0a81bb2d8408f930a184062bac704846e /sys/kern/kern_exit.c
parent2be6b01e44184b82710bf1d175004ad8018f558d (diff)
Stop using KERNEL_LOCK to protect the per process kqueue list
Instead of the KERNEL_LOCK use the ps_mtx for most operations. If the ps_klist is modified an additional global rwlock (kqueue_ps_list_lock) is required. This includes the knotes with NOTE_FORK and NOTE_EXIT since in either cases a ps_klist is changed. In the NOTE_FORK | NOTE_TRACK case the call to kqueue_register() can sleep this is why a global rwlock is used. Adjust the reaper() to call knote_processexit() without KERNEL_LOCK. Double lock idea from visa@ OK mvs@
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 4882de63652..db989e29957 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.228 2024/07/29 09:49:49 claudio Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.229 2024/08/06 08:44:54 claudio Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -477,16 +477,13 @@ reaper(void *arg)
/* Release the rest of the process's vmspace */
uvm_exit(pr);
+ /* Notify listeners of our demise and clean up. */
+ knote_processexit(pr);
+
KERNEL_LOCK();
if ((pr->ps_flags & PS_NOZOMBIE) == 0) {
/* Process is now a true zombie. */
atomic_setbits_int(&pr->ps_flags, PS_ZOMBIE);
- }
-
- /* Notify listeners of our demise and clean up. */
- knote_processexit(pr);
-
- if (pr->ps_flags & PS_ZOMBIE) {
/* Post SIGCHLD and wake up parent. */
prsignal(pr->ps_pptr, SIGCHLD);
wakeup(pr->ps_pptr);