OpenBSD CVS

CVS log for src/sys/kern/kern_event.c


[BACK] Up to [local] / src / sys / kern

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.198 / (download) - annotate - [select for diffs], Sun Aug 20 15:13:43 2023 UTC (9 months, 3 weeks ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, HEAD
Changes since 1.197: +26 -5 lines
Diff to previous 1.197 (colored)

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@

Revision 1.197 / (download) - annotate - [select for diffs], Sun Aug 13 08:29:28 2023 UTC (9 months, 4 weeks ago) by visa
Branch: MAIN
Changes since 1.196: +77 -14 lines
Diff to previous 1.196 (colored)

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@

Revision 1.196 / (download) - annotate - [select for diffs], Tue Apr 11 00:45:09 2023 UTC (14 months ago) by jsg
Branch: MAIN
Changes since 1.195: +2 -2 lines
Diff to previous 1.195 (colored)

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

Revision 1.195 / (download) - annotate - [select for diffs], Fri Feb 10 14:34:17 2023 UTC (16 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.194: +13 -5 lines
Diff to previous 1.194 (colored)

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@

Revision 1.194 / (download) - annotate - [select for diffs], Wed Nov 9 22:25:36 2022 UTC (19 months ago) by claudio
Branch: MAIN
Changes since 1.193: +1 -10 lines
Diff to previous 1.193 (colored)

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

Revision 1.193 / (download) - annotate - [select for diffs], Sun Aug 14 01:58:27 2022 UTC (21 months, 4 weeks ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.192: +1 -6 lines
Diff to previous 1.192 (colored)

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

Revision 1.192 / (download) - annotate - [select for diffs], Sat Jul 9 12:48:21 2022 UTC (23 months ago) by visa
Branch: MAIN
Changes since 1.191: +8 -9 lines
Diff to previous 1.191 (colored)

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

OK jsg@

Revision 1.191 / (download) - annotate - [select for diffs], Mon Jun 27 13:35:21 2022 UTC (23 months, 2 weeks ago) by visa
Branch: MAIN
Changes since 1.190: +11 -6 lines
Diff to previous 1.190 (colored)

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

Revision 1.190 / (download) - annotate - [select for diffs], Mon Jun 20 01:39:44 2022 UTC (23 months, 3 weeks ago) by visa
Branch: MAIN
Changes since 1.189: +1 -23 lines
Diff to previous 1.189 (colored)

Remove unused struct fileops field fo_poll and callbacks.

OK mpi@

Revision 1.189 / (download) - annotate - [select for diffs], Sun Jun 12 10:34:36 2022 UTC (23 months, 4 weeks ago) by visa
Branch: MAIN
Changes since 1.188: +7 -1 lines
Diff to previous 1.188 (colored)

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@

Revision 1.186.2.1 / (download) - annotate - [select for diffs], Sun May 15 19:56:46 2022 UTC (2 years ago) by bluhm
Branch: OPENBSD_7_1
Changes since 1.186: +10 -8 lines
Diff to previous 1.186 (colored) next main 1.187 (colored)

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.

from visa@; reported and tested by and OK jsing@

this is errata/7.1/003_kqueue.patch.sig

Revision 1.188 / (download) - annotate - [select for diffs], Thu May 12 13:33:00 2022 UTC (2 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.187: +10 -8 lines
Diff to previous 1.187 (colored)

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@

Revision 1.187 / (download) - annotate - [select for diffs], Fri May 6 13:12:16 2022 UTC (2 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.186: +5 -17 lines
Diff to previous 1.186 (colored)

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

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

Revision 1.186 / (download) - annotate - [select for diffs], Thu Mar 31 01:41:22 2022 UTC (2 years, 2 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE
Branch point for: OPENBSD_7_1
Changes since 1.185: +2 -5 lines
Diff to previous 1.185 (colored)

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@

Revision 1.185 / (download) - annotate - [select for diffs], Wed Mar 16 16:17:46 2022 UTC (2 years, 2 months ago) by visa
Branch: MAIN
Changes since 1.184: +1 -2 lines
Diff to previous 1.184 (colored)

Remove an unneeded include.

Revision 1.184 / (download) - annotate - [select for diffs], Wed Mar 16 14:38:43 2022 UTC (2 years, 2 months ago) by visa
Branch: MAIN
Changes since 1.183: +5 -5 lines
Diff to previous 1.183 (colored)

Use the refcnt API in kqueue.

OK dlg@ bluhm@

Revision 1.183 / (download) - annotate - [select for diffs], Tue Feb 22 01:15:01 2022 UTC (2 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.182: +1 -2 lines
Diff to previous 1.182 (colored)

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@

Revision 1.182 / (download) - annotate - [select for diffs], Sun Feb 13 13:05:51 2022 UTC (2 years, 3 months ago) by visa
Branch: MAIN
Changes since 1.181: +3 -15 lines
Diff to previous 1.181 (colored)

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

Revision 1.181 / (download) - annotate - [select for diffs], Sun Feb 13 12:58:46 2022 UTC (2 years, 3 months ago) by visa
Branch: MAIN
Changes since 1.180: +7 -7 lines
Diff to previous 1.180 (colored)

Rename knote_modify() to knote_assign()

This avoids verb overlap with f_modify.

Revision 1.180 / (download) - annotate - [select for diffs], Fri Feb 11 07:25:50 2022 UTC (2 years, 3 months ago) by visa
Branch: MAIN
Changes since 1.179: +1 -7 lines
Diff to previous 1.179 (colored)

Inline klist_empty() for more economic machine code.

OK mpi@

Revision 1.179 / (download) - annotate - [select for diffs], Tue Feb 8 08:56:41 2022 UTC (2 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.178: +31 -5 lines
Diff to previous 1.178 (colored)

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@

Revision 1.178 / (download) - annotate - [select for diffs], Sat Dec 25 11:04:58 2021 UTC (2 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.177: +32 -1 lines
Diff to previous 1.177 (colored)

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@

Revision 1.177 / (download) - annotate - [select for diffs], Mon Dec 20 16:24:32 2021 UTC (2 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.176: +12 -1 lines
Diff to previous 1.176 (colored)

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.

Revision 1.176 / (download) - annotate - [select for diffs], Mon Dec 20 16:21:07 2021 UTC (2 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.175: +8 -4 lines
Diff to previous 1.175 (colored)

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.

Revision 1.175 / (download) - annotate - [select for diffs], Sat Dec 11 09:28:26 2021 UTC (2 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.174: +2 -2 lines
Diff to previous 1.174 (colored)

Clarify usage of __EV_POLL and __EV_SELECT

Make __EV_POLL specific to kqueue-based poll(2), to remove overlap
with __EV_SELECT that only select(2) uses.

OK millert@ mpi@

Revision 1.174 / (download) - annotate - [select for diffs], Mon Nov 29 15:54:04 2021 UTC (2 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.173: +31 -87 lines
Diff to previous 1.173 (colored)

kqueue: Revise badfd knote handling

When closing a file descriptor and converting the poll/select knotes
into badfd knotes, keep the knotes attached to the by-fd table. This
should prevent kqueue_purge() from returning before the kqueue has
become quiescent. This in turn should fix a
KASSERT(TAILQ_EMPTY(&kq->kq_head)) panic in KQRELE() that bluhm@ has
reported.

The badfd conversion is only needed when a poll/select scan is ongoing.
The system can skip the conversion if the knote is not part of the
active event set.

The code of this commit skips the conversion when the fd is closed by
the same thread that has done the fd polling. This can be improved but
should already cover typical fd usage patterns.

As badfd knotes now hold slots in the by-fd table, kqueue_register()
clears them. poll/select use kqueue_register() to set up a new scan;
any found fd close notification is a leftover from the previous scan.

The new badfd handling should be free of accidental knote accumulation.
This obsoletes kqpoll_dequeue() and lowers kqpoll_init() overhead.

Re-enable lazy removal of poll/select knotes because the panic should
no longer happen.

OK mpi@

Revision 1.173 / (download) - annotate - [select for diffs], Mon Nov 15 15:48:54 2021 UTC (2 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.172: +4 -1 lines
Diff to previous 1.172 (colored)

Revert to eager removal of poll/select knotes

This should prevent a panic that bluhm@ has reported.

Revision 1.172 / (download) - annotate - [select for diffs], Sat Nov 13 06:04:02 2021 UTC (2 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.171: +2 -2 lines
Diff to previous 1.171 (colored)

Let filt_fileattach() run without the kernel lock

This makes it possible to attach pipe, socket and kqueue event filters
without acquiring the kernel lock. Event filters behind vn_kqfilter()
are not MP-safe yet, so vn_kqfilter() has to take KERNEL_LOCK().
dmabuf_kqfilter() can skip locking because it has no side effects.

OK anton@, mpi@

Revision 1.171 / (download) - annotate - [select for diffs], Fri Nov 12 04:34:22 2021 UTC (2 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.170: +53 -17 lines
Diff to previous 1.170 (colored)

Keep knotes between poll/select systems calls

Reduce the time overhead of kqueue-based poll(2) and select(2) by
keeping knotes registered between the system calls. It is expected that
the set of monitored file descriptors is relatively unchanged between
consecutive iterations of these system calls. By keeping the knotes,
the system saves the effort of repeated knote unregistering and
re-registering.

To avoid receiving events from file descriptors that are no longer in
the monitored set, each poll/select knote is assigned an increasing
serial number. Every iteration of poll/select uses a previously unused
range of serials for its knotes. In the setup stage, kqueue_register()
updates the serials of any existing knotes in the currently monitored
set. Function kqueue_scan() delivers only the events whose serials are
recent enough; expired knotes are dropped. When the serial range is
about to wrap around, all the knotes in the kqueue backend are dropped.

This change is a space-time tradeoff. Memory usage is increased somewhat
because of the retained knotes. The increase is limited by the number
of open file descriptors and active threads.

Idea from DragonFly BSD, initial patch by mpi@, kqueue_scan()-based
approach by me.

Tested by anton@ and mpi@
OK mpi@

Revision 1.170 / (download) - annotate - [select for diffs], Sat Nov 6 05:48:47 2021 UTC (2 years, 7 months ago) by visa
Branch: MAIN
Changes since 1.169: +60 -6 lines
Diff to previous 1.169 (colored)

Make kqread event filter MP-safe

Use the monitored kqueue's kq_lock to serialize kqueue and knote access.

Typically, the "object lock" would cover also the klist, but that is not
possible with kqueues. knote_activate() needs kq_lock of the monitoring
kqueue, which would create lock order troubles if kq_lock was held when
calling KNOTE(&kq->kq_sel.si_note). Avoid this by using a separate klist
lock for kqueues.

The new klist lock is system-wide. Each kqueue instance could have
a dedicated klist lock. However, the efficacy of dedicated versus
system-wide lock is somewhat limited because the current implementation
activates kqueue knotes through a single thread.

OK mpi@

Revision 1.169 / (download) - annotate - [select for diffs], Sat Jul 24 09:16:51 2021 UTC (2 years, 10 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.168: +7 -1 lines
Diff to previous 1.168 (colored)

Modifying a knote must be done with the corresponding lock held.  Assert
that the KERNEL_LOCK() is held unless the filter is marked as MPSAFE.

Should help finding missing locks when unlocking various filters.

ok visa@

Revision 1.168 / (download) - annotate - [select for diffs], Thu Jul 22 07:22:43 2021 UTC (2 years, 10 months ago) by visa
Branch: MAIN
Changes since 1.167: +43 -19 lines
Diff to previous 1.167 (colored)

Make kqpoll_dequeue() usable with lazy removal of knotes

Adjust kqpoll_dequeue() so that it will clear only badfd knotes when
called from kqpoll_init(). This is needed by kqpoll's lazy removal
of knotes. Eager removal in kqpoll_dequeue() would defeat kqpoll's
attempt to reuse previously established knotes under workloads where
knote activation tends to occur already before next kqpoll scan.

Prompted by mpi@

Revision 1.167 / (download) - annotate - [select for diffs], Wed Jun 16 14:26:30 2021 UTC (2 years, 11 months ago) by visa
Branch: MAIN
Changes since 1.166: +14 -5 lines
Diff to previous 1.166 (colored)

kqueue: kq_lock is needed when updating kn_status

The kn_status field of struct knote is part of kqueue's internal state.
When kn_status is being updated, kq_lock has to be locked. This is true
even with MP-unsafe event filters.

OK mpi@

Revision 1.166 / (download) - annotate - [select for diffs], Fri Jun 11 04:29:54 2021 UTC (3 years ago) by visa
Branch: MAIN
Changes since 1.165: +4 -4 lines
Diff to previous 1.165 (colored)

Remember to lock kqueue mutex in filt_timermodify().

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

Revision 1.165 / (download) - annotate - [select for diffs], Thu Jun 10 15:10:56 2021 UTC (3 years ago) by visa
Branch: MAIN
Changes since 1.164: +164 -108 lines
Diff to previous 1.164 (colored)

Serialize internals of kqueue with a mutex

Extend struct kqueue with a mutex and use it to serializes the internals
of each kqueue instance. This should make possible to call kqueue's
system call interface without the kernel lock. The event source facing
side of kqueue should now be MP-safe, too, as long as the event source
itself is MP-safe.

msleep() with PCATCH still requires the kernel lock. To manage with
this, kqueue_scan() locks the kernel temporarily for the section that
may sleep.

As a consequence of the kqueue mutex, knote_acquire() can lose a wakeup
when klist_invalidate() calls it. To preserve proper nesting of mutexes,
knote_acquire() has to release the kqueue mutex before it unlocks klist.
This early unlocking of the mutex lets badly timed wakeups go unnoticed.
However, the system should not hang because the sleep has a timeout.

Tested by gnezdo@ and mpi@

OK mpi@

Revision 1.164 / (download) - annotate - [select for diffs], Wed Jun 2 13:56:28 2021 UTC (3 years ago) by visa
Branch: MAIN
Changes since 1.163: +7 -2 lines
Diff to previous 1.163 (colored)

Enable pool cache on knote pool

Use the pool cache to reduce the overhead of memory management in
function kqueue_register().

When EV_ADD is given, kqueue_register() pre-allocates a knote to avoid
potential sleeping in the middle of the critical section that spans
from knote lookup to insertion. However, the pre-allocation is useless
if the lookup finds a matching knote.

The cost of knote allocation will become significant with kqueue-based
poll(2) and select(2) because the frequency of allocation will increase.
Most of the cost appears to come from the locking inside the pool.
The pool cache amortizes it by using CPU-local caches of free knotes
as buffers.

OK dlg@ mpi@

Revision 1.163 / (download) - annotate - [select for diffs], Thu Apr 22 15:30:12 2021 UTC (3 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.162: +42 -6 lines
Diff to previous 1.162 (colored)

kqueue: Make timer re-addition reset existing timer

When an existing EVFILT_TIMER filter is re-added, cancel the existing
timer and any pending event, and restart the timer using the new timeout
period. This makes the new timeout period take effect immediately and
matches the behaviour of FreeBSD. Previously, the new setting was
applied only after the existing timer expired.

The timer rescheduling is done by using an f_modify callback. The
reading of timer events is moved from f_event to f_process. f_event of
timer_filtops becomes redundant. Unlike most other event sources, timers
activate knotes directly without using a klist and knote(9).

OK mpi@

Revision 1.162 / (download) - annotate - [select for diffs], Sat Feb 27 13:43:16 2021 UTC (3 years, 3 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.161: +2 -2 lines
Diff to previous 1.161 (colored)

Replace stray direct call of f_event with filter_event().

This does not change the current behaviour, but filterops should be
invoked through filter_*() for consistency.

Revision 1.161 / (download) - annotate - [select for diffs], Wed Feb 24 14:59:52 2021 UTC (3 years, 3 months ago) by visa
Branch: MAIN
Changes since 1.160: +188 -41 lines
Diff to previous 1.160 (colored)

kqueue: Revise filterops interface

Extend kqueue's filterops interface with new callbacks so that it
becomes easier to use with fine-grained locking. The new interface
delegates the serialization of kn_event access to event sources. Now
kqueue uses filterops callbacks to read or write kn_event. This hides
event sources' locking patterns from kqueue, and allows clean
implementation of atomic read-and-clear for EV_CLEAR, for instance.

There are so many existing filterops instances that converting all of
them in one go is tricky. This patch adds a wrapper mechanism that
kqueue uses when the new callbacks are missing.

The new filterops interface has been influenced by XNU's kqueue.

OK mpi@ semarie@

Revision 1.160 / (download) - annotate - [select for diffs], Wed Jan 27 02:58:03 2021 UTC (3 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.159: +12 -2 lines
Diff to previous 1.159 (colored)

kqueue: Fix termination assert

When a kqueue file is closed, the kqueue can still have threads
scanning it. Consequently, kqueue_terminate() can see scan markers
in the event queue. These markers are removed when the scanning threads
leave the kqueue. Take this into account when checking the queue's
state, to avoid a panic when kqueue is closed from under a thread.

OK anton@

Reported-by: syzbot+757c60a2aa1125137cce@syzkaller.appspotmail.com

Revision 1.159 / (download) - annotate - [select for diffs], Sun Jan 17 05:56:32 2021 UTC (3 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.158: +117 -30 lines
Diff to previous 1.158 (colored)

kqueue: Revise fd close notification

Deliver file descriptor close notification for __EV_POLL knotes through
struct kevent that kqueue_scan() returns. This replaces the previous way
of returning EBADF from kqueue_scan(), making it easier to determine
what exactly has changed.

When a file descriptor is closed, its __EV_POLL knotes are turned into
one-shot events and queued for delivery. These knotes are "unregistered"
as they are reachable only through the queue of active events. This
reduces interference with the normal workings of kqueue. However, more
care is needed to avoid leaking knotes. In addition, the unregistering
removes a limit on the number of issued knotes. To prevent accumulation
of pending fd close notifications, kqpoll_init() flushes the active
queue at the start of a kqpoll scan.

OK mpi@

Revision 1.158 / (download) - annotate - [select for diffs], Fri Jan 8 12:29:16 2021 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.157: +3 -3 lines
Diff to previous 1.157 (colored)

Lock kernel before raising SPL in klist_lock()

This prevents unwanted spinning with interrupts disabled.

At the moment, this code is only invoked through klist_invalidate()
and the callers should already hold the kernel lock. Also, one could
argue that in MP-unsafe contexts klist_lock() should only assert for
the kernel lock.

Revision 1.157 / (download) - annotate - [select for diffs], Thu Jan 7 11:08:59 2021 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.156: +8 -5 lines
Diff to previous 1.156 (colored)

Adjust comment about klist_invalidate()

Revision 1.156 / (download) - annotate - [select for diffs], Fri Dec 25 12:59:52 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.155: +26 -6 lines
Diff to previous 1.155 (colored)

Refactor klist insertion and removal

Rename klist_{insert,remove}() to klist_{insert,remove}_locked().
These functions assume that the caller has locked the klist. The current
state of locking remains intact because the kernel lock is still used
with all klists.

Add new functions klist_insert() and klist_remove() that lock the klist
internally. This allows some code simplification.

OK mpi@

Revision 1.155 / (download) - annotate - [select for diffs], Wed Dec 23 13:59:09 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.154: +2 -1 lines
Diff to previous 1.154 (colored)

Ensure that filt_dead() takes effect

Invoke dead_filtops' f_event callback in klist_invalidate() to ensure
that filt_dead() modifies every invalidated knote. If a knote has
EV_ONESHOT set in its event flags, kqueue_scan() will not call f_event.

OK mpi@

Revision 1.154 / (download) - annotate - [select for diffs], Wed Dec 23 13:53:44 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.153: +3 -1 lines
Diff to previous 1.153 (colored)

Clear error before each iteration in kqueue_scan()

This fixes a regression where kqueue_scan() may incorrectly return
EWOULDBLOCK after a timeout.

OK mpi@

Revision 1.153 / (download) - annotate - [select for diffs], Sun Dec 20 12:54:05 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.152: +156 -8 lines
Diff to previous 1.152 (colored)

Introduce klistops

This patch extends struct klist with a callback descriptor and
an argument. The main purpose of this is to let the kqueue subsystem
assert when a klist should be locked, and operate the klist lock
in klist_invalidate().

Access to a knote list of a kqueue-monitored object has to be
serialized somehow. Because the object often has a lock for protecting
its state, and because the object often acquires this lock at the latest
in its f_event callback function, it makes sense to use this lock also
for the knote lists. The existing uses of NOTE_SUBMIT already show
a pattern that is likely to become more prevalent.

There could be an embedded lock in klist. However, such a lock would be
redundant in many cases. The code cannot rely on a single lock type
(mutex, rwlock, something else) because the needs of monitored objects
vary. In addition, an embedded lock would introduce new lock order
constraints. Note that the patch does not rule out use of dedicated
klist locks.

The patch introduces a way to associate lock operations with a klist.
The caller can provide a custom implementation, or use a ready-made
interface with a mutex or rwlock.

For compatibility with old code, the new code falls back to using the
kernel lock if no specific klist initialization has been done. The
existing code already relies on implicit initialization of klist.

Sadly, this change increases the size of struct klist. dlg@ thinks this
is not fatal, though.

OK mpi@

Revision 1.152 / (download) - annotate - [select for diffs], Fri Dec 18 16:16:14 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.151: +38 -7 lines
Diff to previous 1.151 (colored)

Add fd close notification for kqueue-based poll() and select()

When the file descriptor of an __EV_POLL-flagged knote is closed,
post EBADF through the kqueue instance to the caller of kqueue_scan().
This lets kqueue-based poll() and select() preserve their current
behaviour of returning EBADF when a polled file descriptor is closed
concurrently.

OK mpi@

Revision 1.151 / (download) - annotate - [select for diffs], Fri Dec 18 16:10:57 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.150: +3 -1 lines
Diff to previous 1.150 (colored)

Make knote_{activate,remove}() internal to kern_event.c.

OK mpi@

Revision 1.150 / (download) - annotate - [select for diffs], Wed Dec 16 15:07:30 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.149: +6 -11 lines
Diff to previous 1.149 (colored)

Remove kqueue_free() and use KQRELE() in kqpoll_exit().

Because kqpoll instances are now linked to the file descriptor table,
the freeing of kqpoll and ordinary kqueues is similar.

Suggested by mpi@

Revision 1.149 / (download) - annotate - [select for diffs], Wed Dec 16 15:06:11 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.148: +14 -10 lines
Diff to previous 1.148 (colored)

Link kqpoll instances to fd_kqlist.

This lets the system remove kqpoll-related event registrations when
a file descriptor is closed.

OK mpi@

Revision 1.148 / (download) - annotate - [select for diffs], Tue Dec 15 04:48:18 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.147: +4 -7 lines
Diff to previous 1.147 (colored)

Use nkev in place of count in kqueue_scan().

OK cheloha@, mpi@, mvs@

Revision 1.147 / (download) - annotate - [select for diffs], Wed Dec 9 18:58:19 2020 UTC (3 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.146: +34 -2 lines
Diff to previous 1.146 (colored)

Add kernel-only per-thread kqueue & helpers to initialize and free it.

This will soon be used by select(2) and poll(2).

ok anton@, visa@

Revision 1.146 / (download) - annotate - [select for diffs], Mon Dec 7 11:15:50 2020 UTC (3 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.145: +48 -48 lines
Diff to previous 1.145 (colored)

Refactor kqueue_scan() so it can be used by other syscalls.

Stop iterating in the function and instead copy the returned events to
userland after every call.

ok visa@

Revision 1.145 / (download) - annotate - [select for diffs], Wed Nov 25 13:49:00 2020 UTC (3 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.144: +31 -10 lines
Diff to previous 1.144 (colored)

Change kqueue_scan() to keep track of collected events in the given context.

It is now possible to call the function multiple times to collect events.
For that, the end marker has to be preserved between calls because otherwise
the scan might collect an event more than once.  If a collected event gets
reactivated during scanning, it will be added at the tail of the queue,
out of reach because of the end marker.

This is required to implement select(2) and poll(2) on top of kqueue_scan().

Done & originally committed by visa@ in r1.143, in snap for more than 2 weeks.

ok visa@, anton@

Revision 1.144 / (download) - annotate - [select for diffs], Mon Oct 26 16:17:00 2020 UTC (3 years, 7 months ago) by cheloha
Branch: MAIN
Changes since 1.143: +5 -5 lines
Diff to previous 1.143 (colored)

kevent(2): ktrace the timeout before validating it

As deraadt@ has pointed out, tracing timevals and timespecs before
validating them makes debugging easier.

Revision 1.143 / (download) - annotate - [select for diffs], Sun Oct 11 07:11:59 2020 UTC (3 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.142: +51 -27 lines
Diff to previous 1.142 (colored)

Refactor kqueue_scan() to use a context: a "kqueue_scan_state struct".

The struct keeps track of the end point of an event queue scan by
persisting the end marker.  This will be needed when kqueue_scan() is
called repeatedly to complete a scan in a piecewise fashion.

Extracted from a previous diff from visa@.

ok visa@, anton@

Revision 1.142 / (download) - annotate - [select for diffs], Wed Aug 12 13:49:24 2020 UTC (3 years, 9 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.141: +12 -8 lines
Diff to previous 1.141 (colored)

Reduce stack usage of kqueue_scan()

Reuse the kev[] array of sys_kevent() in kqueue_scan() to lower
stack usage.

The code has reset kevp, but not nkev, whenever the retry branch is
taken. However, the resetting is unnecessary because retry should be
taken only if no events have been collected. Make this clearer by
adding KASSERTs.

OK mpi@

Revision 1.141 / (download) - annotate - [select for diffs], Sat Jul 4 08:33:43 2020 UTC (3 years, 11 months ago) by visa
Branch: MAIN
Changes since 1.140: +14 -6 lines
Diff to previous 1.140 (colored)

Use klist_invalidate() in knote_processexit()

This leaves knote_remove() for kqueue's internal use. As a result,
knote_remove() is used to drop knotes from the knlist of a single
kqueue instance. klist_invalidate() clears knotes from a klist that
can contain entries from different kqueue instances.

Use FILTEROP_ISFD to control how klist_invalidate() treats knotes,
to preserve the current behaviour of knote_processexit(). All the
existing callers of klist_invalidate() are fd-based. The existing code
rewires and activates knotes to give userspace a clear indication that
the state of the fd has changed. In knote_processexit(), any remaining
knotes in ps_klist are non-fd-based (EVFILT_SIGNAL). Those are dropped
without notifying userspace.

OK mpi@

Revision 1.140 / (download) - annotate - [select for diffs], Mon Jun 22 13:14:32 2020 UTC (3 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.139: +2 -1 lines
Diff to previous 1.139 (colored)

Extend kqueue interface with EVFILT_EXCEPT filter.

This filter, already implemented in macOS and Dragonfly BSD, returns
exceptional conditions like the reception of out-of-band data.

The functionnality is similar to poll(2)'s POLLPRI & POLLRDBAND and
it can be used by the kqfilter-based poll & select implementation.

ok millert@ on a previous version, ok visa@

Revision 1.139 / (download) - annotate - [select for diffs], Mon Jun 15 15:42:11 2020 UTC (3 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.138: +4 -2 lines
Diff to previous 1.138 (colored)

Implement a simple kqfilter for deadfs matching its poll handler.

ok visa@, millert@

Revision 1.138 / (download) - annotate - [select for diffs], Mon Jun 15 13:18:33 2020 UTC (3 years, 11 months ago) by visa
Branch: MAIN
Changes since 1.137: +8 -2 lines
Diff to previous 1.137 (colored)

Raise SPL when modifying ps_klist to prevent a race with interrupts.
The list can be accessed from interrupt context if a signal is sent
from an interrupt handler.

OK anton@ cheloha@ mpi@

Revision 1.137 / (download) - annotate - [select for diffs], Sun Jun 14 07:22:55 2020 UTC (3 years, 11 months ago) by visa
Branch: MAIN
Changes since 1.136: +1 -3 lines
Diff to previous 1.136 (colored)

Remove misleading XXX about locking of ps_klist. All of the kqueue
subsystem and ps_klist handling still run under the kernel lock.

Revision 1.136 / (download) - annotate - [select for diffs], Fri Jun 12 09:34:17 2020 UTC (3 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.135: +4 -4 lines
Diff to previous 1.135 (colored)

Revert addition of double underbars for filter-specific flag.

Port breakages reported by naddy@

Revision 1.135 / (download) - annotate - [select for diffs], Thu Jun 11 09:18:43 2020 UTC (4 years ago) by mpi
Branch: MAIN
Changes since 1.134: +4 -4 lines
Diff to previous 1.134 (colored)

Rename poll-compatibility flag to better reflect what it is.

While here prefix kernel-only EV flags with two underbars.

Suggested by kettenis@, ok visa@

Revision 1.134 / (download) - annotate - [select for diffs], Sat May 30 14:10:17 2020 UTC (4 years ago) by mpi
Branch: MAIN
Changes since 1.133: +38 -12 lines
Diff to previous 1.133 (colored)

Introduce kqueue_terminate() & kqueue_free(), no functional changes.

These functions will be used to managed per-thread kqueues that are not
associated to a file descriptor.

ok visa@

Revision 1.133 / (download) - annotate - [select for diffs], Mon May 25 15:54:10 2020 UTC (4 years ago) by visa
Branch: MAIN
Changes since 1.132: +26 -72 lines
Diff to previous 1.132 (colored)

Revert "Add kqueue_scan_state struct"

sthen@ has reported that the patch might be causing hangs with X.

Revision 1.132 / (download) - annotate - [select for diffs], Sun May 17 10:53:14 2020 UTC (4 years ago) by visa
Branch: MAIN
Changes since 1.131: +72 -26 lines
Diff to previous 1.131 (colored)

Add kqueue_scan_state struct

The struct keeps track of the end point of an event queue scan by
persisting the end marker. This will be needed when kqueue_scan() is
called repeatedly to complete a scan in a piecewise fashion. The end
marker has to be preserved between calls because otherwise the scan
might collect an event more than once. If a collected event gets
reactivated during scanning, it will be added at the tail of the queue,
out of reach because of the end marker.

OK mpi@

Revision 1.131 / (download) - annotate - [select for diffs], Tue Apr 7 13:27:51 2020 UTC (4 years, 2 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.130: +39 -20 lines
Diff to previous 1.130 (colored)

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@

Revision 1.130 / (download) - annotate - [select for diffs], Tue Apr 7 12:52:27 2020 UTC (4 years, 2 months ago) by visa
Branch: MAIN
Changes since 1.129: +8 -6 lines
Diff to previous 1.129 (colored)

Defer selwakeup() from kqueue_wakeup() to kqueue_task() to prevent
deep recursion. This also helps making kqueue_wakeup() free of the
kernel lock because the current implementation of selwakeup()
requires the lock.

OK mpi@

Revision 1.129 / (download) - annotate - [select for diffs], Thu Apr 2 07:00:25 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.128: +33 -21 lines
Diff to previous 1.128 (colored)

Introduce kqueue_sleep() a wrapper around the tsleep(9) dance.

While here check for the validity of the timeout at the begining of the
syscall.

ok kettenis@, cheloha@

Revision 1.128 / (download) - annotate - [select for diffs], Fri Mar 20 04:14:50 2020 UTC (4 years, 2 months ago) by cheloha
Branch: MAIN
Changes since 1.127: +9 -5 lines
Diff to previous 1.127 (colored)

kevent(2): tsleep(9) -> tsleep_nsec(9)

With input from visa@.

ok visa@

Revision 1.127 / (download) - annotate - [select for diffs], Tue Feb 25 13:21:17 2020 UTC (4 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.126: +5 -6 lines
Diff to previous 1.126 (colored)

Keep function definitions in a single place.

No functional change.

Revision 1.126 / (download) - annotate - [select for diffs], Thu Feb 20 16:56:52 2020 UTC (4 years, 3 months ago) by visa
Branch: MAIN
Changes since 1.125: +13 -13 lines
Diff to previous 1.125 (colored)

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@

Revision 1.125 / (download) - annotate - [select for diffs], Mon Feb 17 04:07:01 2020 UTC (4 years, 3 months ago) by visa
Branch: MAIN
Changes since 1.124: +33 -8 lines
Diff to previous 1.124 (colored)

Raise SPL when updating kn_status. Otherwise the field can become
inconsistent if knote_acquire() or knote_release() is preempted by
an interrupt that modifies the same knote.

OK mpi@

Reported-by: syzbot+8c174edc00da365121d7@syzkaller.appspotmail.com

Revision 1.124 / (download) - annotate - [select for diffs], Fri Feb 14 16:50:25 2020 UTC (4 years, 3 months ago) by visa
Branch: MAIN
Changes since 1.123: +22 -3 lines
Diff to previous 1.123 (colored)

Defer chained activation of kqueues. This makes easier to introduce new
locks. The deferring also prevents kernel stack exhaustion with deep
kqueue hierarchies.

OK anton@, mpi@

Revision 1.123 / (download) - annotate - [select for diffs], Sun Feb 9 14:09:08 2020 UTC (4 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.122: +2 -2 lines
Diff to previous 1.122 (colored)

Zero struct knote on allocation. This makes the code less prone
to errors.

OK deraadt@, cheloha@, anton@

Revision 1.122 / (download) - annotate - [select for diffs], Wed Feb 5 17:03:13 2020 UTC (4 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.121: +6 -3 lines
Diff to previous 1.121 (colored)

Move kernel locking inside knote_fdclose() from finishdup() and
fdrelease(). This makes the upper layer of file descriptor closing
free of KERNEL_LOCK() when the process does not use kqueue.

The kernel locking around fdremove() and knote_fdclose() is no longer
needed because kqueue_register() checks if there has been a race with
file descriptor close. Moreover, the locking became ineffective against
these races when filterops callbacks were allowed to sleep.

OK anton@, mpi@

Revision 1.121 / (download) - annotate - [select for diffs], Sat Jan 18 08:59:48 2020 UTC (4 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.120: +35 -4 lines
Diff to previous 1.120 (colored)

Make klist_invalidate() more careful and general. Acquire knotes before
changing them, to synchronize with kqueue_register() and kqueue_scan().
Detach the knotes from the original knote list, change the filterops
to one that always indicates EOF condition, and activate in one-shot
mode.

The detaching allows the original knote list head to be deleted after
klist_invalidate() returns. The knotes are activated to make the EOF
condition visible to the event subscribers as soon as possible. As the
knotes are detached from the list, klist_invalidate() does not have to
wait for userspace to process them.

The use of the special filterops minimizes the need to handle klist
invalidation in actual implementations of filterops.

Tested by Greg Steuck
OK mpi@

Revision 1.120 / (download) - annotate - [select for diffs], Mon Jan 13 13:57:19 2020 UTC (4 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.119: +9 -5 lines
Diff to previous 1.119 (colored)

Allocate kqueue instance outside fdplock to avoid sleeping with
the lock held. This also shortens the critical section.

Prompted by and OK anton@

Revision 1.119 / (download) - annotate - [select for diffs], Fri Jan 10 15:49:37 2020 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.118: +12 -11 lines
Diff to previous 1.118 (colored)

Use atomic operations with kq_refs, to nudge the code toward MP-safety.

While here, adjust the IPL of kqueue-related pools to IPL_MPFLOOR.

OK bluhm@, anton@, mpi@

Revision 1.118 / (download) - annotate - [select for diffs], Wed Jan 8 16:45:28 2020 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.117: +8 -2 lines
Diff to previous 1.117 (colored)

Skip fdplock when freeing a file descriptor table. The lock is not
necessary because other threads cannot access the data structure.
This fixes the following lock order issue:

witness: lock order reversal:
 1st 0xfffffd81d821d248 fdlock (&newfdp->fd_fd.fd_lock)
 2nd 0xffff800000fe45b8 primlk (&prime_fpriv->lock)
lock order "&prime_fpriv->lock"(rwlock) -> "&newfdp->fd_fd.fd_lock"(rwlock) first seen at:
#0  witness_checkorder+0x449
#1  rw_enter_write+0x43
#2  dma_buf_fd+0x8c
#3  drm_gem_prime_handle_to_fd+0xed
#4  drmioctl+0xdc
#5  VOP_IOCTL+0x55
#6  vn_ioctl+0x64
#7  sys_ioctl+0x2f6
#8  syscall+0x389
#9  Xsyscall+0x128
lock order "&newfdp->fd_fd.fd_lock"(rwlock) -> "&prime_fpriv->lock"(rwlock) first seen at:
#0  witness_checkorder+0x449
#1  rw_enter_write+0x43
#2  drm_gem_object_release_handle+0x5e
#3  idr_for_each+0xee
#4  drm_gem_release+0x1f
#5  drmclose+0x144
#6  spec_close+0x213
#7  VOP_CLOSE+0x49
#8  vn_closefile+0x9b
#9  fdrop+0x8b
#10 closef+0xaf
#11 fdfree+0xd4
#12 exit1+0x1cf
#13 sys_exit+0x16
#14 syscall+0x389
#15 Xsyscall+0x128


OK mpi@

Revision 1.117 / (download) - annotate - [select for diffs], Mon Jan 6 10:28:32 2020 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.116: +8 -8 lines
Diff to previous 1.116 (colored)

Use type M_KEVENT instead of M_TEMP when allocating kqueue-related
data buffers.

OK bluhm@, mpi@, anton@

Revision 1.116 / (download) - annotate - [select for diffs], Mon Jan 6 10:25:10 2020 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.115: +15 -4 lines
Diff to previous 1.115 (colored)

Make kqlist part of filedesc and serialize access to it using fdplock.
This choice of locking is guided by knote_fdclose().

OK mpi@, anton@

Revision 1.115 / (download) - annotate - [select for diffs], Sun Jan 5 13:46:02 2020 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.114: +2 -2 lines
Diff to previous 1.114 (colored)

Constify instances of struct fileops.

OK anton@, mpi@, bluhm@

Revision 1.114 / (download) - annotate - [select for diffs], Fri Jan 3 05:37:00 2020 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.113: +20 -1 lines
Diff to previous 1.113 (colored)

Fix a file descriptor close race in kqueue_register()

After inserting a knote, check that the associated file descriptor
still references the same file. Remove the knote if the descriptor
has changed because otherwise the kqueue becomes inconsistent with
the file descriptor table.

There is an analogous race in fcntl(F_SETLK). It is already handled,
but the code can be simplified by using the same check as in
kqueue_register().

Fix inspired by DragonFly BSD

OK mpi@, anton@

Revision 1.113 / (download) - annotate - [select for diffs], Tue Dec 31 14:09:56 2019 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.112: +95 -42 lines
Diff to previous 1.112 (colored)

Fix some races in kqueue_register().

Mark knote with KN_PROCESSING before calling .f_event() in
kqueue_register(). This prevents other threads from freeing the knote
too early.

Rearrange memory allocations so that there is no sleeping point between
the knote lookup and insert. Also take into account that multiple
threads can attempt expanding the kqueue at the same time.

Input and OK mpi@
OK anton@

Revision 1.112 / (download) - annotate - [select for diffs], Tue Dec 31 13:48:32 2019 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.111: +36 -18 lines
Diff to previous 1.111 (colored)

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@

Revision 1.111 / (download) - annotate - [select for diffs], Sun Dec 29 07:14:06 2019 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.110: +5 -1 lines
Diff to previous 1.110 (colored)

Wake up knote waiters in knote_drop(). This lets the blocked
knote_acquire() calls resume immediately instead of waiting
for the timeout expiry.

OK anton@, tedu@

Revision 1.110 / (download) - annotate - [select for diffs], Wed Dec 25 15:04:44 2019 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.109: +4 -11 lines
Diff to previous 1.109 (colored)

Replace macros knote_alloc() and knote_free() with direct use of
pool_get() and pool_put(). This makes it clearer that the knote
allocation cannot fail and that the error check is unnecessary.

OK anton@, kettenis@, mpi@

Revision 1.109 / (download) - annotate - [select for diffs], Thu Dec 12 16:31:06 2019 UTC (4 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.108: +143 -17 lines
Diff to previous 1.108 (colored)

Allow sleeping inside kqueue event filters.

In kqueue_scan(), threads have to get an exclusive access to a knote
before processing by calling knote_acquire(). This prevents the knote
from being destroyed while it is still in use. knote_acquire() also
blocks other threads from processing the knote. Once knote processing
has finished, the thread has to call knote_release().

The kqueue subsystem is still serialized by the kernel lock. If an event
filter sleeps, the kernel lock is released and another thread might
enter kqueue_scan(). kqueue_scan() uses start and end markers to keep
track of the scan's progress and it has to be aware of other threads'
markers.

This patch is a revised version of mpi@'s work derived
from DragonFly BSD. kqueue_check() has been adapted from NetBSD.

Tested by anton@, sashan@
OK mpi@, anton@, sashan@

Revision 1.108 / (download) - annotate - [select for diffs], Wed Dec 11 07:30:09 2019 UTC (4 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.107: +3 -2 lines
Diff to previous 1.107 (colored)

Replace p_xstat with ps_xexit and ps_xsig
Convert those to a consolidated status when needed in wait4(), kevent(),
	and sysctl()
Pass exit code and signal separately to exit1()
(This also serves as prep for adding waitid(2))

ok mpi@

Revision 1.107 / (download) - annotate - [select for diffs], Sat Dec 7 13:11:04 2019 UTC (4 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.106: +7 -11 lines
Diff to previous 1.106 (colored)

Combine macro KNOTE_ACTIVATE() with function knote_activate()
to make the code clearer.

OK claudio@ mpi@

Revision 1.106 / (download) - annotate - [select for diffs], Wed Jul 3 14:32:02 2019 UTC (4 years, 11 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.105: +3 -1 lines
Diff to previous 1.105 (colored)

Lock the kernel when removing file descriptors from the descriptor
table. This should prevent a race with kevent when unlocked code
closes file descriptors that are fully set up.

OK mpi@

Revision 1.105 / (download) - annotate - [select for diffs], Mon Jul 1 16:52:02 2019 UTC (4 years, 11 months ago) by cheloha
Branch: MAIN
Changes since 1.104: +27 -46 lines
Diff to previous 1.104 (colored)

kevent(2): remove 24hr timeout limit

As with nanosleep(2), poll(2), and select(2), here we can chip away at
the timespec until it's empty.  This lets us support the full range of
the timespec regardless of the kernel's HZ.

Update the manpage accordingly.

ok visa@

Revision 1.104 / (download) - annotate - [select for diffs], Sat May 4 14:52:45 2019 UTC (5 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.103: +1 -9 lines
Diff to previous 1.103 (colored)

Removed all diagnostic, calling printf() here might create a recursion.

Should be revisited once logwakeup() is fixed.

Revision 1.103 / (download) - annotate - [select for diffs], Sat May 4 14:42:44 2019 UTC (5 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.102: +9 -3 lines
Diff to previous 1.102 (colored)

Relax the check in knote_{de,en}queue: don't panic w/o KERNEL_LOCK().

Use splassert_fail() instead, please set kern.splassert to 2 and report
the corresponding stack trace if you see a warning.

ok dlg@

Revision 1.102 / (download) - annotate - [select for diffs], Wed May 1 06:22:39 2019 UTC (5 years, 1 month ago) by dlg
Branch: MAIN
Changes since 1.101: +3 -1 lines
Diff to previous 1.101 (colored)

sprinkle some KERNEL_ASSERT_LOCKED()

operations that tweak the kq_head and kq_count need to be serialised
against the kevent syscall which also fumbles with the list and
count too.

these asserts would have made it extremely obvious where the tun(4)
bug was. for half the time of the bug report about it we werent
even sure it was tun(4)

discussed with mpi@ jmatthew@

Revision 1.101 / (download) - annotate - [select for diffs], Tue Nov 27 15:52:50 2018 UTC (5 years, 6 months ago) by cheloha
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.100: +6 -2 lines
Diff to previous 1.100 (colored)

EVFILT_TIMER: Remove extra tick from tvtohz(9) on timeout reload.

tvtohz(9) adds an extra tick to account for the present tick, but this
tick needs to be removed when the timeout is reloaded thereafter.  We
already do this for periodic setitimer(2) timeouts.

Prompted by Paul Herman's writeup on clock aliasing for DragonflyBSD:
https://frenchfries.net/paul/dfly/nanosleep.html

Also fixed in FreeBSD r238424.

Style tweaks from visa.

ok visa@, guenther@

Revision 1.100 / (download) - annotate - [select for diffs], Sat Nov 17 18:55:50 2018 UTC (5 years, 6 months ago) by millert
Branch: MAIN
Changes since 1.99: +2 -1 lines
Diff to previous 1.99 (colored)

Avoid leaking kernel memory in struct kevent padding.
From NetBSD (maxv).  OK deraadt@ visa@

Revision 1.99 / (download) - annotate - [select for diffs], Tue Sep 4 02:38:25 2018 UTC (5 years, 9 months ago) by cheloha
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.98: +19 -23 lines
Diff to previous 1.98 (colored)

kevent: Don't poll for nonzero timeouts < 1us.

Instead of truncating nanosecond timeouts to zero here and polling, we
should round up to a delay of at least a tick, just like all the other
timespec syscalls.

Fixed in NetBSD kern_event.c v1.62 and FreeBSD r247804.

ok millert@ visa@

Revision 1.98 / (download) - annotate - [select for diffs], Mon Aug 20 16:00:22 2018 UTC (5 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.97: +5 -8 lines
Diff to previous 1.97 (colored)

Reorder checks in the read/write(2) family of syscalls to prepare making
file operations mp-safe.

This change makes it clear that `f_offset' is only accessed in vn_read()
and vn_write(), which will help taking it out of the KERNEL_LOCK().

This refactoring uncovered a race in vn_read() which is now documented
and will be addressed in a later diff.

ok visa@

Revision 1.97 / (download) - annotate - [select for diffs], Wed Aug 15 13:19:06 2018 UTC (5 years, 9 months ago) by visa
Branch: MAIN
Changes since 1.96: +5 -1 lines
Diff to previous 1.96 (colored)

Grab the KERNEL_LOCK() in MP-unsafe fo_close routines. This prevents
a scenario where MP-unsafe code gets run without the kernel lock
as a consequence of an unlocked system call.

OK mpi@, kettenis@

Revision 1.96 / (download) - annotate - [select for diffs], Thu Aug 9 15:02:45 2018 UTC (5 years, 10 months ago) by visa
Branch: MAIN
Changes since 1.95: +2 -4 lines
Diff to previous 1.95 (colored)

Remove redundant "kq == kn->kn_kq" checks. The lists kq_knhash and
kq_knlist are dedicated to a single kqueue instance, which makes
the filtering by kn_kq unnecessary.

OK kettenis@, mpi@

Revision 1.95 / (download) - annotate - [select for diffs], Tue Aug 7 12:38:15 2018 UTC (5 years, 10 months ago) by visa
Branch: MAIN
Changes since 1.94: +5 -34 lines
Diff to previous 1.94 (colored)

Fix dangling knote references.

kqueue_close() does not take into account that the kqueue instance may
have queued knotes. This can cause a use-after-free if new knotes are
enqueued on the kqueue as a result of file closing.

Correct the error by dequeueing each knote before freeing it.
Since r1.93 of kern_event.c, each kqueue instance has its knotes
in nonshared lists kq_knhash and kq_knlist, so kqueue_close() does
not have to skip other kqueues' knotes any longer. The code can be
simplified by using knote_remove() for clearing the knote lists.
The function uses knote_drop() which takes care of knote dequeueing.

Found and initial analysis by anton@
OK anton@, mpi@

Revision 1.94 / (download) - annotate - [select for diffs], Mon Jun 18 09:15:05 2018 UTC (5 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.93: +8 -6 lines
Diff to previous 1.93 (colored)

Put file descriptors on shared data structures when they are completely
setup, take 3.

LARVAL fd still exist, but they are no longer marked with a flag and no
longer reachable via `fd_ofiles[]' or the global linked list.  This allows
us to simplifies a lot code grabbing new references to fds.

All of this is now possible because dup2(2) refuses to clone LARVAL fds.

Note that the `fdplock' could now be release in all open(2)-like syscalls,
just like it is done in accept(2).

With inputs from Mathieu Masson, visa@, guenther@ and art@

Previous version ok bluhm@, ok visa@, sthen@

Revision 1.93 / (download) - annotate - [select for diffs], Sun Jun 17 08:22:02 2018 UTC (5 years, 11 months ago) by anton
Branch: MAIN
Changes since 1.92: +56 -46 lines
Diff to previous 1.92 (colored)

Move kqueue related fields from struct filedesc to struct kqueue. Solves a panic
in knote_processexit() that can occur when the filedesc belonging to the process
already has been freed.

Similiar work has been done in:
- FreeBSD (commit bc1805c6e871c178d0b6516c3baa774ffd77224a)
- DragonFlyBSD (commit ccafe911a3aa55fd5262850ecfc5765cd31a56a2)

Thanks to tb@ for testing.

ok kettenis@ mpi@ visa@

Revision 1.92 / (download) - annotate - [select for diffs], Fri Jun 15 01:09:49 2018 UTC (5 years, 11 months ago) by cheloha
Branch: MAIN
Changes since 1.91: +2 -2 lines
Diff to previous 1.91 (colored)

kevent: don't reject timeouts greater than 100 million seconds

We already clamp timeouts to 24 hours anyway, so there's no reason
to set EINVAL because the caller's timeout passed an arbitrary
threshold.

In particular, this keeps www/chromium v67 from busy-waiting and
consuming a ton of cpu as described in the bug report here:

https://bugs.chromium.org/p/chromium/issues/detail?id=850450

Prompted by deraadt@, bug report found by pirofti@,
testing by brynet@ and deraadt@.

ok kettenis@

Revision 1.91 / (download) - annotate - [select for diffs], Tue Jun 5 09:29:05 2018 UTC (6 years ago) by mpi
Branch: MAIN
Changes since 1.90: +6 -8 lines
Diff to previous 1.90 (colored)

Revert introduction of fdinsert(), a sanitify check triggers when
closing a LARVAL file.

Found the hardway by sthen@.

Revision 1.90 / (download) - annotate - [select for diffs], Sat Jun 2 10:27:43 2018 UTC (6 years ago) by mpi
Branch: MAIN
Changes since 1.89: +8 -6 lines
Diff to previous 1.89 (colored)

Put file descriptors on shared data structures when they are completely
setup.

LARVAL fd still exist, but they are no longer marked with a flag and no
longer reachable via `fd_ofiles[]'.  This allows us to simplifies a lot
code grabbing new references to fds.

All of this is now possible because dup2(2) refuses to clone LARVAL fds.

Note that the `fdplock' could now be release in all open(2)-like syscalls,
just like it is done in accept(2).

With inputs from Mathieu -, visa@, guenther@ and art@

ok visa@, bluhm@

Revision 1.89 / (download) - annotate - [select for diffs], Tue May 22 19:15:22 2018 UTC (6 years ago) by cheloha
Branch: MAIN
Changes since 1.88: +10 -7 lines
Diff to previous 1.88 (colored)

kevent: correctly check that timeout's nanoseconds are on [0, 1000000000)

Validate the input with timespecfix before truncating to a timeval.
timespecfix does not round, so we need to to it by hand after validation.

FreeBSD and NetBSD check the input with this range, we ought to as well.

Also add a regression test for this case.

ok tb@

Revision 1.88 / (download) - annotate - [select for diffs], Fri Apr 27 10:13:37 2018 UTC (6 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.87: +1 -3 lines
Diff to previous 1.87 (colored)

Move FREF() inside fd_getfile().

ok visa@

Revision 1.87 / (download) - annotate - [select for diffs], Tue Apr 10 09:17:45 2018 UTC (6 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.86: +8 -8 lines
Diff to previous 1.86 (colored)

Convert 'struct fileops' definitions to C99.

ok millert@, deraadt@, florian@

Revision 1.86 / (download) - annotate - [select for diffs], Sun Apr 8 16:45:12 2018 UTC (6 years, 2 months ago) by mikeb
Branch: MAIN
Changes since 1.85: +3 -1 lines
Diff to previous 1.85 (colored)

Test for preexisting conditions when re-enabling events

When an event that was disabled by EV_DISABLE or EV_DISPATCH is registered
again, an associated filter must be ran to mark it active if a preexisting
condition is present.

The issue was reported and fix tested by Lukas Larsson <lukas at erlang.org>,
thanks!

ok mpi

Revision 1.85 / (download) - annotate - [select for diffs], Tue Apr 3 09:10:02 2018 UTC (6 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.84: +7 -4 lines
Diff to previous 1.84 (colored)

Move FREF()s just after fd_getfile() in sys_kevent(), sys_lseek() and
getvnode().

ok millert@

Revision 1.84 / (download) - annotate - [select for diffs], Sat Jan 13 12:58:40 2018 UTC (6 years, 4 months ago) by robert
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.83: +2 -1 lines
Diff to previous 1.83 (colored)

introduce a filter called EVFILT_DEVICE that can be used to notify
listeners of device state changes.
currently only supports NOTE_CHANGE that will be used by drm(4)

ok kettenis@

Revision 1.83 / (download) - annotate - [select for diffs], Mon Dec 18 10:10:53 2017 UTC (6 years, 5 months ago) by mpi
Branch: MAIN
Changes since 1.82: +1 -58 lines
Diff to previous 1.82 (colored)

Revert support for multiple threads to enter kqueue_scan() in parallel.

It is not clear if this change is responsible for the lockups experienced
by dhill@ and jcs@ but since we're no longer grabbing the socket lock in
kqueue(2) filters there's no need for this change.

Revision 1.82 / (download) - annotate - [select for diffs], Sat Nov 4 14:13:53 2017 UTC (6 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.81: +59 -2 lines
Diff to previous 1.81 (colored)

Make it possible for multiple threads to enter kqueue_scan() in parallel.

This is a requirement to use a sleeping lock inside kqueue filters.
It is now possible, but not recommended, to sleep inside ``f_event''.

Threads iterating over the list of pending events are now recognizing
and skipping other threads' markers.  knote_acquire() and knote_release()
must be used to "own" a knote to make sure no other thread is sleeping
with a reference on it.

Acquire and marker logic taken from DragonFly but the KERNEL_LOCK()
is still serializing the execution of the kqueue code.

This also enable the NET_LOCK() in socket filters.

Tested by abieber@ & juanfra@, run by naddy@ in a bulk, ok visa@, bluhm@

Revision 1.81 / (download) - annotate - [select for diffs], Wed Oct 11 08:06:56 2017 UTC (6 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.80: +7 -6 lines
Diff to previous 1.80 (colored)

Move `kq_count' increase/decrease close to the corresponding TAILQ_*
insert/remove operation.

No functionnal change for the moment.  However this helps to make this
code mp-safe.

Note that markers are still not, and wont be, counted.

ok visa@, jsing@, bluhm@

Revision 1.80 / (download) - annotate - [select for diffs], Wed Oct 11 08:01:10 2017 UTC (6 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.79: +12 -10 lines
Diff to previous 1.79 (colored)

Move kq_kev from struct kqueue to the stack.

It turns this set of events per-thread without having to lock anything.

From Dragonfly 10f6680a4f6684751aaae0965abfe140f19e9231

ok kettenis@, visa@, bluhm@

Revision 1.79 / (download) - annotate - [select for diffs], Wed May 31 14:52:05 2017 UTC (7 years ago) by mikeb
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.78: +9 -5 lines
Diff to previous 1.78 (colored)

Add support for EV_RECEIPT and EV_DISPATCH flags

From FreeBSD via Jan Schreiber <jes at posteo ! de>, thanks!
OK tedu, bluhm

Revision 1.78 / (download) - annotate - [select for diffs], Sat Feb 11 19:51:06 2017 UTC (7 years, 3 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.77: +2 -2 lines
Diff to previous 1.77 (colored)

Add a flags argument to falloc() that lets it optionally set the
close-on-exec flag on the newly allocated fd.  Make falloc()'s
return arguments non-optional: assert that they're not NULL.

ok mpi@ millert@

Revision 1.77 / (download) - annotate - [select for diffs], Sat Sep 24 18:39:17 2016 UTC (7 years, 8 months ago) by tedu
Branch: MAIN
Changes since 1.76: +1 -2 lines
Diff to previous 1.76 (colored)

move knhash size to event.h, use it for hashfree. from Mathieu -
ok guenther

Revision 1.76 / (download) - annotate - [select for diffs], Thu Sep 15 02:00:16 2016 UTC (7 years, 8 months ago) by dlg
Branch: MAIN
Changes since 1.75: +3 -5 lines
Diff to previous 1.75 (colored)

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);

Revision 1.75 / (download) - annotate - [select for diffs], Thu Aug 25 00:00:02 2016 UTC (7 years, 9 months ago) by dlg
Branch: MAIN
Changes since 1.74: +3 -1 lines
Diff to previous 1.74 (colored)

pool_setipl

ok kettenis@

Revision 1.74 / (download) - annotate - [select for diffs], Thu Jul 14 05:55:08 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.73: +4 -1 lines
Diff to previous 1.73 (colored)

Prevent silly states via knotes on pids > 2^32 and on nonexistent signals.

ok tedu@

Revision 1.61.6.2 / (download) - annotate - [select for diffs], Thu Jul 14 02:40:40 2016 UTC (7 years, 10 months ago) by tedu
Branch: OPENBSD_5_8
Changes since 1.61.6.1: +3 -1 lines
Diff to previous 1.61.6.1 (colored) to branchpoint 1.61 (colored) next main 1.62 (colored)

backport 1.73
kevent validates that ident is a valid fd by getting the file. one sad
quirk: uint64 to int32 truncation can lead to false positives, and then
later in the array sizing code, very big mallocs panic the kernel.
add a check that the ident isn't larger than INT_MAX in the fd case.
reported by Tim Newsham

Revision 1.71.2.1 / (download) - annotate - [select for diffs], Thu Jul 14 02:40:04 2016 UTC (7 years, 10 months ago) by tedu
Branch: OPENBSD_5_9
Changes since 1.71: +3 -1 lines
Diff to previous 1.71 (colored) next main 1.72 (colored)

backport 1.73
kevent validates that ident is a valid fd by getting the file. one sad
quirk: uint64 to int32 truncation can lead to false positives, and then
later in the array sizing code, very big mallocs panic the kernel.
add a check that the ident isn't larger than INT_MAX in the fd case.
reported by Tim Newsham

Revision 1.73 / (download) - annotate - [select for diffs], Thu Jul 14 02:35:17 2016 UTC (7 years, 10 months ago) by tedu
Branch: MAIN
Changes since 1.72: +3 -1 lines
Diff to previous 1.72 (colored)

kevent validates that ident is a valid fd by getting the file. one sad
quirk: uint64 to int32 truncation can lead to false positives, and then
later in the array sizing code, very big mallocs panic the kernel.
add a check that the ident isn't larger than INT_MAX in the fd case.
reported by Tim Newsham

Revision 1.72 / (download) - annotate - [select for diffs], Fri May 13 19:05:07 2016 UTC (8 years, 1 month ago) by tedu
Branch: MAIN
Changes since 1.71: +6 -10 lines
Diff to previous 1.71 (colored)

contrary to documentation and other implementations, kevent was preventing
a process from watching other users' procs. but there are no secrets here.
remove that check.
at the same time, note that as far as pledge is concerned, while most of
kevent is a "stdio" type operation, process monitoring belongs to the
"proc" family, so add an additional check here.
ok deraadt millert

Revision 1.71 / (download) - annotate - [select for diffs], Wed Jan 6 17:58:46 2016 UTC (8 years, 5 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE
Branch point for: OPENBSD_5_9
Changes since 1.70: +18 -16 lines
Diff to previous 1.70 (colored)

tidy up whitespace, etc.

Revision 1.70 / (download) - annotate - [select for diffs], Sun Dec 20 17:56:18 2015 UTC (8 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.69: +3 -3 lines
Diff to previous 1.69 (colored)

size for free, sent and reminded by Mathieu. also delete null check.

Revision 1.69 / (download) - annotate - [select for diffs], Thu Dec 17 17:00:48 2015 UTC (8 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.68: +5 -5 lines
Diff to previous 1.68 (colored)

arrays decay to pointers without needing &

Revision 1.68 / (download) - annotate - [select for diffs], Thu Dec 17 16:57:20 2015 UTC (8 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.67: +15 -2 lines
Diff to previous 1.67 (colored)

add ktrace to kevent. ok guenther

Revision 1.67 / (download) - annotate - [select for diffs], Sat Dec 5 10:11:53 2015 UTC (8 years, 6 months ago) by tedu
Branch: MAIN
Changes since 1.66: +1 -8 lines
Diff to previous 1.66 (colored)

remove stale lint annotations

Revision 1.66 / (download) - annotate - [select for diffs], Thu Oct 29 13:20:44 2015 UTC (8 years, 7 months ago) by jsing
Branch: MAIN
Changes since 1.65: +4 -5 lines
Diff to previous 1.65 (colored)

In knote(), use SLIST_FOREACH_SAFE when walking the klist since a call to
an f_event() handler may remove an entry.

Currently knote_processexit() calls knote() with NOTE_EXIT, knote() walks
the list and calls f_event(), one of these happens to be filt_proc(), which
happily SLIST_REMOVEs the NOTE_EXIT note from the same list that knote() is
currently walking, then we get back to knote() and go boom...

Flushed out by bluhm@'s invalidation change to sys/queue.h and found the
hard way by naddy@.

ok doug@ nicm@ tedu@

Revision 1.58.4.1 / (download) - annotate - [select for diffs], Wed Oct 14 18:12:52 2015 UTC (8 years, 7 months ago) by sthen
Branch: OPENBSD_5_6
Changes since 1.58: +16 -16 lines
Diff to previous 1.58 (colored) next main 1.59 (colored)

MFC: Always set the timeout at least one tick in the future for EVFILT_TIMER
to avoid looping in softclock()

Revision 1.61.2.1 / (download) - annotate - [select for diffs], Wed Oct 14 18:12:25 2015 UTC (8 years, 7 months ago) by sthen
Branch: OPENBSD_5_7
Changes since 1.61: +16 -16 lines
Diff to previous 1.61 (colored) next main 1.62 (colored)

MFC: Always set the timeout at least one tick in the future for EVFILT_TIMER
to avoid looping in softclock()

Revision 1.61.6.1 / (download) - annotate - [select for diffs], Wed Oct 14 18:10:27 2015 UTC (8 years, 7 months ago) by sthen
Branch: OPENBSD_5_8
Changes since 1.61: +16 -16 lines
Diff to previous 1.61 (colored)

MFC: Always set the timeout at least one tick in the future for EVFILT_TIMER
to avoid looping in softclock()

Revision 1.65 / (download) - annotate - [select for diffs], Sun Oct 11 01:53:39 2015 UTC (8 years, 8 months ago) by guenther
Branch: MAIN
Changes since 1.64: +16 -16 lines
Diff to previous 1.64 (colored)

Always set the timeout at least one tick in the future for EVFILT_TIMER
to avoid looping in softclock()

based on diff by sthen@
ok sthen@

Revision 1.64 / (download) - annotate - [select for diffs], Sat Oct 10 16:35:08 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.63: +0 -0 lines
Diff to previous 1.63 (colored)

shuffle #ifdef TIOCSTI block to avoid a future /*FALLTHROUGH*/ mistake.

Revision 1.63 / (download) - annotate - [select for diffs], Fri Oct 9 11:47:30 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.62: +15 -15 lines
Diff to previous 1.62 (colored)

oops, snuck into a syscalls sync; spotted by sthen

Revision 1.62 / (download) - annotate - [select for diffs], Fri Oct 9 01:11:12 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.61: +16 -16 lines
Diff to previous 1.61 (colored)

sync

Revision 1.61 / (download) - annotate - [select for diffs], Fri Dec 19 05:59:21 2014 UTC (9 years, 5 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_7_BASE
Branch point for: OPENBSD_5_8, OPENBSD_5_7
Changes since 1.60: +5 -5 lines
Diff to previous 1.60 (colored)

start retiring the nointr allocator. specify PR_WAITOK as a flag as a
marker for which pools are not interrupt safe. ok dlg

Revision 1.60 / (download) - annotate - [select for diffs], Tue Dec 9 07:05:06 2014 UTC (9 years, 6 months ago) by doug
Branch: MAIN
Changes since 1.59: +3 -2 lines
Diff to previous 1.59 (colored)

More malloc() -> mallocarray() in the kernel.

ok deraadt@ tedu@

Revision 1.59 / (download) - annotate - [select for diffs], Mon Nov 3 03:08:00 2014 UTC (9 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.58: +2 -2 lines
Diff to previous 1.58 (colored)

pass size argument to free()
ok doug tedu

Revision 1.58 / (download) - annotate - [select for diffs], Sat Jul 12 18:43:32 2014 UTC (9 years, 11 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE
Branch point for: OPENBSD_5_6
Changes since 1.57: +3 -3 lines
Diff to previous 1.57 (colored)

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.

Revision 1.57 / (download) - annotate - [select for diffs], Thu May 15 04:43:25 2014 UTC (10 years ago) by guenther
Branch: MAIN
Changes since 1.56: +5 -3 lines
Diff to previous 1.56 (colored)

knote_processexit() needs the thread to pass down to FRELE(), so pass it
the exiting thread instead of assuming that that's ps_mainproc.
Also, panic no matter which thread of init takes it down.

ok tedu@

Revision 1.56 / (download) - annotate - [select for diffs], Sun Mar 30 21:54:48 2014 UTC (10 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.55: +2 -2 lines
Diff to previous 1.55 (colored)

Eliminates struct pcred by moving the real and saved ugids into
struct ucred; struct process then directly links to the ucred

Based on a discussion at c2k10 or so before noting that FreeBSD and
NetBSD did this too.

ok matthew@

Revision 1.55 / (download) - annotate - [select for diffs], Wed Jan 22 02:31:30 2014 UTC (10 years, 4 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.54: +7 -9 lines
Diff to previous 1.54 (colored)

Delete casts in assignments to void* and passed void* arguments.
bcopy() can be memcpy() because target is freshly malloced.
&array[n] is simpler than (char*)array + n*sizeof(array[0])

ok tedu@

Revision 1.54 / (download) - annotate - [select for diffs], Tue Jan 21 01:48:44 2014 UTC (10 years, 4 months ago) by tedu
Branch: MAIN
Changes since 1.53: +4 -4 lines
Diff to previous 1.53 (colored)

bzero -> memset

Revision 1.53 / (download) - annotate - [select for diffs], Thu Nov 14 18:09:39 2013 UTC (10 years, 6 months ago) by chl
Branch: MAIN
Changes since 1.52: +5 -5 lines
Diff to previous 1.52 (colored)

Use (N * sizeof(struct klist)) instead of (N * sizeof(struct klist *))
when malloc'ing struct klist *.

Similar diff found upstream:
http://svnweb.freebsd.org/base?view=revision&revision=197575

Found by LLVM/Clang Static Analyzer.

ok tedu@ krw@ guenther@

Revision 1.52 / (download) - annotate - [select for diffs], Sat Sep 14 01:35:00 2013 UTC (10 years, 8 months ago) by guenther
Branch: MAIN
Changes since 1.51: +1 -254 lines
Diff to previous 1.51 (colored)

Snapshots for all archs have been built, so remove the T32 code

Revision 1.51 / (download) - annotate - [select for diffs], Tue Aug 13 05:52:23 2013 UTC (10 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.50: +254 -1 lines
Diff to previous 1.50 (colored)

Switch time_t, ino_t, clock_t, and struct kevent's ident and data
members to 64bit types.  Assign new syscall numbers for (almost
all) the syscalls that involve the affected types, including anything
with time_t, timeval, itimerval, timespec, rusage, dirent, stat,
or kevent arguments.  Add a d_off member to struct dirent and replace
getdirentries() with getdents(), thus immensely simplifying and
accelerating telldir/seekdir.  Build perl with -DBIG_TIME.

Bump the major on every single base library: the compat bits included
here are only good enough to make the transition; the T32 compat
option will be burned as soon as we've reached the new world are
are happy with the snapshots for all architectures.

DANGER: ABI incompatibility.  Updating to this kernel requires extra
work or you won't be able to login: install a snapshot instead.

Much assistance in fixing userland issues from deraadt@ and tedu@
and build assistance from todd@ and otto@

Revision 1.50 / (download) - annotate - [select for diffs], Fri May 31 19:01:56 2013 UTC (11 years ago) by yasuoka
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.49: +2 -1 lines
Diff to previous 1.49 (colored)

On NOTE_EXIT event of EVFILT_PROC, store the exit status in kn_data.

ok guenther tedu deraadt

Revision 1.49 / (download) - annotate - [select for diffs], Wed Apr 24 09:52:54 2013 UTC (11 years, 1 month ago) by nicm
Branch: MAIN
Changes since 1.48: +10 -1 lines
Diff to previous 1.48 (colored)

When a ucom(4) is removed, it frees the tty with ttyfree(). However if
anyone is waiting with kqueue their knotes may still have a reference to
the tty and later try to use it in the filt_tty* functions.

To avoid this, walk the knotes in ttyfree(), remove them from the tty's
list and invalidate them by setting kn_hook to NODEV. The filter
functions can then check for this and safely ignore the knotes.

ok tedu matthieu

Revision 1.48 / (download) - annotate - [select for diffs], Sun Jul 8 17:21:08 2012 UTC (11 years, 11 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.47: +5 -10 lines
Diff to previous 1.47 (colored)

kevent(EV_DELETE) shouldn't be calling closef(), as that releases POSIX
file locks.  c.f. regress/sys/kern/kqueue/kqueue-flock.c

ok krw@

Revision 1.47 / (download) - annotate - [select for diffs], Wed Jun 6 04:47:43 2012 UTC (12 years ago) by guenther
Branch: MAIN
Changes since 1.46: +14 -14 lines
Diff to previous 1.46 (colored)

EVFILT_SIGNAL and EVFILT_PROC events need to track the process they're
attached to and not just the thread, which can go away.

Problem observed by jsg@; ok jsg@ matthew@

Revision 1.46 / (download) - annotate - [select for diffs], Sun Apr 22 05:43:14 2012 UTC (12 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.45: +5 -5 lines
Diff to previous 1.45 (colored)

Add struct proc * argument to FRELE() and FILE_SET_MATURE() in
anticipation of further changes to closef().  No binary change.

ok krw@ miod@ deraadt@

Revision 1.45 / (download) - annotate - [select for diffs], Sun Mar 25 20:33:54 2012 UTC (12 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.44: +36 -6 lines
Diff to previous 1.44 (colored)

release the file ref to the kqueue while in kevent(), so that close()
can terminate.  a new ref on the kqueue itself allows us to free it
properly in that case.  wakeups were missing too (for both kevent and poll).
similar to netbsd pr46248. fixes a number of threaded ports.
this version of the fix from matthew.
ok tedu guenther matthew

Revision 1.44 / (download) - annotate - [select for diffs], Mon Mar 19 09:05:39 2012 UTC (12 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.43: +6 -1 lines
Diff to previous 1.43 (colored)

Add tracing and dumping of "pointer to struct" syscall arguments for
structs timespec, timeval, sigaction, and rlimit.

ok otto@ jsing@

Revision 1.43 / (download) - annotate - [select for diffs], Sat Mar 10 05:54:28 2012 UTC (12 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.42: +2 -2 lines
Diff to previous 1.42 (colored)

Add PS_EXITING to better differentiate between the process exiting and
the main thread exiting.  c.f. regress/sys/kern/main-thread-exited/

Revision 1.42 / (download) - annotate - [select for diffs], Wed Feb 15 04:26:27 2012 UTC (12 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.41: +3 -1 lines
Diff to previous 1.41 (colored)

Hold struct filedesc's fd_lock when writing to the fd_ofiles, fd_ofileflags,
or fd_{lo,hi}maps members, or when doing a read for a write.  Fixes hangs
when an rthreaded processes sleeps while copying the fd table for fork()
and catches another thread with the lock.

ok jsing@ tedu@

Revision 1.41 / (download) - annotate - [select for diffs], Sat Jul 2 22:20:08 2011 UTC (12 years, 11 months ago) by nicm
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.40: +2 -2 lines
Diff to previous 1.40 (colored)

kqueue attach functions should return an errno or 0, not a plain 1. Fix
the obvious cases to return EINVAL and ENXIO.

ok tedu deraadt

Revision 1.40 / (download) - annotate - [select for diffs], Tue May 3 15:59:50 2011 UTC (13 years, 1 month ago) by marco
Branch: MAIN
Changes since 1.39: +3 -3 lines
Diff to previous 1.39 (colored)

spaces

Revision 1.39 / (download) - annotate - [select for diffs], Sat Apr 2 17:04:35 2011 UTC (13 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.38: +2 -2 lines
Diff to previous 1.38 (colored)

Move P_SUGID and P_SUGIDEXEC from struct proc to struct process, so
that you can't evade the checks by doing the dirty work in an rthread

ok blambert@, deraadt@

Revision 1.38 / (download) - annotate - [select for diffs], Mon Aug 2 19:54:07 2010 UTC (13 years, 10 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.37: +23 -2 lines
Diff to previous 1.37 (colored)

Fix knote handling for exiting processes: when triggering a NOTE_EXIT
knote, remove it from the process's klist; after handling those,
remove and drop any remaining knotes from the process's klist.  Ban
attaching knotes to processes that have started exiting or attaching
them via the pid of a thread other than the main thread.

ok tedu@, deraadt@

Revision 1.37 / (download) - annotate - [select for diffs], Wed Jul 28 21:44:41 2010 UTC (13 years, 10 months ago) by nicm
Branch: MAIN
Changes since 1.36: +31 -1 lines
Diff to previous 1.36 (colored)

Add a dummy kqueue filter similar to seltrue and use it for anything
using seltrue for poll. Based on code from NetBSD.

Also remove a stray duplicate lpt entry from loongson, from deraadt.

ok tedu deraadt

Revision 1.36 / (download) - annotate - [select for diffs], Tue May 18 22:26:09 2010 UTC (14 years ago) by tedu
Branch: MAIN
Changes since 1.35: +3 -3 lines
Diff to previous 1.35 (colored)

move knote list to struct process.  ok guenther

Revision 1.35 / (download) - annotate - [select for diffs], Mon Nov 9 17:53:39 2009 UTC (14 years, 7 months ago) by nicm
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.34: +3 -3 lines
Diff to previous 1.34 (colored)

Every selwakeup() should have a matching KNOTE() (even if kqueue isn't
supported it doesn't do any harm), so put the KNOTE() in selwakeup() itself and
remove it from any occurences where both are used, except one for kqueue itself
and one in sys_pipe.c (where the selwakeup is under a PIPE_SEL flag).

Based on a diff from tedu.

ok deraadt

Revision 1.34 / (download) - annotate - [select for diffs], Tue Jun 2 11:04:55 2009 UTC (15 years ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.33: +3 -2 lines
Diff to previous 1.33 (colored)

A process should always be able to attach kevent filters to its own
threads, even when it has changed uid or gid in the past.  As is, a
P_SUGID process using rthreads leaks the stack on thread exit.

requested and approved by tedu@ a while ago

Revision 1.33 / (download) - annotate - [select for diffs], Tue May 6 20:57:19 2008 UTC (16 years, 1 month ago) by thib
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.32: +2 -3 lines
Diff to previous 1.32 (colored)

Add a PR_ZERO flag for pools, to compliment the M_ZERO
malloc flag, does the same thing.
use it in a few places.

OK tedu@, "then go ahead. and don't forget the manpage (-:" miod@

Revision 1.32 / (download) - annotate - [select for diffs], Mon Oct 29 14:12:19 2007 UTC (16 years, 7 months ago) by chl
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.31: +3 -3 lines
Diff to previous 1.31 (colored)

MALLOC/FREE -> malloc/free
replace an hard coded value with M_WAITOK

ok krw@

Revision 1.31 / (download) - annotate - [select for diffs], Wed May 30 02:24:59 2007 UTC (17 years ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.30: +10 -10 lines
Diff to previous 1.30 (colored)

openbsd has timeouts, not callouts so rename the variables.  i applied an older
diff from brad.  from brad.

Revision 1.30 / (download) - annotate - [select for diffs], Wed May 30 00:23:48 2007 UTC (17 years ago) by tedu
Branch: MAIN
Changes since 1.29: +75 -1 lines
Diff to previous 1.29 (colored)

add a new kevent filter type for timers.  this allows processes to create
a series of oneshot or periodic timers.  capped to a global limit.
from freebsd via brad.
ok art pedro

Revision 1.28.2.1 / (download) - annotate - [select for diffs], Sat Apr 28 01:53:46 2007 UTC (17 years, 1 month ago) by ckuethe
Branch: OPENBSD_4_1
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored) next main 1.29 (colored)

stability fix from reyk

Original commit message:
============================================================
the splnet() does not make sense at this place and can lead to a panic
with heavy kqueue usage. changing it to splhigh() fixes the problem.

suggested by dlg@ deraadt@, ok dlg@ tedu@ art@
============================================================

Revision 1.26.4.1 / (download) - annotate - [select for diffs], Fri Mar 30 22:34:43 2007 UTC (17 years, 2 months ago) by ckuethe
Branch: OPENBSD_4_0
Changes since 1.26: +2 -2 lines
Diff to previous 1.26 (colored) next main 1.27 (colored)

MFC, stability fix from reyk

Original commit message:
============================================================
the splnet() does not make sense at this place and can lead to a panic
with heavy kqueue usage. changing it to splhigh() fixes the problem.

suggested by dlg@ deraadt@, ok dlg@ tedu@ art@
============================================================

Revision 1.26.2.1 / (download) - annotate - [select for diffs], Fri Mar 30 22:33:57 2007 UTC (17 years, 2 months ago) by ckuethe
Branch: OPENBSD_3_9
Changes since 1.26: +2 -2 lines
Diff to previous 1.26 (colored) next main 1.27 (colored)

MFC, stability fix from reyk

Original commit message:
============================================================
the splnet() does not make sense at this place and can lead to a panic
with heavy kqueue usage. changing it to splhigh() fixes the problem.

suggested by dlg@ deraadt@, ok dlg@ tedu@ art@
============================================================

Revision 1.29 / (download) - annotate - [select for diffs], Fri Mar 30 14:21:51 2007 UTC (17 years, 2 months ago) by reyk
Branch: MAIN
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored)

change a misplaced splnet() in kqueue_poll() to splhigh(). fixes a
random panics with kqueue under high load with many events.

tested by me
cookies for dlg@ deraadt@
ok dlg@ tedu@ art@

Revision 1.28 / (download) - annotate - [select for diffs], Fri Dec 1 07:17:25 2006 UTC (17 years, 6 months ago) by camield
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE
Branch point for: OPENBSD_4_1
Changes since 1.27: +2 -2 lines
Diff to previous 1.27 (colored)

spell kqueue, not kqeue

ok jmc

Revision 1.27 / (download) - annotate - [select for diffs], Wed Nov 15 17:25:40 2006 UTC (17 years, 6 months ago) by jmc
Branch: MAIN
Changes since 1.26: +3 -3 lines
Diff to previous 1.26 (colored)

typos; from bret lambert

Revision 1.26 / (download) - annotate - [select for diffs], Mon Nov 21 18:16:45 2005 UTC (18 years, 6 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_3_9_BASE
Branch point for: OPENBSD_4_0, OPENBSD_3_9
Changes since 1.25: +2 -2 lines
Diff to previous 1.25 (colored)

Move contents of sys/select.h to sys/selinfo.h in preparation for a
userland-visible sys/select.h.  Consistent with what Net and Free do.
OK deraadt@, tested with full ports build by naddy@.

Revision 1.25 / (download) - annotate - [select for diffs], Thu Sep 16 18:46:01 2004 UTC (19 years, 8 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.24: +2 -2 lines
Diff to previous 1.24 (colored)

Don't put parens around the call to pool_put but do use parens to
protect expansion of the kn parameter.  OK miod@

Revision 1.24 / (download) - annotate - [select for diffs], Thu Jun 24 19:35:24 2004 UTC (19 years, 11 months ago) by tholo
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.23: +13 -8 lines
Diff to previous 1.23 (colored)

This moves access to wall and uptime variables in MI code,
encapsulating all such access into wall-defined functions
that makes sure locking is done as needed.

It also cleans up some uses of wall time vs. uptime some
places, but there is sure to be more of these needed as
well, particularily in MD code.  Also, many current calls
to microtime() should probably be changed to getmicrotime(),
or to the {,get}microuptime() versions.

ok art@ deraadt@ aaron@ matthieu@ beck@ sturm@ millert@ others
"Oh, that is not your problem!" from miod@

Revision 1.8.2.7 / (download) - annotate - [select for diffs], Sat Jun 5 23:13:01 2004 UTC (20 years ago) by niklas
Branch: SMP
Changes since 1.8.2.6: +1 -8 lines
Diff to previous 1.8.2.6 (colored) next main 1.9 (colored)

Merge with the trunk

Revision 1.23 / (download) - annotate - [select for diffs], Thu Apr 1 00:27:51 2004 UTC (20 years, 2 months ago) by tedu
Branch: MAIN
CVS Tags: SMP_SYNC_B, SMP_SYNC_A
Changes since 1.22: +2 -9 lines
Diff to previous 1.22 (colored)

init kqueues normally, from pedro martelletto

Revision 1.8.2.6 / (download) - annotate - [select for diffs], Thu Feb 19 10:56:37 2004 UTC (20 years, 3 months ago) by niklas
Branch: SMP
Changes since 1.8.2.5: +38 -9 lines
Diff to previous 1.8.2.5 (colored)

Merge of current from two weeks agointo the SMP branch

Revision 1.22 / (download) - annotate - [select for diffs], Mon Jan 12 04:47:01 2004 UTC (20 years, 5 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.21: +12 -1 lines
Diff to previous 1.21 (colored)

klist_invalidate to help clean up when the backend disappears, tested by mpf@

Revision 1.21 / (download) - annotate - [select for diffs], Tue Sep 23 16:51:12 2003 UTC (20 years, 8 months ago) by millert
Branch: MAIN
Changes since 1.20: +9 -8 lines
Diff to previous 1.20 (colored)

Replace select backends with poll backends.  selscan() and pollscan()
now call the poll backend.  With this change we implement greater
poll(2) functionality instead of emulating it via the select backend.
Adapted from NetBSD and including some changes from FreeBSD.
Tested by many, deraadt@ OK

Revision 1.20 / (download) - annotate - [select for diffs], Fri Aug 15 20:32:18 2003 UTC (20 years, 10 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.19: +2 -3 lines
Diff to previous 1.19 (colored)

change arguments to suser.  suser now takes the process, and a flags
argument.  old cred only calls user suser_ucred.  this will allow future
work to more flexibly implement the idea of a root process.  looks like
something i saw in freebsd, but a little different.
use of suser_ucred vs suser in file system code should be looked at again,
for the moment semantics remain unchanged.
review and input from art@  testing and further review miod@

Revision 1.19 / (download) - annotate - [select for diffs], Fri Jun 27 16:20:58 2003 UTC (20 years, 11 months ago) by nate
Branch: MAIN
Changes since 1.18: +19 -1 lines
Diff to previous 1.18 (colored)

filter event that simulates seltrue(). From NetBSD

Revision 1.8.2.5 / (download) - annotate - [select for diffs], Fri Mar 28 00:41:26 2003 UTC (21 years, 2 months ago) by niklas
Branch: SMP
Changes since 1.8.2.4: +6 -7 lines
Diff to previous 1.8.2.4 (colored)

Sync the SMP branch with 3.3

Revision 1.10.2.3 / (download) - annotate - [select for diffs], Tue Oct 29 00:36:44 2002 UTC (21 years, 7 months ago) by art
Branch: UBC
Changes since 1.10.2.2: +7 -8 lines
Diff to previous 1.10.2.2 (colored) to branchpoint 1.10 (colored) next main 1.11 (colored)

sync to -current

Revision 1.18 / (download) - annotate - [select for diffs], Tue Oct 1 14:06:53 2002 UTC (21 years, 8 months ago) by art
Branch: MAIN
CVS Tags: UBC_SYNC_B, UBC_SYNC_A, OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.17: +7 -8 lines
Diff to previous 1.17 (colored)

Prevent two localhost crashes with proc filters.
 - don't send NOTE_SIGNAL to exiting processes.
 - null dereference on error condition.
from Peter Werner <peterw at ifost.org.au>
deraadt@ ok

Revision 1.10.2.2 / (download) - annotate - [select for diffs], Tue Jun 11 03:29:40 2002 UTC (22 years ago) by art
Branch: UBC
Changes since 1.10.2.1: +37 -40 lines
Diff to previous 1.10.2.1 (colored) to branchpoint 1.10 (colored)

Sync UBC branch to -current

Revision 1.8.2.4 / (download) - annotate - [select for diffs], Wed Mar 6 02:13:23 2002 UTC (22 years, 3 months ago) by niklas
Branch: SMP
Changes since 1.8.2.3: +37 -41 lines
Diff to previous 1.8.2.3 (colored)

Merge in trunk

Revision 1.17 / (download) - annotate - [select for diffs], Fri Mar 1 12:17:58 2002 UTC (22 years, 3 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.16: +3 -2 lines
Diff to previous 1.16 (colored)

fp doesn't necessarily have to be set when we do the early FRELE.

Revision 1.16 / (download) - annotate - [select for diffs], Fri Feb 8 13:53:28 2002 UTC (22 years, 4 months ago) by art
Branch: MAIN
Changes since 1.15: +7 -7 lines
Diff to previous 1.15 (colored)

- Rename FILE_{,UN}USE to FREF and FRELE. USE is a bad verb and we don't have
  the same semantics as NetBSD anyway, so it's good to avoid name collissions.
- Always fdremove before freeing the file, not the other way around.
- falloc FREFs the file.
- have FILE_SET_MATURE FRELE the file (It feels like a good ortogonality to
  falloc FREFing the file).
- Use closef as much as possible instead of ffree in error paths of
  falloc:ing functions. closef is much more careful with the fd and can
  deal with the fd being forcibly closed by dup2. Also try to avoid
  manually calling *fo_close when closef can do that for us (this makes
  some error paths mroe complicated (sys_socketpair and sys_pipe), but
  others become simpler (sys_open)).

Revision 1.15 / (download) - annotate - [select for diffs], Tue Feb 5 16:02:27 2002 UTC (22 years, 4 months ago) by art
Branch: MAIN
Changes since 1.14: +10 -6 lines
Diff to previous 1.14 (colored)

Add counting of temporary references to a struct file (as opposed to references
from fd tables and other long-lived objects). This is to avoid races between
using a file descriptor and having another process (with shared fd table)
close it. We use a separate refence count so that error values from close(2)
will be correctly returned to the caller of close(2).

The macros for those reference counts are FILE_USE(fp) and FILE_UNUSE(fp).

Make sure that the cases where closef can be called "incorrectly" (most notably
dup2(2)) are handled.

Right now only callers of closef (and {,p}read) use FILE_{,UN}USE correctly,
more fixes incoming soon.

Revision 1.14 / (download) - annotate - [select for diffs], Fri Feb 1 15:32:43 2002 UTC (22 years, 4 months ago) by art
Branch: MAIN
Changes since 1.13: +25 -32 lines
Diff to previous 1.13 (colored)

Allocate kqueues with pool.

Revision 1.13 / (download) - annotate - [select for diffs], Fri Feb 1 14:24:08 2002 UTC (22 years, 4 months ago) by art
Branch: MAIN
Changes since 1.12: +3 -4 lines
Diff to previous 1.12 (colored)

Don't MALLOC with variable size.

Revision 1.10.2.1 / (download) - annotate - [select for diffs], Thu Jan 31 22:55:40 2002 UTC (22 years, 4 months ago) by niklas
Branch: UBC
Changes since 1.10: +2 -3 lines
Diff to previous 1.10 (colored)

Merge in -current, builds on i386, otherwise untested

Revision 1.12 / (download) - annotate - [select for diffs], Fri Jan 25 04:03:29 2002 UTC (22 years, 4 months ago) by art
Branch: MAIN
Changes since 1.11: +1 -2 lines
Diff to previous 1.11 (colored)

kernel printfs triggerable by a simple mistake in userland are just wrong.

Revision 1.11 / (download) - annotate - [select for diffs], Wed Jan 23 00:39:47 2002 UTC (22 years, 4 months ago) by art
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
 - group all information the backend allocator for a pool in a separate
   struct. The pool will only have a pointer to that struct.
 - change the pool_init API to reflect that.
 - link all pools allocating from the same allocator on a linked list.
 - Since an allocator is responsible to wait for physical memory it will
   only fail (waitok) when it runs out of its backing vm_map, carefully
   drain pools using the same allocator so that va space is freed.
   (see comments in code for caveats and details).
 - change pool_reclaim to return if it actually succeeded to free some
   memory, use that information to make draining easier and more efficient.
 - get rid of PR_URGENT, noone uses it.

Revision 1.8.2.3 / (download) - annotate - [select for diffs], Wed Oct 31 03:26:29 2001 UTC (22 years, 7 months ago) by nate
Branch: SMP
Changes since 1.8.2.2: +25 -8 lines
Diff to previous 1.8.2.2 (colored)

Sync the SMP branch to something just after 3.0

Revision 1.10 / (download) - annotate - [select for diffs], Fri Oct 26 12:03:27 2001 UTC (22 years, 7 months ago) by art
Branch: MAIN
CVS Tags: UBC_BASE
Branch point for: UBC
Changes since 1.9: +5 -6 lines
Diff to previous 1.9 (colored)

 - every new fd created by falloc() is marked as larval and should not be used
   any anyone. Every caller of falloc matures the fd when it's usable.
 - Since every lookup in the fd table must now check this flag and all of
   them do the same thing, move all the necessary checks into a function -
   fd_getfile.

Revision 1.9 / (download) - annotate - [select for diffs], Tue Jul 17 01:51:37 2001 UTC (22 years, 11 months ago) by provos
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.8: +21 -3 lines
Diff to previous 1.8 (colored)

use pool allocator for knotes, adapted from lukem@netbsd, okay art@

Revision 1.8.2.2 / (download) - annotate - [select for diffs], Wed Jul 4 10:48:16 2001 UTC (22 years, 11 months ago) by niklas
Branch: SMP
Changes since 1.8.2.1: +16 -1 lines
Diff to previous 1.8.2.1 (colored)

Merge in -current from two days ago in the SMP branch.
As usual with merges, they do not indicate progress, so do not hold
your breath for working SMP, and do not mail me and ask about the
state of it.  It has not changed.  There is work ongoing, but very, very
slowly.  The commit is done in parts as to not lock up the tree in too
big chunks at a time.

Revision 1.8.2.1 / (download) - annotate - [select for diffs], Mon May 14 22:32:40 2001 UTC (23 years, 1 month ago) by niklas
Branch: SMP
Changes since 1.8: +0 -15 lines
Diff to previous 1.8 (colored)

merge in approximately 2.9 into SMP branch

Revision 1.8 / (download) - annotate - [select for diffs], Mon May 14 12:38:46 2001 UTC (23 years, 1 month ago) by art
Branch: MAIN
Branch point for: SMP
Changes since 1.7: +16 -1 lines
Diff to previous 1.7 (colored)

Add a fo_stat member to struct fileops. Used soon.
Also add a stat function for kqueue from FreeBSD.

Revision 1.7 / (download) - annotate - [select for diffs], Thu Mar 1 20:54:33 2001 UTC (23 years, 3 months ago) by provos
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.6: +67 -83 lines
Diff to previous 1.6 (colored)

port kqueue changes from freebsd, plus all required openbsd glue.
okay deraadt@, millert@
from jlemon@freebsd.org:
extend kqueue down to the device layer, backwards compatible approach
suggested by peter@freebsd.org

Revision 1.6 / (download) - annotate - [select for diffs], Tue Nov 21 21:49:57 2000 UTC (23 years, 6 months ago) by provos
Branch: MAIN
Changes since 1.5: +5 -5 lines
Diff to previous 1.5 (colored)

support for kernel events on vnodes, from jlemon@freebsd.org, okay art@

Revision 1.5 / (download) - annotate - [select for diffs], Sat Nov 18 22:16:49 2000 UTC (23 years, 6 months ago) by provos
Branch: MAIN
Changes since 1.4: +9 -2 lines
Diff to previous 1.4 (colored)

better permission check; okay art@, millert@

Revision 1.4 / (download) - annotate - [select for diffs], Fri Nov 17 06:34:23 2000 UTC (23 years, 6 months ago) by provos
Branch: MAIN
Changes since 1.3: +13 -12 lines
Diff to previous 1.3 (colored)

calculate timeouts correctly, simpler.

Revision 1.3 / (download) - annotate - [select for diffs], Fri Nov 17 05:18:44 2000 UTC (23 years, 6 months ago) by provos
Branch: MAIN
Changes since 1.2: +2 -2 lines
Diff to previous 1.2 (colored)

correct timersub

Revision 1.2 / (download) - annotate - [select for diffs], Thu Nov 16 20:24:35 2000 UTC (23 years, 6 months ago) by mickey
Branch: MAIN
Changes since 1.1: +38 -36 lines
Diff to previous 1.1 (colored)

rcsid; fix comment; lots of bad tabs and spaces

Revision 1.1 / (download) - annotate - [select for diffs], Thu Nov 16 20:02:15 2000 UTC (23 years, 6 months ago) by provos
Branch: MAIN

support kernel event queues, from FreeBSD by Jonathan Lemon,
okay art@, millert@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.