| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
| |
OK mpi@
|
|
|
|
|
|
| |
This will soon be used by select(2) and poll(2).
ok anton@, visa@
|
|
|
|
|
|
|
| |
Stop iterating in the function and instead copy the returned events to
userland after every call.
ok visa@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
| |
ok mvs@, visa@
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
| |
ok visa@, millert@
|
|
|
|
|
|
| |
This is only done in poll-compatibility mode, when __EV_POLL is set.
ok visa@, millert@
|
|
|
|
| |
Port breakages reported by naddy@
|
|
|
|
|
|
| |
While here prefix kernel-only EV flags with two underbars.
Suggested by kettenis@, ok visa@
|
|
|
|
|
|
|
|
|
| |
Adapt FS kqfilters to always return true when the flag is set and bypass
the polling mechanism of the NFS thread.
While here implement a write filter for NFS.
ok visa@
|
|
|
|
| |
sthen@ has reported that the patch might be causing hangs with X.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
| |
that have arguments. Document this requirement/recommendation in style(9)
prompted by mpi@
ok deraadt@
|
|
|
|
|
|
| |
for example, with locking assertions.
OK mpi@, anton@
|
|
|
|
|
|
|
|
| |
Use two underbars to start the locally defined variable, as suggested by
guenther@. The other option to avoid namespace conflict would be to start
the identifier with an underbar and a capital.
ok beck@, guenther@
|
|
|
|
|
|
| |
adding more filter properties without cluttering the struct.
OK mpi@, anton@
|
|
|
|
|
|
| |
make the structs const so that the data are put in .rodata.
OK mpi@, deraadt@, anton@, bluhm@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
| |
listeners of device state changes.
currently only supports NOTE_CHANGE that will be used by drm(4)
ok kettenis@
|
|
|
|
|
|
| |
respectively to avoid compilation errors when one of the POSIX or
X/OPEN version macros is defined. Also sync the field descriptions
with kqueue.2. OK deraadt@
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
buffers.
This is one step towards unlocking TCP input path. Note that all the
functions asserting for the socket lock are not necessarilly MP-safe.
All the fields of 'struct socket' aren't protected.
Introduce a new kernel-only kqueue hint, NOTE_SUBMIT, to be able to
tell when a filter needs to lock the underlying data structures. Logic
and name taken from NetBSD.
Tested by Hrvoje Popovski.
ok claudio@, bluhm@, mikeb@
|
|
|
|
|
| |
From FreeBSD via Jan Schreiber <jes at posteo ! de>, thanks!
OK tedu, bluhm
|
|
|
|
|
| |
matches freebsd, fixes lldb. from Kamil Rytarowski at NetBSD.
while here, make the same change to KNOTE. ok deraadt
|
|
|
|
| |
ok guenther
|
| |
|
|
|
|
| |
ok deraadt@
|
|
|
|
|
|
|
| |
the exiting thread instead of assuming that that's ps_mainproc.
Also, panic no matter which thread of init takes it down.
ok tedu@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
| |
attached to and not just the thread, which can go away.
Problem observed by jsg@; ok jsg@ matthew@
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
|
| |
using seltrue for poll. Based on code from NetBSD.
Also remove a stray duplicate lpt entry from loongson, from deraadt.
ok tedu deraadt
|
|
|
|
|
|
| |
expansion.
requested by otto@
|
|
|
|
|
|
| |
use in other if/else blocks.
"yeah" deraadt@
|
|
|
|
|
|
| |
a series of oneshot or periodic timers. capped to a global limit.
from freebsd via brad.
ok art pedro
|
| |
|
| |
|
|
|
|
|
| |
to kqueue
from marius@monkey tested by brad@
|
| |
|
| |
|
|
|
|
| |
ok deraadt@
|