| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
OK anton@, 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@
|
|
|
|
|
|
|
|
| |
By storing pipe pointer in kn_hook, filt_pipedetach() does not need
extra logic to find the correct pipe instance. This also lets the kernel
clear the knote lists fully.
OK anton@, mpi@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
serializing calls to pipe_buffer_free(). Repeating the previous commit
message:
Instead of performing three distinct allocations per created pipe,
reduce it to a single one. Not only should this be more performant, it
also solves a kqueue related issue found by visa@ who also requested
this change: if you attach an EVFILT_WRITE filter to a pipe fd, the
knote gets added to the peer's klist. This is a problem for kqueue
because if you close the peer's fd, the knote is left in the list whose
head is about to be freed. knote_fdclose() is not able to clear the
knote because it is not registered with the peer's fd.
FreeBSD also takes a similar approach to pipe allocations.
once again ok mpi@ visa@
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
reduce it to a single one. Not only should this be more performant, it
also solves a kqueue related issue found by visa@ who also requested
this change: if you attach an EVFILT_WRITE filter to a pipe fd, the
knote gets added to the peer's klist. This is a problem for kqueue
because if you close the peer's fd, the knote is left in the list whose
head is about to be freed. knote_fdclose() is not able to clear the
knote because it is not registered with the peer's fd.
FreeBSD also takes a similar approach to pipe allocations.
ok mpi@ visa@
|
|
|
|
|
|
| |
This is only done in poll-compatibility mode, when __EV_POLL is set.
ok visa@, millert@
|
|
|
|
|
|
| |
for example, with locking assertions.
OK mpi@, anton@
|
|
|
|
|
|
| |
adding more filter properties without cluttering the struct.
OK mpi@, anton@
|
|
|
|
|
|
|
|
| |
excessive as only one command actually modifies the pipe. The sigio
subsystem is already internally protected using its own lock. This is
similar to what soo_ioctl() already does.
ok mpi@ visa@
|
|
|
|
|
|
|
|
|
|
|
| |
The 3 subsystems: signal, poll/select and kqueue can now be addressed
separatly.
Note that bpf(4) and audio(4) currently delay the wakeups to a separate
context in order to respect the KERNEL_LOCK() requirement. Sockets (UDP,
TCP) and pipes spin to grab the lock for the sames reasons.
ok anton@, visa@
|
|
|
|
| |
asked for more oks; my bad!
|
|
|
|
|
|
|
|
|
|
| |
operating on the process structure and issuing signals. This is similar
to what sigio_setown() already does.
With this in place, the pipe subsystem is no longer required to grab the
kernel lock before calling pgsigio().
ok visa@
|
| |
|
|
|
|
| |
ok millert@ ratchov@ visa@
|
|
|
|
|
|
|
| |
pair. One lock per pipe pair is used to guarantee exclusive access to
both ends of a pipe.
Thanks to millert@ and tedu@ for the feedback and ok visa@
|
|
|
|
|
|
|
|
|
|
|
|
| |
FIOGETOWN/SIOCGPGRP/TIOCGPGRP. Do this by determining the meaning of
the ID parameter inside the sigio code. Also add cases for FIOSETOWN
and FIOGETOWN where there have been TIOCSPGRP and TIOCGPGRP before.
These changes allow removing the ID translation from sys_fcntl() and
sys_ioctl().
Idea from NetBSD
OK mpi@, claudio@
|
|
|
|
| |
OK anton@, mpi@, bluhm@
|
|
|
|
|
|
|
| |
* Sort local variables by size, name
* No need to initialize error in pipe_write()
ok millert@ visa@
|
|
|
|
|
|
| |
mere preparation for introducing a dedicated lock per pipe pair.
ok mpi@ visa@
|
|
|
|
|
|
| |
make the structs const so that the data are put in .rodata.
OK mpi@, deraadt@, anton@, bluhm@
|
|
|
|
|
|
|
|
| |
is serialized by the pipe_lock by now. The kernel lock is however still
needed when interacting with kqueue in order to prevent a race and when
potentially issuing SIGIO signals.
ok visa@
|
|
|
|
| |
turn them into proper sentences. Gets rid of 27 lines in total.
|
|
|
|
|
|
|
|
|
|
|
| |
to simplify the locking pattern, revert back to using a hand-rolled I/O
lock just like FreeBSD and NetBSD does. The state of pipes is quite
different compared to when I made use of a rwlock for the I/O lock in
revision 1.96. Most notably, the pipe_lock can now be used while
sleeping. This does imply that witness(4) tracking of the I/O lock is
lost but the implementation ends up being simpler.
ok visa@
|
|
|
|
|
|
|
|
| |
pipe_lock. This add a potential sleeping point in the kqueue filter
routines which should be fine by now thanks to changes made to the
kqueue subsystem by visa.
ok visa@
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
rwlock. This lock is shared among all pipes for simplicity. In the
future, the lock will probably be replaced with one lock per pipe pair,
just like FreeBSD and NetBSD does.
While here, extract the common rundown wakeup logic into a dedicated
function.
Thanks to cheloha@ for testing and feedback.
ok mpi@ visa@
|
|
|
|
|
|
|
| |
rwsleep(). All made possible by the recent switch to using a rwlock as
the exclusive pipe lock.
ok visa@
|
|
|
|
|
|
|
| |
pattern more similar to pipe_read(). This also eliminates two races
caused by relocking.
ok visa@
|
|
|
|
|
|
| |
preparation for further refactoring.
ok cheloha@ mpi@ visa@
|
|
|
|
|
|
| |
towards unlocking pipes.
ok cheloha@ mpi@ visa@
|
|
|
|
|
|
| |
rename pipclose() to pipe_destroy(), and return early instead of having the whole code in if-body.
ok claudio@ anton@ visa@ mpi@
|
|
|
|
|
|
|
|
|
|
| |
- in dopipe(), get an already zeroed struct (PR_ZERO) instead of manually initialize each member (in pipe_create)
- rename pipespace() and pipe_free_kmem() to pipe_buffer_realloc() and pipe_buffer_free(): it is more evident that the functions works on the same thing
- in pipe_buffer_free(), return early and move the if-body as function body
No functional change intented.
ok anton@ visa@ mpi@
|
|
|
|
|
|
| |
in the common case.
OK mpi@
|
|
|
|
|
|
|
|
|
|
|
|
| |
PIPE_WANT flag is used for signaling the pipe is about to be run-down.
Pending readers/writers will wakeup the closing thread which is waiting.
We already have PIPE_WANTR, PIPE_WANTW and PIPE_LWANT flags, so
PIPE_WANT isn't really descriptive.
No functional changes intented.
ok visa@ anton@ mpi@
|
|
|
|
|
|
|
|
|
|
|
|
| |
but there is a possible sleeping point between the check (cnt == 0) and
the resize (pipespace() call), resulting resizing on possibly not empty
buffer.
fix it by rechecking the buffer usage once the exclusive lock is hold.
it should be revisited later as part of larger work on pipe(2).
ok visa@ anton@
|
|
|
|
|
|
| |
assert "cpipe->pipe_buffer.cnt == 0" occured whereas it shouldn't.
Reported-by: syzbot+b559fa9d3292c3cb0343@syzkaller.appspotmail.com
|
|
|
|
|
|
| |
initial work from mpi@
ok visa@ mpi@
|
|
|
|
|
|
|
|
|
|
|
| |
unlocks read(2) and write(2) syscalls families, and push the KERNEL_LOCK
deeper in the code path. KERNEL_LOCK is managed per file type in fileops
handlers (fo_read, fo_write, and fo_close). read(2) and write(2) on
socket are KERNEL_LOCK-free.
initial work from mpi@ and ians@
ok mpi@ kettenis@ visa@ ians@
|
|
|
|
|
|
|
| |
of kern_descrip.c r1.177 and sys_pipe.c r1.82, the call always
returned an error.
OK jca@ anton@ mpi@
|
|
|
|
|
|
|
|
| |
handle arg as a process ID if the value is positive and as a process
group ID if the value is negative. In addition, now the signal sending
checks privileges.
OK mpi@
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
|
| |
a scenario where MP-unsafe code gets run without the kernel lock
as a consequence of an unlocked system call.
OK mpi@, kettenis@
|
|
|
|
|
|
|
|
| |
- Update counters atomatically
- Use IPL_MPFLOOR for pipe's pool.
- Grab the KERNEL_LOCK() before calling km_alloc(9) & km_free(9)
Inputs from kettenis@, ok visa@
|
|
|
|
| |
ok visa@, tb@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
|
|
| |
closing a LARVAL file.
Found the hardway by sthen@.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
| |
ok millert@, deraadt@, florian@
|
|
|
|
| |
ok millert@ sthen@
|