OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.146 / (download) - annotate - [select for diffs], Tue May 9 14:22:17 2023 UTC (13 months 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.145: +8 -4 lines
Diff to previous 1.145 (colored)

Don't return EPIPE from pipe kqfilter

Proceed with the registration of an EVFILT_WRITE filter even if the
pipe's other end has been closed, instead of failing with error EPIPE.
The filter will trigger immediately. This reduces the possible outcomes
when a kevent(2) call and a close(2) call race on the different ends
of a pipe.

This fixes a failure of lang/ghc unit test as reported by gnezdo@.

OK gnezdo@ mpi@

Revision 1.145 / (download) - annotate - [select for diffs], Sun Feb 12 10:41:00 2023 UTC (15 months, 4 weeks ago) by mvs
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.144: +8 -8 lines
Diff to previous 1.144 (colored)

Rename pipeselwakeup() to pipe_wakeup(). It doesn't call selwakeup()
anymore, so do it to be consistent with similar *wakeup() functions.

No functional changes.

ok visa@

Revision 1.144 / (download) - annotate - [select for diffs], Fri Feb 10 14:34:17 2023 UTC (16 months ago) by visa
Branch: MAIN
Changes since 1.143: +2 -2 lines
Diff to previous 1.143 (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.143 / (download) - annotate - [select for diffs], Mon Dec 5 23:18:37 2022 UTC (18 months ago) by deraadt
Branch: MAIN
Changes since 1.142: +2 -2 lines
Diff to previous 1.142 (colored)

zap a pile of dangling tabs

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

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

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

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

OK jsg@

Revision 1.140 / (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.139: +1 -44 lines
Diff to previous 1.139 (colored)

Remove unused struct fileops field fo_poll and callbacks.

OK mpi@

Revision 1.139 / (download) - annotate - [select for diffs], Mon May 30 14:06:16 2022 UTC (2 years ago) by visa
Branch: MAIN
Changes since 1.138: +2 -7 lines
Diff to previous 1.138 (colored)

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

Recommit the reverted change selectively so that only pipes are
affected. Leave sockets untouched for now.

Revision 1.138 / (download) - annotate - [select for diffs], Mon May 9 14:49:55 2022 UTC (2 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.137: +7 -2 lines
Diff to previous 1.137 (colored)

Revert "Replace selwakeup() with KNOTE() in pipe and socket event activation."

The commit caused hangs with NFS.

Reported by ajacoutot@ and naddy@

Revision 1.137 / (download) - annotate - [select for diffs], Fri May 6 13:09:41 2022 UTC (2 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.136: +2 -7 lines
Diff to previous 1.136 (colored)

Replace selwakeup() with KNOTE() in pipe and socket event activation.

OK mpi@

Revision 1.136 / (download) - annotate - [select for diffs], Sun Feb 13 13:05:51 2022 UTC (2 years, 3 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.135: +3 -9 lines
Diff to previous 1.135 (colored)

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

Revision 1.135 / (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.134: +2 -2 lines
Diff to previous 1.134 (colored)

Rename knote_modify() to knote_assign()

This avoids verb overlap with f_modify.

Revision 1.134 / (download) - annotate - [select for diffs], Sat Feb 12 14:07:26 2022 UTC (2 years, 3 months ago) by visa
Branch: MAIN
Changes since 1.133: +19 -114 lines
Diff to previous 1.133 (colored)

Reduce code duplication in pipe event filters

Use the f_event callback for checking event state within the pipe
event filters. This enables the same f_modify and f_process functions
to handle the different filter types.

OK anton@

Revision 1.133 / (download) - annotate - [select for diffs], Mon Dec 13 14:56:55 2021 UTC (2 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.132: +7 -6 lines
Diff to previous 1.132 (colored)

Revise EVFILT_EXCEPT filters

Restrict the circumstances where EVFILT_EXCEPT filters trigger:
* when out-of-band data is present and NOTE_OOB is requested.
* when the channel is fully closed and consumer is poll(2).

This should clarify the logic and suppress events that kqueue-based
poll(2) does not except.

OK mpi@

Revision 1.132 / (download) - annotate - [select for diffs], Mon Dec 13 14:54:22 2021 UTC (2 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.131: +6 -1 lines
Diff to previous 1.131 (colored)

Prevent kevent(2) use of EVFILT_EXCEPT with FIFOs and pipes

Currently, the only intended direct usage of the EVFILT_EXCEPT filter
is with NOTE_OOB to detect out-of-band data in ptys and sockets.
NOTE_OOB does not apply to FIFOs or pipes. Prevent the user from
registering the filter with these file types. The filter code is for
the kernel's internal use.

OK mpi@

Revision 1.131 / (download) - annotate - [select for diffs], Wed Dec 8 13:03:52 2021 UTC (2 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.130: +6 -1 lines
Diff to previous 1.130 (colored)

Fix select(2) exceptfds handling of FIFOs and pipes

Prevent select(2) from indicating an exceptional condition when the
other end of a FIFO or pipe is closed.

Originally, select(2) returned an exceptfds event only with a pty or
socket that has out-of-band data pending. millert@ says that OpenBSD
diverged from this by accident when poll(2) and select(2) were changed
to use the same backend code in year 2003.

OK millert@

Revision 1.130 / (download) - annotate - [select for diffs], Tue Dec 7 14:06:16 2021 UTC (2 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.129: +78 -1 lines
Diff to previous 1.129 (colored)

Add EVFILT_EXCEPT filter for pipes

The kqueue-based select(2) needs the filter to replicate the old
exceptfds behaviour. The upcoming new poll(2) code will use the filter
for POLLHUP condition checking when the events bitmap is clear of
read/write events.

OK anton@

Revision 1.129 / (download) - annotate - [select for diffs], Sun Oct 24 06:59:54 2021 UTC (2 years, 7 months ago) by visa
Branch: MAIN
Changes since 1.128: +102 -26 lines
Diff to previous 1.128 (colored)

Make pipe event filters MP-safe

Add the missing f_modify and f_process callbacks so that pipe_lock
serializes pipe knote handling. As pipe klist locking is already in
place, pipe event filters should now be MP-safe.

This uses write locking everywhere in the callbacks for simplicity.
There is not much multiple-readers parallelism to utilize.

OK mpi@ anton@

Revision 1.128 / (download) - annotate - [select for diffs], Fri Oct 22 15:16:50 2021 UTC (2 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.127: +6 -17 lines
Diff to previous 1.127 (colored)

Revert "Preserve select(2) semantics when the other end of the pipe is gone".

The logic to emulate the current poll/select behavior is better implemented
at the syscall layer and not in the kqueue backend.

Discussed with deraadt@, ok anton@

Revision 1.127 / (download) - annotate - [select for diffs], Fri Oct 22 05:00:26 2021 UTC (2 years, 7 months ago) by anton
Branch: MAIN
Changes since 1.126: +17 -6 lines
Diff to previous 1.126 (colored)

Preserve pipe select(2) semantics when the other end of the pipe is gone.
In preparation for implementing select(2) on top of kqueue.

ok mpi@

Revision 1.126 / (download) - annotate - [select for diffs], Wed Dec 30 17:02:32 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.125: +15 -5 lines
Diff to previous 1.125 (colored)

Set klist lock for pipes.

OK anton@, mpi@

Revision 1.125 / (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.124: +4 -4 lines
Diff to previous 1.124 (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.124 / (download) - annotate - [select for diffs], Fri Dec 11 14:17:35 2020 UTC (3 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.123: +7 -18 lines
Diff to previous 1.123 (colored)

Simplify filt_pipedetach()

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@

Revision 1.123 / (download) - annotate - [select for diffs], Mon Jun 29 18:23:18 2020 UTC (3 years, 11 months ago) by anton
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.122: +55 -52 lines
Diff to previous 1.122 (colored)

Bring back revision 1.122 with a fix preventing a use-after-free by
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@

Revision 1.122 / (download) - annotate - [select for diffs], Fri Jun 19 02:08:48 2020 UTC (3 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.121: +50 -52 lines
Diff to previous 1.121 (colored)

backout pipe change, it crashes some arch

Revision 1.121 / (download) - annotate - [select for diffs], Wed Jun 17 18:29:28 2020 UTC (3 years, 11 months ago) by anton
Branch: MAIN
Changes since 1.120: +53 -51 lines
Diff to previous 1.120 (colored)

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.

ok mpi@ visa@

Revision 1.120 / (download) - annotate - [select for diffs], Mon Jun 15 15:29:40 2020 UTC (3 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.119: +5 -1 lines
Diff to previous 1.119 (colored)

Set __EV_HUP when the conditions matching poll(2)'s POLLUP are found.

This is only done in poll-compatibility mode, when __EV_POLL is set.

ok visa@, millert@

Revision 1.119 / (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.118: +5 -5 lines
Diff to previous 1.118 (colored)

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

OK mpi@, anton@

Revision 1.118 / (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.117: +3 -3 lines
Diff to previous 1.117 (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.117 / (download) - annotate - [select for diffs], Sun Feb 16 07:59:08 2020 UTC (4 years, 3 months ago) by anton
Branch: MAIN
Changes since 1.116: +5 -5 lines
Diff to previous 1.116 (colored)

Unconditionally acquiring a write lock in pipe_ioctl() is quite
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@

Revision 1.116 / (download) - annotate - [select for diffs], Fri Feb 14 14:32:44 2020 UTC (4 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.115: +5 -8 lines
Diff to previous 1.115 (colored)

Push the KERNEL_LOCK() insidge pgsigio() and selwakeup().

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@

Revision 1.115 / (download) - annotate - [select for diffs], Sat Feb 1 15:52:34 2020 UTC (4 years, 4 months ago) by anton
Branch: MAIN
Changes since 1.114: +6 -3 lines
Diff to previous 1.114 (colored)

Back out previous. Nothing wrong with the diff per se but I should have
asked for more oks; my bad!

Revision 1.114 / (download) - annotate - [select for diffs], Sat Feb 1 15:06:21 2020 UTC (4 years, 4 months ago) by anton
Branch: MAIN
Changes since 1.113: +3 -6 lines
Diff to previous 1.113 (colored)

Grab the kernel lock in pgsigio() as it's strictly needed while
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@

Revision 1.113 / (download) - annotate - [select for diffs], Sun Jan 12 09:18:39 2020 UTC (4 years, 4 months ago) by anton
Branch: MAIN
Changes since 1.112: +2 -5 lines
Diff to previous 1.112 (colored)

condense comment

Revision 1.112 / (download) - annotate - [select for diffs], Sun Jan 12 09:16:57 2020 UTC (4 years, 4 months ago) by anton
Branch: MAIN
Changes since 1.111: +11 -11 lines
Diff to previous 1.111 (colored)

Get rid of redundant parenthesis.

ok millert@ ratchov@ visa@

Revision 1.111 / (download) - annotate - [select for diffs], Thu Jan 9 18:54:33 2020 UTC (4 years, 5 months ago) by anton
Branch: MAIN
Changes since 1.110: +83 -60 lines
Diff to previous 1.110 (colored)

Replace the global pipe_lock with a more fine-grained lock per pipe
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@

Revision 1.110 / (download) - annotate - [select for diffs], Wed Jan 8 16:27:41 2020 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.109: +6 -8 lines
Diff to previous 1.109 (colored)

Unify handling of ioctls FIOSETOWN/SIOCSPGRP/TIOCSPGRP and
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@

Revision 1.109 / (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.108: +2 -2 lines
Diff to previous 1.108 (colored)

Constify instances of struct fileops.

OK anton@, mpi@, bluhm@

Revision 1.108 / (download) - annotate - [select for diffs], Sat Jan 4 09:38:27 2020 UTC (4 years, 5 months ago) by anton
Branch: MAIN
Changes since 1.107: +4 -6 lines
Diff to previous 1.107 (colored)

Eliminate some minor differences between pipe_read() and pipe_write():

* Sort local variables by size, name
* No need to initialize error in pipe_write()

ok millert@ visa@

Revision 1.107 / (download) - annotate - [select for diffs], Fri Jan 3 15:18:02 2020 UTC (4 years, 5 months ago) by anton
Branch: MAIN
Changes since 1.106: +18 -18 lines
Diff to previous 1.106 (colored)

Rename the pipe I/O lock routines for improved clarity. This is just a
mere preparation for introducing a dedicated lock per pipe pair.

ok mpi@ visa@

Revision 1.106 / (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.105: +14 -5 lines
Diff to previous 1.105 (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.105 / (download) - annotate - [select for diffs], Fri Dec 27 09:29:50 2019 UTC (4 years, 5 months ago) by anton
Branch: MAIN
Changes since 1.104: +7 -12 lines
Diff to previous 1.104 (colored)

Remove the kernel lock in pipe read and write routines since everything
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@

Revision 1.104 / (download) - annotate - [select for diffs], Wed Dec 25 09:46:09 2019 UTC (4 years, 5 months ago) by anton
Branch: MAIN
Changes since 1.103: +13 -40 lines
Diff to previous 1.103 (colored)

Condense a few multi line comments into single line ones. While here
turn them into proper sentences. Gets rid of 27 lines in total.

Revision 1.103 / (download) - annotate - [select for diffs], Wed Dec 25 09:32:01 2019 UTC (4 years, 5 months ago) by anton
Branch: MAIN
Changes since 1.102: +53 -33 lines
Diff to previous 1.102 (colored)

Protect remaining fields of `struct pipe' using the pipe_lock. In order
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@

Revision 1.102 / (download) - annotate - [select for diffs], Thu Dec 19 18:53:37 2019 UTC (4 years, 5 months ago) by anton
Branch: MAIN
Changes since 1.101: +79 -26 lines
Diff to previous 1.101 (colored)

Start protecting the pipe_peer member of `struct pipe' using the
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@

Revision 1.101 / (download) - annotate - [select for diffs], Fri Nov 29 15:17:28 2019 UTC (4 years, 6 months ago) by anton
Branch: MAIN
Changes since 1.100: +2 -3 lines
Diff to previous 1.100 (colored)

add missing parens around return expression and zap empty line

Revision 1.100 / (download) - annotate - [select for diffs], Fri Nov 29 15:15:10 2019 UTC (4 years, 6 months ago) by anton
Branch: MAIN
Changes since 1.99: +54 -24 lines
Diff to previous 1.99 (colored)

Start protecting the pipe_busy field of struct pipe using a global
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@

Revision 1.99 / (download) - annotate - [select for diffs], Tue Nov 19 19:19:28 2019 UTC (4 years, 6 months ago) by anton
Branch: MAIN
Changes since 1.98: +36 -20 lines
Diff to previous 1.98 (colored)

When waiting on pipe I/O, simplify the unlock/relock logic using
rwsleep(). All made possible by the recent switch to using a rwlock as
the exclusive pipe lock.

ok visa@

Revision 1.98 / (download) - annotate - [select for diffs], Mon Nov 11 16:45:46 2019 UTC (4 years, 7 months ago) by anton
Branch: MAIN
Changes since 1.97: +29 -46 lines
Diff to previous 1.97 (colored)

Extended the scope of the pipelock() in pipe_write() making the locking
pattern more similar to pipe_read(). This also eliminates two races
caused by relocking.

ok visa@

Revision 1.97 / (download) - annotate - [select for diffs], Sun Nov 10 08:36:44 2019 UTC (4 years, 7 months ago) by anton
Branch: MAIN
Changes since 1.96: +66 -64 lines
Diff to previous 1.96 (colored)

Invert a conditional in pipe_write() for reduced indent and in
preparation for further refactoring.

ok cheloha@ mpi@ visa@

Revision 1.96 / (download) - annotate - [select for diffs], Sat Nov 9 19:02:31 2019 UTC (4 years, 7 months ago) by anton
Branch: MAIN
Changes since 1.95: +5 -15 lines
Diff to previous 1.95 (colored)

Replace the hand-rolled pipe lock with a rwlock. A necessary first step
towards unlocking pipes.

ok cheloha@ mpi@ visa@

Revision 1.95 / (download) - annotate - [select for diffs], Tue Jul 16 12:16:58 2019 UTC (4 years, 10 months ago) by semarie
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.94: +52 -48 lines
Diff to previous 1.94 (colored)

move the whole `struct pipe' allocation and initialization inside pipe_create()
rename pipclose() to pipe_destroy(), and return early instead of having the whole code in if-body.

ok claudio@ anton@ visa@ mpi@

Revision 1.94 / (download) - annotate - [select for diffs], Mon Jul 15 09:05:46 2019 UTC (4 years, 10 months ago) by semarie
Branch: MAIN
Changes since 1.93: +41 -34 lines
Diff to previous 1.93 (colored)

revisit pipe initialization and buffer management

- 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@

Revision 1.93 / (download) - annotate - [select for diffs], Mon Jul 15 04:11:03 2019 UTC (4 years, 10 months ago) by visa
Branch: MAIN
Changes since 1.92: +10 -7 lines
Diff to previous 1.92 (colored)

Do not relock fdp in fdrelease(). This prevents unnecessary locking
in the common case.

OK mpi@

Revision 1.92 / (download) - annotate - [select for diffs], Sun Jul 14 10:21:11 2019 UTC (4 years, 10 months ago) by semarie
Branch: MAIN
Changes since 1.91: +9 -9 lines
Diff to previous 1.91 (colored)

rename PIPE_WANT to PIPE_WANTD.

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@

Revision 1.91 / (download) - annotate - [select for diffs], Sat Jul 13 06:51:59 2019 UTC (4 years, 11 months ago) by semarie
Branch: MAIN
Changes since 1.90: +3 -2 lines
Diff to previous 1.90 (colored)

pipe_write() do opportunistic buffer resizing, when the buffer is empty.
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@

Revision 1.90 / (download) - annotate - [select for diffs], Tue Jul 9 15:02:15 2019 UTC (4 years, 11 months ago) by semarie
Branch: MAIN
Changes since 1.89: +4 -13 lines
Diff to previous 1.89 (colored)

backout the unlock of pipe(2) and pipe2(2)

assert "cpipe->pipe_buffer.cnt == 0" occured whereas it shouldn't.

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

Revision 1.89 / (download) - annotate - [select for diffs], Tue Jul 9 11:35:06 2019 UTC (4 years, 11 months ago) by semarie
Branch: MAIN
Changes since 1.88: +13 -4 lines
Diff to previous 1.88 (colored)

unlock pipe(2) and pipe2(2) syscalls

initial work from mpi@

ok visa@ mpi@

Revision 1.88 / (download) - annotate - [select for diffs], Sat Jun 22 06:48:25 2019 UTC (4 years, 11 months ago) by semarie
Branch: MAIN
Changes since 1.87: +13 -4 lines
Diff to previous 1.87 (colored)

push the KERNEL_LOCK deeper on read(2) and write(2)

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@

Revision 1.87 / (download) - annotate - [select for diffs], Tue Nov 13 13:02:20 2018 UTC (5 years, 6 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.86: +2 -2 lines
Diff to previous 1.86 (colored)

Fix fcntl(fd, F_GETOWN) with pipes. As a regression
of kern_descrip.c r1.177 and sys_pipe.c r1.82, the call always
returned an error.

OK jca@ anton@ mpi@

Revision 1.86 / (download) - annotate - [select for diffs], Mon Nov 12 16:33:08 2018 UTC (5 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.85: +8 -8 lines
Diff to previous 1.85 (colored)

Utilize sigio with pipes. This makes fcntl(fd, F_SETOWN, arg) correctly
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@

Revision 1.85 / (download) - annotate - [select for diffs], Mon Aug 20 16:00:22 2018 UTC (5 years, 9 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.84: +5 -5 lines
Diff to previous 1.84 (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.84 / (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.83: +3 -1 lines
Diff to previous 1.83 (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.83 / (download) - annotate - [select for diffs], Mon Aug 13 14:35:29 2018 UTC (5 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.82: +23 -16 lines
Diff to previous 1.82 (colored)

Make it possible to run pipe(2) and pipe2(2) mostly w/o KERNEL_LOCK():

- 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@

Revision 1.82 / (download) - annotate - [select for diffs], Tue Jul 10 08:58:50 2018 UTC (5 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.81: +7 -1 lines
Diff to previous 1.81 (colored)

Move socket & pipe specific logic in their ioctl handler.

ok visa@, tb@

Revision 1.81 / (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.80: +8 -5 lines
Diff to previous 1.80 (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.80 / (download) - annotate - [select for diffs], Tue Jun 5 09:29:05 2018 UTC (6 years ago) by mpi
Branch: MAIN
Changes since 1.79: +5 -8 lines
Diff to previous 1.79 (colored)

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

Found the hardway by sthen@.

Revision 1.79 / (download) - annotate - [select for diffs], Sat Jun 2 10:27:43 2018 UTC (6 years ago) by mpi
Branch: MAIN
Changes since 1.78: +8 -5 lines
Diff to previous 1.78 (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.78 / (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.77: +8 -3 lines
Diff to previous 1.77 (colored)

Convert 'struct fileops' definitions to C99.

ok millert@, deraadt@, florian@

Revision 1.77 / (download) - annotate - [select for diffs], Tue Jan 2 06:38:45 2018 UTC (6 years, 5 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.76: +2 -1 lines
Diff to previous 1.76 (colored)

Stop assuming <sys/file.h> will pull in fcntl.h when _KERNEL is defined.

ok millert@ sthen@

Revision 1.76 / (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_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.75: +6 -9 lines
Diff to previous 1.75 (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.75 / (download) - annotate - [select for diffs], Sat Oct 8 02:16:43 2016 UTC (7 years, 8 months ago) by guenther
Branch: MAIN
Changes since 1.74: +8 -1 lines
Diff to previous 1.74 (colored)

Add ktracing of the fds returned by pipe() and socketpair()

ok deraadt@

Revision 1.74 / (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.73: +3 -4 lines
Diff to previous 1.73 (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.73 / (download) - annotate - [select for diffs], Tue Aug 30 07:40:35 2016 UTC (7 years, 9 months ago) by dlg
Branch: MAIN
Changes since 1.72: +2 -1 lines
Diff to previous 1.72 (colored)

pool_setipl

ok natano@

Revision 1.72 / (download) - annotate - [select for diffs], Fri Jan 15 18:10:48 2016 UTC (8 years, 4 months ago) by stefan
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.71: +9 -10 lines
Diff to previous 1.71 (colored)

Convert to uiomove(); from Martin Natano

ok millert@

Revision 1.71 / (download) - annotate - [select for diffs], Wed Jan 6 17:59:30 2016 UTC (8 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.70: +11 -12 lines
Diff to previous 1.70 (colored)

remove unnecessary casts where the incoming type is void *.

Revision 1.70 / (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.69: +1 -5 lines
Diff to previous 1.69 (colored)

remove stale lint annotations

Revision 1.69 / (download) - annotate - [select for diffs], Tue Feb 10 21:56:10 2015 UTC (9 years, 4 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.68: +4 -4 lines
Diff to previous 1.68 (colored)

First step towards making uiomove() take a size_t size argument:
- rename uiomove() to uiomovei() and update all its users.
- introduce uiomove(), which is similar to uiomovei() but with a size_t.
- rewrite uiomovei() as an uiomove() wrapper.
ok kettenis@

Revision 1.68 / (download) - annotate - [select for diffs], Fri Dec 19 05:59:21 2014 UTC (9 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.67: +3 -3 lines
Diff to previous 1.67 (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.67 / (download) - annotate - [select for diffs], Sun Sep 28 18:52:04 2014 UTC (9 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.66: +4 -4 lines
Diff to previous 1.66 (colored)

Replace uvm_km_alloc(9) and uvm_km_free(9) with the equivalent km_alooc(9)
and km_free(9) calls.

ok tedu@, mlarkin@

Revision 1.66 / (download) - annotate - [select for diffs], Sun Aug 31 01:42:36 2014 UTC (9 years, 9 months ago) by guenther
Branch: MAIN
Changes since 1.65: +31 -5 lines
Diff to previous 1.65 (colored)

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC.  Includes SOCK_NONBLOCK support.

ok matthew@

Revision 1.65 / (download) - annotate - [select for diffs], Fri Jan 24 06:00:01 2014 UTC (10 years, 4 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.64: +7 -4 lines
Diff to previous 1.64 (colored)

Copy timespecs member by member in fo_stat callback functions, to avoid
leaking values in the padding bytes on LP64.  Also, vn_stat() was lacking
the zero-fill to clean its padding.

ok kettenis@ deraadt@ phessler@

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

bzero -> memset

Revision 1.63 / (download) - annotate - [select for diffs], Sun May 6 09:45:26 2012 UTC (12 years, 1 month ago) by mikeb
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.62: +8 -9 lines
Diff to previous 1.62 (colored)

take a file descriptor table lock after allocating pipe structures
and buffers;  ok guenther

Revision 1.62 / (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.61: +3 -3 lines
Diff to previous 1.61 (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.61 / (download) - annotate - [select for diffs], Fri Jul 8 19:00:09 2011 UTC (12 years, 11 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.60: +2 -5 lines
Diff to previous 1.60 (colored)

keep the fdplock around copyout in pipe.  ok matthew

Revision 1.60 / (download) - annotate - [select for diffs], Fri Jul 8 05:01:27 2011 UTC (12 years, 11 months ago) by matthew
Branch: MAIN
Changes since 1.59: +18 -9 lines
Diff to previous 1.59 (colored)

Remove the sys_opipe() kernel entry point.  sys_pipe() is the future.

While here, switch compat_linux to just use sys_pipe() rather than
incorrectly wrapping sys_opipe().

ok tedu@, miod@

Revision 1.59 / (download) - annotate - [select for diffs], Fri May 27 08:53:15 2011 UTC (13 years ago) by nicm
Branch: MAIN
Changes since 1.58: +6 -5 lines
Diff to previous 1.58 (colored)

Fix the return values from pipe_kqfilter - kqfilters should return an
errno not 0/1.

ok guenther

Revision 1.58 / (download) - annotate - [select for diffs], Thu Jan 14 23:12:11 2010 UTC (14 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.57: +2 -2 lines
Diff to previous 1.57 (colored)

fix typos in comments, no code changes;
from Brad Tilley <brad at 16systems dot com>;
ok oga@

Revision 1.57 / (download) - annotate - [select for diffs], Mon Nov 9 17:53:39 2009 UTC (14 years, 7 months ago) by nicm
Branch: MAIN
Changes since 1.56: +3 -3 lines
Diff to previous 1.56 (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.56 / (download) - annotate - [select for diffs], Fri Oct 30 18:03:34 2009 UTC (14 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.55: +1 -2 lines
Diff to previous 1.55 (colored)

pipeclose() calls pileseltimeout() which does the KNOTE(); therefore calling
KNOTE() a second time is not needed (and perhaps bad)
ok claudio millert

Revision 1.55 / (download) - annotate - [select for diffs], Thu Jan 29 22:08:45 2009 UTC (15 years, 4 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.54: +4 -4 lines
Diff to previous 1.54 (colored)

Switch struct stat's timespec members to the names standardized in
POSIX 1003.1-2008, with compatibility macros for the names used in
previous version of OpenBSD.  Update all the references in the
kernel to use the new, standard member names.

ok'ed by miod@, otto@; ports build test by naddy@

Revision 1.54 / (download) - annotate - [select for diffs], Fri Jul 11 14:12:57 2008 UTC (15 years, 11 months ago) by blambert
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.53: +7 -7 lines
Diff to previous 1.53 (colored)

de-__inline a trio of functions to shave some space.

ok art@

Revision 1.53 / (download) - annotate - [select for diffs], Wed Nov 28 15:19:43 2007 UTC (16 years, 6 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.52: +4 -4 lines
Diff to previous 1.52 (colored)

When updating the timestamps on pipes, use getnanotime() instead of more
accurate but more expensive nanotime(), the loss of precision shouldn't matter.
Inspired from the other *BSD which did a similar change.

ok tedu@ millert@ henning@ deraadt@

Revision 1.52 / (download) - annotate - [select for diffs], Tue Aug 7 11:30:53 2007 UTC (16 years, 10 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.51: +3 -2 lines
Diff to previous 1.51 (colored)

Correctly deal with EOF on pipe wrt kqueue.  Based on a fix present
in FreeBSD and NetBSD.  OK art@ beck@

Revision 1.51 / (download) - annotate - [select for diffs], Fri Nov 17 09:21:52 2006 UTC (17 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.50: +2 -2 lines
Diff to previous 1.50 (colored)

missing punctuation in comments; from bret lambert

Revision 1.50 / (download) - annotate - [select for diffs], Tue Dec 13 10:33:14 2005 UTC (18 years, 6 months ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.49: +16 -47 lines
Diff to previous 1.49 (colored)

ansi/deregister. No binary change.

Revision 1.49 / (download) - annotate - [select for diffs], Thu Jul 22 06:13:08 2004 UTC (19 years, 10 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.48: +2 -2 lines
Diff to previous 1.48 (colored)

remove p arg from fdplock

Revision 1.48 / (download) - annotate - [select for diffs], Wed Jul 21 17:05:40 2004 UTC (19 years, 10 months ago) by art
Branch: MAIN
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

In pipe_read, when the pipelock fails (most likely because we catch a
signal), don't jump to unlocked_error: and do things that we don't need
to do (including messing up the internal state of the pipe). Just return.

ok niklas@ miod@

Revision 1.47 / (download) - annotate - [select for diffs], Thu Jun 24 19:35:24 2004 UTC (19 years, 11 months ago) by tholo
Branch: MAIN
Changes since 1.46: +7 -7 lines
Diff to previous 1.46 (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.23.2.7 / (download) - annotate - [select for diffs], Thu Feb 19 10:56:38 2004 UTC (20 years, 3 months ago) by niklas
Branch: SMP
Changes since 1.23.2.6: +142 -117 lines
Diff to previous 1.23.2.6 (colored) to branchpoint 1.23 (colored) next main 1.24 (colored)

Merge of current from two weeks agointo the SMP branch

Revision 1.46 / (download) - annotate - [select for diffs], Tue Jan 6 04:18:18 2004 UTC (20 years, 5 months ago) by tedu
Branch: MAIN
CVS Tags: SMP_SYNC_B, SMP_SYNC_A, OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.45: +7 -1 lines
Diff to previous 1.45 (colored)

lock filedesc before manipulating.  avoids some rare races.
testing for quite some time by brad + otto

Revision 1.45 / (download) - annotate - [select for diffs], Fri Oct 3 16:38:01 2003 UTC (20 years, 8 months ago) by miod
Branch: MAIN
Changes since 1.44: +106 -82 lines
Diff to previous 1.44 (colored)

Bring several fixes from FreeBSD to our current pipe implementation:
- when allocating or growing a pipe buffer is not possible, do not panic
  but report the error and handle it correctly. (1.73)
- "The pipe_write() code was locking the pipe without busying it first
  in certain cases, and a close() by another process could potentially rip
  the pipe out from under the (blocked) locking operation." (from Al Viro,
  1.81)
- "Remove test in pipe_write() which causes write(2) to return EAGAIN
  on a non-blocking pipe in cases where select(2) returns the file
  descriptor as ready for write. This in turns causes libc_r, for
  one, to busy wait in such cases.
  Note: it is a quick performance fix, a more complex fix might be
  required in case this turns out to have unexpected side effects."
  (1.141)

Revision 1.44 / (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.43: +32 -37 lines
Diff to previous 1.43 (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.40.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.40.2.1: +18 -16 lines
Diff to previous 1.40.2.1 (colored) to branchpoint 1.40 (colored) next main 1.41 (colored)

Sync UBC branch to -current

Revision 1.23.2.6 / (download) - annotate - [select for diffs], Thu Mar 28 11:43:04 2002 UTC (22 years, 2 months ago) by niklas
Branch: SMP
Changes since 1.23.2.5: +13 -13 lines
Diff to previous 1.23.2.5 (colored) to branchpoint 1.23 (colored)

Merge in -current from about a week ago

Revision 1.43 / (download) - annotate - [select for diffs], Thu Mar 14 01:27:04 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: UBC_SYNC_B, UBC_SYNC_A, OPENBSD_3_4_BASE, OPENBSD_3_4, OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2, OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.42: +14 -14 lines
Diff to previous 1.42 (colored)

First round of __P removal in sys

Revision 1.23.2.5 / (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.23.2.4: +5 -4 lines
Diff to previous 1.23.2.4 (colored) to branchpoint 1.23 (colored)

Merge in trunk

Revision 1.42 / (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.41: +5 -3 lines
Diff to previous 1.41 (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.40.2.1 / (download) - annotate - [select for diffs], Thu Jan 31 22:55:41 2002 UTC (22 years, 4 months ago) by niklas
Branch: UBC
Changes since 1.40: +2 -3 lines
Diff to previous 1.40 (colored)

Merge in -current, builds on i386, otherwise untested

Revision 1.41 / (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.40: +2 -3 lines
Diff to previous 1.40 (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.23.2.4 / (download) - annotate - [select for diffs], Tue Nov 13 23:04:23 2001 UTC (22 years, 7 months ago) by niklas
Branch: SMP
Changes since 1.23.2.3: +1 -2 lines
Diff to previous 1.23.2.3 (colored) to branchpoint 1.23 (colored)

merge in -current

Revision 1.40 / (download) - annotate - [select for diffs], Tue Nov 6 19:53:20 2001 UTC (22 years, 7 months ago) by miod
Branch: MAIN
CVS Tags: UBC_BASE
Branch point for: UBC
Changes since 1.39: +1 -2 lines
Diff to previous 1.39 (colored)

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)

Revision 1.23.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.23.2.2: +4 -11 lines
Diff to previous 1.23.2.2 (colored) to branchpoint 1.23 (colored)

Sync the SMP branch to something just after 3.0

Revision 1.39 / (download) - annotate - [select for diffs], Fri Oct 26 12:03:27 2001 UTC (22 years, 7 months ago) by art
Branch: MAIN
Changes since 1.38: +3 -1 lines
Diff to previous 1.38 (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.38 / (download) - annotate - [select for diffs], Wed Sep 19 20:50:58 2001 UTC (22 years, 8 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.37: +1 -3 lines
Diff to previous 1.37 (colored)

merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok

Revision 1.37 / (download) - annotate - [select for diffs], Thu Jul 5 07:15:07 2001 UTC (22 years, 11 months ago) by art
Branch: MAIN
Changes since 1.36: +2 -9 lines
Diff to previous 1.36 (colored)

Get rid of unnecessary includes.

Revision 1.23.2.2 / (download) - annotate - [select for diffs], Wed Jul 4 10:48:34 2001 UTC (22 years, 11 months ago) by niklas
Branch: SMP
Changes since 1.23.2.1: +180 -143 lines
Diff to previous 1.23.2.1 (colored) to branchpoint 1.23 (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.36 / (download) - annotate - [select for diffs], Wed Jun 27 04:49:46 2001 UTC (22 years, 11 months ago) by art
Branch: MAIN
Changes since 1.35: +1 -36 lines
Diff to previous 1.35 (colored)

remove old vm

Revision 1.35 / (download) - annotate - [select for diffs], Sat Jun 23 06:34:37 2001 UTC (22 years, 11 months ago) by art
Branch: MAIN
Changes since 1.34: +6 -6 lines
Diff to previous 1.34 (colored)

pool_init, not pool_create

Revision 1.34 / (download) - annotate - [select for diffs], Sat Jun 23 06:09:16 2001 UTC (22 years, 11 months ago) by art
Branch: MAIN
Changes since 1.33: +2 -1 lines
Diff to previous 1.33 (colored)

pipe_stat isn't referenced from outside sys_pipe.c anymore

Revision 1.33 / (download) - annotate - [select for diffs], Sat Jun 23 06:04:34 2001 UTC (22 years, 11 months ago) by art
Branch: MAIN
Changes since 1.32: +10 -6 lines
Diff to previous 1.32 (colored)

Add pipe_init, call it from main, move the pool initialization into it.

Revision 1.26.2.1 / (download) - annotate - [select for diffs], Thu Jun 7 04:45:04 2001 UTC (23 years ago) by jason
Branch: OPENBSD_2_9
Changes since 1.26: +17 -3 lines
Diff to previous 1.26 (colored) next main 1.27 (colored)

Pull in patch from current:
Fix (provos):
fix kqueue EVFILT_WRITE; okay art@

Revision 1.32 / (download) - annotate - [select for diffs], Tue Jun 5 18:28:18 2001 UTC (23 years ago) by provos
Branch: MAIN
Changes since 1.31: +17 -3 lines
Diff to previous 1.31 (colored)

fix kqueue EVFILT_WRITE; okay art@

Revision 1.31 / (download) - annotate - [select for diffs], Sat May 26 04:16:08 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.30: +155 -101 lines
Diff to previous 1.30 (colored)

Sync in some improvements from FreeBSD + my own improvements.

 - use pool for allocating pipe structures.
 - use microtime instead of splhigh and time.
 - improve locking.
 - better handling of nonblocking.
 - various efficiency fixes.

Revision 1.23.2.1 / (download) - annotate - [select for diffs], Mon May 14 22:32:43 2001 UTC (23 years, 1 month ago) by niklas
Branch: SMP
Changes since 1.23: +86 -8 lines
Diff to previous 1.23 (colored)

merge in approximately 2.9 into SMP branch

Revision 1.30 / (download) - annotate - [select for diffs], Mon May 14 13:43:53 2001 UTC (23 years, 1 month ago) by art
Branch: MAIN
Changes since 1.29: +1 -4 lines
Diff to previous 1.29 (colored)

gc OLD_PIPE.

Revision 1.29 / (download) - annotate - [select for diffs], Mon May 14 12:38:47 2001 UTC (23 years, 1 month ago) by art
Branch: MAIN
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored)

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

Revision 1.28 / (download) - annotate - [select for diffs], Mon May 14 10:51:26 2001 UTC (23 years, 1 month ago) by art
Branch: MAIN
Changes since 1.27: +6 -3 lines
Diff to previous 1.27 (colored)

More generic arguments to pipe_stat.

Revision 1.27 / (download) - annotate - [select for diffs], Mon May 14 10:35:42 2001 UTC (23 years, 1 month ago) by art
Branch: MAIN
Changes since 1.26: +1 -2 lines
Diff to previous 1.26 (colored)

We already have a prototype for pipe_stat in sys/pipe.h

Revision 1.26 / (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
Branch point for: OPENBSD_2_9
Changes since 1.25: +23 -9 lines
Diff to previous 1.25 (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.25 / (download) - annotate - [select for diffs], Thu Nov 16 20:02:17 2000 UTC (23 years, 6 months ago) by provos
Branch: MAIN
Changes since 1.24: +63 -1 lines
Diff to previous 1.24 (colored)

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

Revision 1.24 / (download) - annotate - [select for diffs], Wed Apr 19 08:34:54 2000 UTC (24 years, 1 month ago) by csapuntz
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8, OPENBSD_2_7_BASE, OPENBSD_2_7
Changes since 1.23: +7 -5 lines
Diff to previous 1.23 (colored)



Change struct file interface methods read and write to pass file offset in
and out.

Make pread/pwrite in netbsd & linux thread safe - which is the whole point
anyway.

Revision 1.23 / (download) - annotate - [select for diffs], Thu Jan 27 18:56:13 2000 UTC (24 years, 4 months ago) by art
Branch: MAIN
CVS Tags: SMP_BASE
Branch point for: SMP
Changes since 1.22: +1 -2 lines
Diff to previous 1.22 (colored)

No need to include sys/vmmeter.h

Revision 1.22 / (download) - annotate - [select for diffs], Thu Nov 25 13:39:38 1999 UTC (24 years, 6 months ago) by art
Branch: MAIN
CVS Tags: kame_19991208
Changes since 1.21: +2 -2 lines
Diff to previous 1.21 (colored)

Annoying unnecessary space.

Revision 1.21 / (download) - annotate - [select for diffs], Sun Nov 21 17:40:26 1999 UTC (24 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.20: +3 -2 lines
Diff to previous 1.20 (colored)

if select returns writable on a pipe, the write should not return
EWOULDBLOCK.  turns out the two checking conditions were not the same,
and a certain use of rsync uncovered the bug by chewing all available
cpu time; fix from art

Revision 1.20 / (download) - annotate - [select for diffs], Fri Oct 29 14:08:49 1999 UTC (24 years, 7 months ago) by art
Branch: MAIN
Changes since 1.19: +4 -4 lines
Diff to previous 1.19 (colored)

Use M_PIPE instead of M_TEMP.

Revision 1.19 / (download) - annotate - [select for diffs], Fri Oct 29 14:01:44 1999 UTC (24 years, 7 months ago) by art
Branch: MAIN
Changes since 1.18: +28 -435 lines
Diff to previous 1.18 (colored)

Remove the "Direct write" code.
We never used it and some parts of it slowed the code down.
Generally clean up the pipe code.

Revision 1.18 / (download) - annotate - [select for diffs], Wed Oct 27 07:38:19 1999 UTC (24 years, 7 months ago) by niklas
Branch: MAIN
Changes since 1.17: +3 -1 lines
Diff to previous 1.17 (colored)

Actually make ASYNC pipes generate SIGIO.

Revision 1.17 / (download) - annotate - [select for diffs], Thu Jul 15 14:07:41 1999 UTC (24 years, 11 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_2_6_BASE, OPENBSD_2_6
Changes since 1.16: +10 -10 lines
Diff to previous 1.16 (colored)

vm_offset_t -> {v,p}addr_t ; vm_size_t -> {v,p}size_t

Revision 1.16 / (download) - annotate - [select for diffs], Tue Jul 13 15:17:50 1999 UTC (24 years, 11 months ago) by provos
Branch: MAIN
Changes since 1.15: +2 -2 lines
Diff to previous 1.15 (colored)

introduce fdremove() to mark a file descriptor as unused. fdremove makes
sure that the fd_freefile hints stay in sync, otherwise free file
descriptors might not be overlooked by fdalloc(); ok millert@

Revision 1.15 / (download) - annotate - [select for diffs], Tue Jun 8 16:05:22 1999 UTC (25 years ago) by deraadt
Branch: MAIN
Changes since 1.14: +1 -29 lines
Diff to previous 1.14 (colored)

better fd leak prevention

Revision 1.14 / (download) - annotate - [select for diffs], Mon Jun 7 20:46:09 1999 UTC (25 years ago) by deraadt
Branch: MAIN
Changes since 1.13: +29 -1 lines
Diff to previous 1.13 (colored)

need seperate sys_pipe() versions, for pipeclose() or soclose() calls

Revision 1.13 / (download) - annotate - [select for diffs], Mon Jun 7 07:17:42 1999 UTC (25 years ago) by deraadt
Branch: MAIN
Changes since 1.12: +2 -2 lines
Diff to previous 1.12 (colored)

replacement pipe() system call; copies data into place inside kernel, so
that EFAULT return value is possible

Revision 1.12 / (download) - annotate - [select for diffs], Mon Jun 7 01:41:01 1999 UTC (25 years ago) by deraadt
Branch: MAIN
Changes since 1.11: +2 -2 lines
Diff to previous 1.11 (colored)

oops, premature commit

Revision 1.11 / (download) - annotate - [select for diffs], Mon Jun 7 01:38:44 1999 UTC (25 years ago) by deraadt
Branch: MAIN
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored)

store NULL in fd_ofiles

Revision 1.10 / (download) - annotate - [select for diffs], Fri Feb 26 05:12:18 1999 UTC (25 years, 3 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_2_5_BASE, OPENBSD_2_5
Changes since 1.9: +21 -2 lines
Diff to previous 1.9 (colored)

kmem allocation changes for uvm

Revision 1.9 / (download) - annotate - [select for diffs], Tue Feb 16 21:27:37 1999 UTC (25 years, 3 months ago) by art
Branch: MAIN
Changes since 1.8: +3 -10 lines
Diff to previous 1.8 (colored)

Move defining of PIPE_NODIRECT to pipe.h and conditionalize more code with it.
This allows this code to compile on sparc.

Revision 1.8 / (download) - annotate - [select for diffs], Thu Nov 6 05:58:21 1997 UTC (26 years, 7 months ago) by csapuntz
Branch: MAIN
CVS Tags: OPENBSD_2_4_BASE, OPENBSD_2_4, OPENBSD_2_3_BASE, OPENBSD_2_3
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)

Updates for VFS Lite 2 + soft update.

Revision 1.7 / (download) - annotate - [select for diffs], Mon Oct 6 20:20:02 1997 UTC (26 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.6: +1 -1 lines
Diff to previous 1.6 (colored)

back out vfs lite2 till after 2.2

Revision 1.6 / (download) - annotate - [select for diffs], Mon Oct 6 15:12:29 1997 UTC (26 years, 8 months ago) by csapuntz
Branch: MAIN
Changes since 1.5: +2 -2 lines
Diff to previous 1.5 (colored)

VFS Lite2 Changes

Revision 1.5 / (download) - annotate - [select for diffs], Mon Feb 24 14:19:58 1997 UTC (27 years, 3 months ago) by niklas
Branch: MAIN
CVS Tags: OPENBSD_2_1_BASE, OPENBSD_2_1
Changes since 1.4: +2 -2 lines
Diff to previous 1.4 (colored)

OpenBSD tags

Revision 1.4 / (download) - annotate - [select for diffs], Sat Oct 12 14:34:42 1996 UTC (27 years, 8 months ago) by niklas
Branch: MAIN
Changes since 1.3: +5 -1 lines
Diff to previous 1.3 (colored)

Correct sys_pipe's 3rd arg type, alpha needs it

Revision 1.3 / (download) - annotate - [select for diffs], Thu Sep 5 12:31:14 1996 UTC (27 years, 9 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_2_0_BASE, OPENBSD_2_0
Changes since 1.2: +3 -2 lines
Diff to previous 1.2 (colored)

compile!

Revision 1.2 / (download) - annotate - [select for diffs], Wed Sep 4 22:23:28 1996 UTC (27 years, 9 months ago) by niklas
Branch: MAIN
Changes since 1.1: +47 -45 lines
Diff to previous 1.1 (colored)

Stylistic cleanup, like removing "static"s, and removing warnings
given by -Wall -Wstrict-prototypes -Wmissing-prototypes

Revision 1.1 / (download) - annotate - [select for diffs], Tue Aug 27 14:47:00 1996 UTC (27 years, 9 months ago) by shawn
Branch: MAIN

New fast pipe(2) from freebsd without fancy vm stuff.

The old pipes can be used with the "OLD_PIPE" config option.

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.