History log of /dragonfly/sys/kern/sys_generic.c (Results 1 – 25 of 122)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 0d47c594 23-Jan-2024 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Fix long-standing bug in kqueue backend for *poll*()

* The poll() family of system calls passes an fds[] array with a
series of descriptors and event requests. Our kernel implementation

kernel - Fix long-standing bug in kqueue backend for *poll*()

* The poll() family of system calls passes an fds[] array with a
series of descriptors and event requests. Our kernel implementation
uses kqueue but a long standing bug breaks situations where
more than one fds[] entry for the poll corresponds to the same
{ ident, filter } for kqueue, causing only the last such entry
to be registered with kqueue and breaking poll().

* Added feature to kqueue to supply further distinctions between
knotes beyond the nominal { kq, filter, ident } tuple, allowing
us to fix poll().

* Added a FreeBSD feature where poll() implements an implied POLLHUP
when events = 0. This is used by X11 and (perhaps mistakenly) also
by sshd. Our poll previous ignored fds[] entries with events = 0.

* Note that sshd can generate poll fds[] arrays with both an events = 0
and an events = POLLIN for the same descriptor, which broke sshd
when I initially added the events = 0 support due to the first bug.

Now with that fixed, sshd works properly. However it is unclear whether
the authors of sshd intended events = 0 to detect POLLHUP or not.

Reported-by: servik (missing events = 0 poll feature)
Testing: servik, dillon

show more ...


# e6bc4d0d 28-Mar-2023 Matthew Dillon <dillon@apollo.backplane.com>

poll/select: Fix panic in kqueue backend

* The poll and select system calls use kqueue as a backend and
attempt to cache active events from prior calls to improve
performance.

However, this m

poll/select: Fix panic in kqueue backend

* The poll and select system calls use kqueue as a backend and
attempt to cache active events from prior calls to improve
performance.

However, this makes a potential race more likely where in a
high-concurrency application one thread close()es a descriptor
that another thread had previously used in a poll/select operation
and this close() races the later poll/select operation that is
attempting to remove the kevent.

* The race can sometimes prevent the poll/select kevent copyout
code from removing previously cached but no-longer-used
events, because the removal references the events by their
descriptor rather than directly and the descriptor is no longer
valid.

This causes kern_kevent() to loop infinite and hit a panic
designed to check for that situation.

* Fix the problem by moving the removal of old events from the
poll/select copyout code into kqueue_scan(). kqueue_scan()
can detect old unused events using the sequence id that the
poll/select kernel code stores in the kevent.

show more ...


Revision tags: v6.4.0, v6.4.0rc1, v6.5.0, v6.2.2, v6.2.1, v6.2.0, v6.3.0, v6.0.1
# 6df899ee 13-May-2021 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Implement POLLHUP for pipes and filesystem fifos (3)

* Add an internal NOTE_HUPONLY flag to allow the poll() system call
to tell the kevent system that EVFILT_READ should only trigger on

kernel - Implement POLLHUP for pipes and filesystem fifos (3)

* Add an internal NOTE_HUPONLY flag to allow the poll() system call
to tell the kevent system that EVFILT_READ should only trigger on
a HUP and not trigger on read-data-present.

* Linux does not trigger POLLHUP on a half-closed socket, make
DFly have the same behavior. POLLHUP is only triggered on a fully-closed
socket.

* Fix bug where data-present on the pipe, socket, or fifo would trigger an
EVFILT_READ event when only a HUP is being requested. This caused our
poll() implementation to complain about spurious events (which then
results in incorrect operation).

show more ...


# 8eaaa203 13-May-2021 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Implement POLLHUP for pipes and filesystem fifos (2)

* Allow POLLHUP to be requested without POLLIN.

Reported-by: mjg


Revision tags: v6.0.0, v6.0.0rc1, v6.1.0, v5.8.3, v5.8.2
# 80d831e1 25-Jul-2020 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Refactor in-kernel system call API to remove bcopy()

* Change the in-kernel system call prototype to take the
system call arguments as a separate pointer, and make the
contents read-onl

kernel - Refactor in-kernel system call API to remove bcopy()

* Change the in-kernel system call prototype to take the
system call arguments as a separate pointer, and make the
contents read-only.

int sy_call_t (void *);
int sy_call_t (struct sysmsg *sysmsg, const void *);

* System calls with 6 arguments or less no longer need to copy
the arguments from the trapframe to a holding structure. Instead,
we simply point into the trapframe.

The L1 cache footprint will be a bit smaller, but in simple tests
the results are not noticably faster... maybe 1ns or so
(roughly 1%).

show more ...


# 2885073d 15-Jul-2020 Sascha Wildner <saw@online.de>

kernel: Remove some unused variables and a dead sysctl.

Reported-by: mjg


# 95121ed2 06-Jun-2020 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Refactor kern_kevent(), fix timeout overflow (ppoll() bug) (2)

* Certain unsupported EV_ERROR events can cause kern_kevent() to
live-lock, which hits a 'checkloop failed' panic. Silently

kernel - Refactor kern_kevent(), fix timeout overflow (ppoll() bug) (2)

* Certain unsupported EV_ERROR events can cause kern_kevent() to
live-lock, which hits a 'checkloop failed' panic. Silently
deregister such events.

* Complain and deregister any kqueue event on behalf of *poll()
which does not set any poll return flags.

Reported-by: swildner

show more ...


Revision tags: v5.8.1
# 7323bef7 18-Mar-2020 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Generate POLLHUP for fully disconnected socket

* Properly generate POLLHUP for fully disconnected sockets.

However, there is still a possible issue. We do not set POLLHUP
for half-clo

kernel - Generate POLLHUP for fully disconnected socket

* Properly generate POLLHUP for fully disconnected sockets.

However, there is still a possible issue. We do not set POLLHUP
for half-closed sockets and it is really unclear whether we should
or not once read data has been exhausted.

show more ...


Revision tags: v5.8.0, v5.9.0, v5.8.0rc1, v5.6.3
# e58ce663 18-Oct-2019 zrj <rimvydas.jasinskas@gmail.com>

kernel: Fix spurious M_IOV declarations.

Do not include <sys/malloc.h> unconditionally in <sys/uio.h> as it only
hides issues in other headers and source codes.
* Include <sys/malloc.h> before <s

kernel: Fix spurious M_IOV declarations.

Do not include <sys/malloc.h> unconditionally in <sys/uio.h> as it only
hides issues in other headers and source codes.
* Include <sys/malloc.h> before <sys/uio.h> in sys_generic.c for M_IOV.

show more ...


Revision tags: v5.6.2, v5.6.1, v5.6.0, v5.6.0rc1, v5.7.0, v5.4.3, v5.4.2, v5.4.1, v5.4.0, v5.5.0, v5.4.0rc1, v5.2.2, v5.2.1
# d6299163 22-Apr-2018 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Remove SMP bottlenecks on uidinfo, descriptors, and lockf

* Use an eventcounter and the per-thread fd cache to fix
bottlenecks in checkfdclosed(). This will work well for
the vast majo

kernel - Remove SMP bottlenecks on uidinfo, descriptors, and lockf

* Use an eventcounter and the per-thread fd cache to fix
bottlenecks in checkfdclosed(). This will work well for
the vast majority of applications and test benches.

* Batch holdfp*() operations on kqueue collections when implementing
poll() and select(). This significant improves performance.
Full scaling not yet achieved, however.

* Increase copyin item batching from 8 to 32 for select() and poll().

* Give the uidinfo structure a pcpu array to hold the posixlocks
and openfiles count fields, with a rollup contained in the uidinfo
structure itself.

This removes numerous global bottlenecks related to open(),
close(), dup*(), and lockf operations (posixlocks count).

ui_openfiles will force a rollup on limit reached to be sure
that the limit was actually reached. ui_posixlocks stays fairly
loose. Each cpu rolls up generally only when the pcpu count exceeds
+32 or goes below -32.

* Give the proc structure a pcpu array for the same counts, in order
to properly support seteuid() and such.

* Replace P_ADVLOCK with a char field proc->p_advlock_flag, and
remove token operations around the field.

show more ...


# 35949930 20-Apr-2018 Matthew Dillon <dillon@apollo.backplane.com>

kernel - per-thread fd cache, p_fd lock bypass

* Implement a per-thread (fd,fp) cache. Cache hits can keep fp's
in a held state (avoiding the need to fhold()/fdrop() the ref count),
and bypasse

kernel - per-thread fd cache, p_fd lock bypass

* Implement a per-thread (fd,fp) cache. Cache hits can keep fp's
in a held state (avoiding the need to fhold()/fdrop() the ref count),
and bypasses the p_fd spinlock. This allows the file pointer structure
to generally be shared across cpu caches.

* Can cache up to four descriptors in each thread, LRU. This is the common
case. Highly threaded programs tend to focus work on a distinct
file descriptors in each thread.

* One file descriptor can be cached in up to four threads. This is
a significant limitation, though relatively uncommon. On a cache miss
the code drops into the normal shared p_fd spinlock lookup.

show more ...


Revision tags: v5.2.0, v5.3.0, v5.2.0rc, v5.0.2, v5.0.1, v5.0.0, v5.0.0rc2, v5.1.0, v5.0.0rc1
# fd399d96 29-Aug-2017 Sepherosa Ziehau <sephe@dragonflybsd.org>

poll/select: Use 64bit serial for poll/select's kevent.udata.

This fixes the issue mentioned in this commit:
ce4975442fa0524017fb3c1aef93bbe6880ae770

It takes ~200 years for 2.5Ghz cpu to make the

poll/select: Use 64bit serial for poll/select's kevent.udata.

This fixes the issue mentioned in this commit:
ce4975442fa0524017fb3c1aef93bbe6880ae770

It takes ~200 years for 2.5Ghz cpu to make the 64bit serial wrap,
even if the cpu's speed were 10 times faster tomorrow, it still
would take two decades to make the 64bit serial wrap.

Suggested-by: dillon@

show more ...


# 203bf8e2 29-Aug-2017 Sepherosa Ziehau <sephe@dragonflybsd.org>

Revert "select: Don't allow unwanted/leftover fds being returned."

This reverts commit ce4975442fa0524017fb3c1aef93bbe6880ae770.


# 6a165a97 28-Aug-2017 Sepherosa Ziehau <sephe@dragonflybsd.org>

poll: Fix inverse test


# ce497544 28-Aug-2017 Sepherosa Ziehau <sephe@dragonflybsd.org>

select: Don't allow unwanted/leftover fds being returned.

The root cause is that the lwp_kqueue_serial will wrap pretty quickly,
6 seconds on my laptop, if the select(2) is polling, either due to he

select: Don't allow unwanted/leftover fds being returned.

The root cause is that the lwp_kqueue_serial will wrap pretty quickly,
6 seconds on my laptop, if the select(2) is polling, either due to heavy
workload or 0 timeout. The POC test:
https://leaf.dragonflybsd.org/~sephe/select_wrap.c

Fixing this issue by saving the original fd_sets and do additional
kevent filtering before return the fd to userland.

poll(2) suffers the similar issue and will be fixed in later commit.

Reported-by: many

show more ...


Revision tags: v4.8.1, v4.8.0, v4.6.2, v4.9.0, v4.8.0rc
# 282f3194 11-Jan-2017 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Incidental MPLOCK removal

* Remove misc #include <sys/mplock2.h> statements that are no longer needed.

* Replace mplock with acct_lock in kern_acct.c

* Replace mplock with msg_token in sy

kernel - Incidental MPLOCK removal

* Remove misc #include <sys/mplock2.h> statements that are no longer needed.

* Replace mplock with acct_lock in kern_acct.c

* Replace mplock with msg_token in sysv_msg.c

* Replace mplock with p->p_token in the profiling code.

show more ...


# eba68494 01-Dec-2016 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Fix bug in socket_wait() (used by samba)

* socket_wait() was not properly initializing the temporary kqueue
structure, resulting in corruption that prevented the event from being
proper

kernel - Fix bug in socket_wait() (used by samba)

* socket_wait() was not properly initializing the temporary kqueue
structure, resulting in corruption that prevented the event from being
properly deleted.

* Fixes mount_smbfs panic.

Reported-by: dflyum

show more ...


Revision tags: v4.6.1
# c2e7bb20 27-Sep-2016 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Remove mplock from KTRACE paths

* The mplock is no longer needed for KTRACE, ktrace writes are serialized
by the vnode lock and everything else is MPSAFE. Note that this change
means t

kernel - Remove mplock from KTRACE paths

* The mplock is no longer needed for KTRACE, ktrace writes are serialized
by the vnode lock and everything else is MPSAFE. Note that this change
means that even fast system calls may interleave in the ktrace output on
a multi-threaded program.

* Fix ktrace bug related to vkernels. The syscall2() code assumes that
no tokens are held on entry (since we are coming from usermode), but
a system call made from the vkernel may actually be nested inside
another syscall2(). The mplock KTRACE held caused this to assert in
the nested syscall2(). The removal of the mplock from the ktrace path
also fixes this bug.

* Minor comment adjustment in vm_vmspace.c.

Reported-by: tuxillo

show more ...


Revision tags: v4.6.0, v4.6.0rc2, v4.6.0rc, v4.7.0, v4.4.3, v4.4.2
# 6d2444c4 12-Dec-2015 Imre Vadasz <imre@vdsz.com>

kernel - Implement ppoll system call with precise microseconds timeout.

* Implement a maximum timeout of 2000s, because systimer(9) just accepts an
int timeout in microseconds.

* Add kern.kv_slee

kernel - Implement ppoll system call with precise microseconds timeout.

* Implement a maximum timeout of 2000s, because systimer(9) just accepts an
int timeout in microseconds.

* Add kern.kv_sleep_threshold sysctl variable for tuning the threshold for
the ppoll sleep duration (in nanoseconds), below which we will
busy-loop with DELAY instead of using tsleep for waiting.

show more ...


Revision tags: v4.4.1, v4.4.0, v4.5.0, v4.4.0rc, v4.2.4, v4.3.1, v4.2.3, v4.2.1, v4.2.0, v4.0.6, v4.3.0, v4.2.0rc
# 0d20b837 26-May-2015 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Return EINVAL on negative timeout to poll()

* Return EINVAL if poll() is called with a negative
timeout, as per manual page.

Submitted-by: stateless


Revision tags: v4.0.5, v4.0.4, v4.0.3, v4.0.2, v4.0.1, v4.0.0, v4.0.0rc3, v4.0.0rc2, v4.0.0rc, v4.1.0, v3.8.2, v3.8.1, v3.6.3, v3.8.0, v3.8.0rc2, v3.9.0, v3.8.0rc, v3.6.2, v3.6.1
# 9dd5bb28 10-Jan-2014 Matthew Dillon <dillon@apollo.backplane.com>

kernel - Fix bug in last commit to sys_generic.c

* memp can be uninitialized if the goto done occurs.


# 13886075 09-Jan-2014 Matthew Dillon <dillon@apollo.backplane.com>

cyapa - Introduce better three-finger button emulation

* Change the three-finger button emulation such that the third finger that
you use to tap will emulate the LEFT, MIDDLE, or RIGHT buttons dep

cyapa - Introduce better three-finger button emulation

* Change the three-finger button emulation such that the third finger that
you use to tap will emulate the LEFT, MIDDLE, or RIGHT buttons depending
on its X position relative to the other two fingers that are being held
down.

e.g. if you arrange fingers left-to-right A, B, C, and you hold B and C
on the pad and tap A, that's a LEFT button. If you hold A and C and
tap B, that's a middle button, and if you hold A and B and tap C, that's
a right button.

* This methodology allows all three buttons to be emulated cleanly without
having to depress the trackpad's physical button.

* Document all jestures.

show more ...


Revision tags: v3.6.0, v3.7.1, v3.6.0rc, v3.7.0, v3.4.3
# dc71b7ab 31-May-2013 Justin C. Sherrill <justin@shiningsilence.com>

Correct BSD License clause numbering from 1-2-4 to 1-2-3.

Apparently everyone's doing it:
http://svnweb.freebsd.org/base?view=revision&revision=251069

Submitted-by: "Eitan Adler" <lists at eitanadl

Correct BSD License clause numbering from 1-2-4 to 1-2-3.

Apparently everyone's doing it:
http://svnweb.freebsd.org/base?view=revision&revision=251069

Submitted-by: "Eitan Adler" <lists at eitanadler.com>

show more ...


Revision tags: v3.4.2
# 2702099d 06-May-2013 Justin C. Sherrill <justin@shiningsilence.com>

Remove advertising clause from all that isn't contrib or userland bin.

By: Eitan Adler <lists@eitanadler.com>


Revision tags: v3.4.0, v3.4.1, v3.4.0rc, v3.5.0, v3.2.2
# 89233cfd 01-Nov-2012 John Marino <draco@marino.st>

Implement SO_NOSIGPIPE

The SO_NOSIGPIPE socket option allows a user process to mark a socket so
that the socket does not generate SIGPIPE, only EPIPE, when a write is
attempted after socket shutdown

Implement SO_NOSIGPIPE

The SO_NOSIGPIPE socket option allows a user process to mark a socket so
that the socket does not generate SIGPIPE, only EPIPE, when a write is
attempted after socket shutdown.

Regression test added: tools/regression/sockets/sigpipe

show more ...


12345