History log of /openbsd-src/sys/kern/kern_event.c (Results 1 – 25 of 200)
Revision Date Author Comments
# 0747e3d2 06-Aug-2024 claudio <claudio@openbsd.org>

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_l

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@

show more ...


# 235013eb 29-Jul-2024 claudio <claudio@openbsd.org>

Move the signal related kqueue filters to kern_event.c.

Since proc and signal filters share the same klist it makes sense
to keep them together.
OK mvs@


# eaac6367 20-Aug-2023 visa <visa@openbsd.org>

Add kqueue1() system call

kqueue1() takes the flags argument. This lets the kqueue file descriptor
be opened with O_CLOEXEC. Adapted from NetBSD.

OK guenther@


# 471dbed6 13-Aug-2023 visa <visa@openbsd.org>

kevent: Add precision and abstimer flags for EVFILT_TIMER

Add timer precision flags NOTE_SECONDS, NOTE_MSECONDS, NOTE_USECONDS
and NOTE_NSECONDS for EVFILT_TIMER. Also, add an initial implementation

kevent: Add precision and abstimer flags for EVFILT_TIMER

Add timer precision flags NOTE_SECONDS, NOTE_MSECONDS, NOTE_USECONDS
and NOTE_NSECONDS for EVFILT_TIMER. Also, add an initial implementation
of NOTE_ABSTIME timers.

Similar kevent(2) flags exist on FreeBSD, NetBSD and XNU.

Initial diff by and OK aisha@
OK mpi@

show more ...


# b3af768d 11-Apr-2023 jsg <jsg@openbsd.org>

fix double words in comments
feedback and ok jmc@ miod, ok millert@


# c78098b6 10-Feb-2023 visa <visa@openbsd.org>

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.

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@

show more ...


# eadad9f1 09-Nov-2022 claudio <claudio@openbsd.org>

Remove kernel lock here since msleep() with PCATCH no longer requires it.
OK mpi@


# 0d280c5f 14-Aug-2022 jsg <jsg@openbsd.org>

remove unneeded includes in sys/kern
ok mpi@ miod@


# a820167a 09-Jul-2022 visa <visa@openbsd.org>

Unwrap klist from struct selinfo as this code no longer uses selwakeup().

OK jsg@


# dc399801 27-Jun-2022 visa <visa@openbsd.org>

kqueue: Clear task when closing kqueue

When closing a kqueue, block until any pending wakeup task has finished.
Otherwise, if a pending task progressed slowly, the kqueue could stay
alive longer tha

kqueue: Clear task when closing kqueue

When closing a kqueue, block until any pending wakeup task has finished.
Otherwise, if a pending task progressed slowly, the kqueue could stay
alive longer than the associated file descriptor table, causing
a use-after-free in KQRELE().

This also fixes a failed assertion "p->p_kq->kq_refcnt.r_refs == 1" in
kqpoll_exit().

The use-after-free bug had existed since the introduction of
kqueue_task() (the bug could occur if fdplock() blocked in KQRELE()).
However, the issue became worse when the task was allowed to run without
the kernel lock in sys/kern/kern_event.c r1.187.

Prompted by a report from Mikhail on bugs@.

OK mpi@

Reported-by: syzbot+fca7e4fa773c90886819@syzkaller.appspotmail.com

show more ...


# d3f5ce76 20-Jun-2022 visa <visa@openbsd.org>

Remove unused struct fileops field fo_poll and callbacks.

OK mpi@


# a26b930e 12-Jun-2022 visa <visa@openbsd.org>

kqueue: Fix missing wakeup

While one thread is running kqueue_scan(), another thread can begin
scanning the same kqueue, observe that the event queue is empty, and
go to sleep. If the first thread r

kqueue: Fix missing wakeup

While one thread is running kqueue_scan(), another thread can begin
scanning the same kqueue, observe that the event queue is empty, and
go to sleep. If the first thread re-inserts a knote for re-processing,
the second thread can miss the newly pending event. Wake up the kqueue
after a re-insert to correct this.

This fixes a Go test hang that jsing@ tracked down to kqueue.

Tested in snaps for a week.

OK jsing@ mpi@

show more ...


# 1789dd4e 12-May-2022 visa <visa@openbsd.org>

kqueue: Fix race condition in knote_remove()

Always fetch the knlist array pointer at the start of every iteration
in knote_remove(). This prevents the use of a stale pointer after
another thread ha

kqueue: Fix race condition in knote_remove()

Always fetch the knlist array pointer at the start of every iteration
in knote_remove(). This prevents the use of a stale pointer after
another thread has simultaneously reallocated the kq_knlist array.

Reported and tested by and OK jsing@

show more ...


# f8bd7ca9 06-May-2022 visa <visa@openbsd.org>

Replace selwakeup() with KNOTE() in kqueue event activation.

The deferred activation can now run in an MP-safe task queue.


# 26eeb0be 31-Mar-2022 millert <millert@openbsd.org>

Move knote_processexit() call from exit1() to the reaper().
This fixes a problem where NOTE_EXIT could be received before
the process was officially a zombie and thus not immediately
waitable. OK de

Move knote_processexit() call from exit1() to the reaper().
This fixes a problem where NOTE_EXIT could be received before
the process was officially a zombie and thus not immediately
waitable. OK deraadt@ visa@

show more ...


# c76c2d6a 16-Mar-2022 visa <visa@openbsd.org>

Remove an unneeded include.


# 50b77637 16-Mar-2022 visa <visa@openbsd.org>

Use the refcnt API in kqueue.

OK dlg@ bluhm@


# 7eb8d89d 22-Feb-2022 guenther <guenther@openbsd.org>

Delete unnecessary #includes of <sys/domain.h> and/or <sys/protosw.h>

net/if_pppx.c pointed out by jsg@
ok gnezdo@ deraadt@ jsg@ mpi@ millert@


# f093adcc 13-Feb-2022 visa <visa@openbsd.org>

Use knote_modify() and knote_process() in obvious places.


# a3a2b40e 13-Feb-2022 visa <visa@openbsd.org>

Rename knote_modify() to knote_assign()

This avoids verb overlap with f_modify.


# 608b7d9a 11-Feb-2022 visa <visa@openbsd.org>

Inline klist_empty() for more economic machine code.

OK mpi@


# c5e59ae3 08-Feb-2022 visa <visa@openbsd.org>

poll(2): Switch to kqueue backend

Implement the poll(2) system call on top of the kqueue subsystem.
This obsoletes the old, non-MP-safe poll backend.

On entering poll(2), the new code translates ea

poll(2): Switch to kqueue backend

Implement the poll(2) system call on top of the kqueue subsystem.
This obsoletes the old, non-MP-safe poll backend.

On entering poll(2), the new code translates each pollfd array entry
into a set of knotes. When these knotes receive events through kqueue,
the events are translated back to pollfd format.

Entries in the pollfd array can refer to the same file descriptor with
overlapping event masks. To allow such overlap with knotes, use an extra
kn_pollid key that separates knotes of different pollfd entries.

Adapted from DragonFly BSD, initial implementation by mpi@.

Tested in snaps for three weeks.

OK mpi@

show more ...


# ce1591e9 25-Dec-2021 visa <visa@openbsd.org>

kqueue: Invalidate revoked vnodes' knotes on the fly

When a tty device is revoked, the associated knotes should be
invalidated. Otherwise the user processes can keep on receiving
events from the dev

kqueue: Invalidate revoked vnodes' knotes on the fly

When a tty device is revoked, the associated knotes should be
invalidated. Otherwise the user processes can keep on receiving
events from the device.

It appears tricky to do the invalidation as part of revocation
in a way that does not allow unwanted event registration or clutter
the tty code. For now, make the knotes invalid lazily before delivery.

OK mpi@

show more ...


# 321d7ba1 20-Dec-2021 visa <visa@openbsd.org>

Make filt_dead() selectively inactive with EVFILT_EXCEPT

When a knote uses the dead event filter, the knote's file descriptor is
not supposed to point to an object with pending out-of-band data. Mak

Make filt_dead() selectively inactive with EVFILT_EXCEPT

When a knote uses the dead event filter, the knote's file descriptor is
not supposed to point to an object with pending out-of-band data. Make
the knote inactive so that userspace will not receive a spurious event.
However, kqueue-based poll(2) should still receive HUP notifications.

This lets the system use dead_filtops with less strings attached
relative to the filter type.

show more ...


# 69e8f641 20-Dec-2021 visa <visa@openbsd.org>

Run seltrue/dead event filter in modify and process callbacks

Do not assume event status in the modify and process callbacks. Instead
always run the event filter so that it has a chance to set knote

Run seltrue/dead event filter in modify and process callbacks

Do not assume event status in the modify and process callbacks. Instead
always run the event filter so that it has a chance to set knote flags.
The filter can also indicate event inactivity.

show more ...


12345678