summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2023-02-10 14:34:18 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2023-02-10 14:34:18 +0000
commit04d3413ff78e66f127de3749e6564ba940ff320e (patch)
tree8d0adc2e66658136bd528d87b27b8bce64fce574 /sys/kern
parent36d295960f2bd4394d4ae7685b11fcb6cdf82d9f (diff)
Adjust knote(9) API
Make knote(9) lock the knote list internally, and add knote_locked(9) for the typical situation where the list is already locked. Remove the KNOTE(9) macro to simplify the API. Manual page OK jmc@ OK mpi@ mvs@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_event.c18
-rw-r--r--sys/kern/kern_exec.c4
-rw-r--r--sys/kern/kern_fork.c4
-rw-r--r--sys/kern/kern_sig.c4
-rw-r--r--sys/kern/sys_generic.c4
-rw-r--r--sys/kern/sys_pipe.c4
-rw-r--r--sys/kern/uipc_socket.c4
-rw-r--r--sys/kern/uipc_socket2.c4
-rw-r--r--sys/kern/uipc_syscalls.c4
9 files changed, 29 insertions, 21 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index 388691ee69d..a31c036a8a5 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_event.c,v 1.194 2022/11/09 22:25:36 claudio Exp $ */
+/* $OpenBSD: kern_event.c,v 1.195 2023/02/10 14:34:17 visa Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -1590,9 +1590,7 @@ kqueue_task(void *arg)
{
struct kqueue *kq = arg;
- mtx_enter(&kqueue_klist_lock);
- KNOTE(&kq->kq_klist, 0);
- mtx_leave(&kqueue_klist_lock);
+ knote(&kq->kq_klist, 0);
}
void
@@ -1744,6 +1742,16 @@ knote_activate(struct knote *kn)
void
knote(struct klist *list, long hint)
{
+ int ls;
+
+ ls = klist_lock(list);
+ knote_locked(list, hint);
+ klist_unlock(list, ls);
+}
+
+void
+knote_locked(struct klist *list, long hint)
+{
struct knote *kn, *kn0;
struct kqueue *kq;
@@ -1853,7 +1861,7 @@ knote_processexit(struct process *pr)
{
KERNEL_ASSERT_LOCKED();
- KNOTE(&pr->ps_klist, NOTE_EXIT);
+ knote_locked(&pr->ps_klist, NOTE_EXIT);
/* remove other knotes hanging off the process */
klist_invalidate(&pr->ps_klist);
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 6a7188c3264..4c30e5a45b9 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exec.c,v 1.243 2023/01/13 23:02:43 kettenis Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.244 2023/02/10 14:34:17 visa Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
@@ -675,7 +675,7 @@ sys_execve(struct proc *p, void *v, register_t *retval)
/*
* notify others that we exec'd
*/
- KNOTE(&pr->ps_klist, NOTE_EXEC);
+ knote_locked(&pr->ps_klist, NOTE_EXEC);
/* map the process's timekeep page, needs to be before exec_elf_fixup */
if (exec_timekeep_map(pr))
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index ccdd34aafb8..f0f279d9f64 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.245 2023/01/07 05:24:58 guenther Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.246 2023/02/10 14:34:17 visa Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -465,7 +465,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg,
/*
* Notify any interested parties about the new process.
*/
- KNOTE(&curpr->ps_klist, NOTE_FORK | pr->ps_pid);
+ knote_locked(&curpr->ps_klist, NOTE_FORK | pr->ps_pid);
/*
* Update stats now that we know the fork was successful.
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 416cef58181..54c86f6dcf4 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.304 2023/01/31 15:18:56 deraadt Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.305 2023/02/10 14:34:17 visa Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -985,7 +985,7 @@ ptsignal(struct proc *p, int signum, enum signal_type type)
}
if (type != SPROPAGATED)
- KNOTE(&pr->ps_klist, NOTE_SIGNAL | signum);
+ knote_locked(&pr->ps_klist, NOTE_SIGNAL | signum);
prop = sigprop[signum];
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index 46da93a80c2..29f7363fa94 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_generic.c,v 1.151 2022/12/27 20:13:03 patrick Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.152 2023/02/10 14:34:17 visa Exp $ */
/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
@@ -832,7 +832,7 @@ void
selwakeup(struct selinfo *sip)
{
KERNEL_LOCK();
- KNOTE(&sip->si_note, NOTE_SUBMIT);
+ knote_locked(&sip->si_note, NOTE_SUBMIT);
KERNEL_UNLOCK();
}
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 31f3ba45a52..80c401bf6f5 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.143 2022/12/05 23:18:37 deraadt Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.144 2023/02/10 14:34:17 visa Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -370,7 +370,7 @@ pipeselwakeup(struct pipe *cpipe)
{
rw_assert_wrlock(cpipe->pipe_lock);
- KNOTE(&cpipe->pipe_klist, 0);
+ knote_locked(&cpipe->pipe_klist, 0);
if (cpipe->pipe_state & PIPE_ASYNC)
pgsigio(&cpipe->pipe_sigio, SIGIO, 0);
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 612999623a6..0ca3727ccbd 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.300 2023/02/02 09:35:07 mvs Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.301 2023/02/10 14:34:17 visa Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -2122,7 +2122,7 @@ void
sohasoutofband(struct socket *so)
{
pgsigio(&so->so_sigio, SIGURG, 0);
- KNOTE(&so->so_rcv.sb_klist, 0);
+ knote_locked(&so->so_rcv.sb_klist, 0);
}
int
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index 80ac5fc7c01..9965baaf91b 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket2.c,v 1.135 2023/02/02 09:35:07 mvs Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.136 2023/02/10 14:34:17 visa Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@@ -545,7 +545,7 @@ sowakeup(struct socket *so, struct sockbuf *sb)
}
if (sb->sb_flags & SB_ASYNC)
pgsigio(&so->so_sigio, SIGIO, 0);
- KNOTE(&sb->sb_klist, 0);
+ knote_locked(&sb->sb_klist, 0);
}
/*
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 49da6a1bab4..6b8bfc84bac 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.211 2023/01/27 21:01:59 mvs Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.212 2023/02/10 14:34:17 visa Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -326,7 +326,7 @@ doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
: (flags & SOCK_NONBLOCK ? FNONBLOCK : 0);
/* connection has been removed from the listen queue */
- KNOTE(&head->so_rcv.sb_klist, 0);
+ knote_locked(&head->so_rcv.sb_klist, 0);
if (persocket)
sounlock(head);