Commit Graph

2601 Commits

Author SHA1 Message Date
lukem dafe2b38ba freebsd kqueue implementation 2001-07-06 08:01:32 +00:00
itojun d5b4c4a05d remove a #ifdef __OpenBSD__ segment. 2001-07-03 08:06:40 +00:00
itojun ebdb9f12f3 typo (should we get rid of this portion? 2001-07-02 23:02:11 +00:00
jdolecek 12aa43b8b1 Don't try to be too smart about chunking - if the data size is bigger
than PIPE_CHUNK_SIZE, just transfer first PIPE_CHUNK_SIZE and return short
write, expecting the caller to call us again later (if they need). Previous
behaviour (besides being wrong for O_NONBLOCK reads) hung hbench under some
circumstances and other applications may have similar expectations as hbench.
This might also fix port-vax/13333 by Manuel Bowyer.

Other changes to pipe_direct_write() include:
* return short write (and success) on EOF if any data were already read;
  we return EPIPE on next write(2) call
* simplify error handling, actually handle uvm_loan() failure correctly,
  call pipe_loan_free() on error explicitly and only call uvm_unloan()
  if the address space was _not_ already freed by pipe_loan_free()
  Thanks Chuck Silvers for uvm_unloan() hints :)

Fallthough to common write in pipe_write() if pipe_direct_write()
returns ENOMEM, otherwise always break out immediatelly.
Use uvm_km_valloc_wait() instead uvm_km_valloc() in pipe_loan_alloc().
2001-07-02 20:43:39 +00:00
matt 54ec2573c9 Use consistent types for len. Limit sockarg length to reasonable values. 2001-07-01 20:42:48 +00:00
thorpej 5bdb21d48a Duh, use fd_getfile() in sys_close(). 2001-07-01 18:12:00 +00:00
thorpej ce232da4eb Regen; added Linux-compatible clone(2) system call. 2001-07-01 18:07:33 +00:00
thorpej 9377ba2c38 Linux-compatible clone(2) system call, lifted from the Linux
compatibility module.  Based on patches from Bang Jun-Young <bjy@mogua.org>.
2001-07-01 18:06:11 +00:00
thorpej 7f109318f9 Protect the `pool cache group' pool with splvm(), so that pool caches
can be used by code that runs in interrupt context.
2001-07-01 06:12:20 +00:00
gmcgarry d6182a9e77 In-kernel device configuration manager - allows modification
of device locators at run-time.

Written by Mats O Jansson <moj@stacken.kth.se>.  Reworked by
Jun-ichiro itojun Hagino <itojun@netbsd.org>.
2001-07-01 02:56:20 +00:00
jdolecek 77f0267d21 Use array based upon CTL_VFS_NAMES to get filesystem name for non-VFS_GENERIC
syscall, instead of mountcompatnames[].
Move the extern mountcompatnames[], nmountcompatnames definition to
COMPAT_09 || COMPAT_43 section.
2001-06-28 08:12:08 +00:00
jdolecek 1ff201e042 Only define mountcompatnames[] for COMPAT_09 and COMPAT_43, make the
table actually match state in NetBSD 0.9 (checked against sys/mount.h
rev. 1.11).
The array is not to be modified from now on, comment updated accordingly.
2001-06-28 08:04:18 +00:00
atatat 298956dcf1 If no select collision is needed, try our best to avoid it by clearing
the flag.
2001-06-28 05:45:49 +00:00
thorpej 25f00d4c18 In getnewvnode(), allocate a vnode from the pool with NOWAIT. If
that fails, just try to recycle a vnode.  If we can't allocate or
recycle, issue a warning, sleep a bit, and try the whole thing
again.

This prevents us from blocking forever if we want to use a very large
number of vnodes, but don't have {memory,kva} resources from which to
allocate them.
2001-06-26 22:52:03 +00:00
jdolecek e65c47a67f vfs_rootmountalloc: take advantage of LIST_FOREACH() 2001-06-26 19:14:25 +00:00
thorpej a279b0973b Reduce some complexity in the fault path -- Rather than maintaining
an spl-protected "interrupt safe map" list, simply require that callers
of uvm_fault() never call us in interrupt context (MD code must make
the assertion), and check for interrupt-safe maps in uvmfault_lookup()
before we lock the map.
2001-06-26 17:55:14 +00:00
thorpej a160a0b77c Make the kmemstats limits unsigned, and use unsigned arithmetic
to compute them.  Prevents overflows when using a very large number
of kmem pages.

From chopps@netbsd.org.
2001-06-26 16:02:27 +00:00
wrstuden 716d3ae08f In vcount(), when getting rid of unused aliases, don't vgone one which
has VXLOCK set - it's already being vgoned, most likely by one of our
callers. If we call vgone, we can end up sleeping against ourself
with VXLOCK set - we'll start the race for root.

Pointed out by Love <lha@stacken.kth.se> on tech-kern. Analysis from
Artur Grabowski <art@openbsd.org> via Love.

Should resolve PR kern/13077
2001-06-26 15:51:06 +00:00
thorpej c0b03b60e7 Really only need uvm_extern.h. From Chuck Cranor. 2001-06-25 22:08:52 +00:00
jdolecek 26d45c1101 Back off the sendit()/recvit() change, some have problems with it 2001-06-25 20:46:11 +00:00
jdolecek d865180393 sys_connect(): fix the call to FILE_UNUSE() so that it's done on return, rather
than immediatelly after getsock() call
2001-06-25 19:46:50 +00:00
jdolecek 7f7c60e827 Add 'kernsa' parameter for sendit()/recvit(); if nonzero, msg->msg_name
is supposed to point directly to struct mbuf or struct sockaddr in kernel
space as appropriate, rather than being a pointer to memory in userland.

This is to be used by compat/* when emulation needs to wrap
send{to|msg}(2)/recv{from|msg}(2) and modify the passed struct
sockaddr.
2001-06-25 19:24:02 +00:00
thorpej 99db7959b4 Include <uvm/uvm.h> rather than <uvm/uvm_param.h> directly. 2001-06-25 16:24:31 +00:00
jdolecek 36f8e84443 Move prototype of sysctl_dopipe() from <sys/sysctl.h> to <sys/pipe.h>
and adjust kern/kern_sysctl.c accordingly.
2001-06-21 19:08:36 +00:00
jdolecek 82ce96aaec Don't include opt_new_pipe.h, it's not needed here 2001-06-21 18:59:51 +00:00
jdolecek ad2b5880f0 Oops, fell into rpipe/wpipe trap:
The end we want to do selwakeup() on is not necessarily same as the one
we send SIGIO to. Make pipeselwakeup() accept two parameters and update
callers accordingly. This change fixes behaviour for code, which does
select(2)s on the write end waiting for reader (watched on gv, the problem
manifestated itself as a too long delay before the document was displayed).

Clearly separate the resource free code for FreeBSD
and NetBSD case in pipeclose(), so that it's a bit clearer what's going on.
Also LK_DRAIN the lock before the memory is returned to pipe_pool.

Add missing wakeup() in pipe_write() for PIPE_WANTCLOSE case.
2001-06-21 18:46:22 +00:00
jdolecek 3fd1ca0fc9 Do not include the ELF 'catch all' entry in execsw[] by default, which
used to make ELF binaries unmatched by any signature check to be run under
NetBSD 'emulation'. This causes problems like kern/12253.
The old behaviour is available with option EXEC_ELF_CATCHALL.
2001-06-19 17:58:41 +00:00
christos 0f380fac15 Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.
2001-06-18 02:00:48 +00:00
manu 94a4020177 Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.
2001-06-16 21:29:32 +00:00
jdolecek ee882e3a09 Add port of high performance pipe implementation written by John S. Dyson
for FreeBSD project. Besides huge speed boost compared with socketpair-based
pipes, this implementation also uses pagable kernel memory instead of mbufs.

Significant differences to FreeBSD version:
* uses uvm_loan() facility for direct write
* async/SIGIO handling correct also for sync writer, async reader
* limits settable via sysctl, amountpipekva and nbigpipes available via sysctl
* pipes are unidirectional - this is enforced on file descriptor level
	for now only, the code would be updated to take advantage of it
	eventually
* uses lockmgr(9)-based locks instead of home brew variant
* scatter-gather write is handled correctly for direct write case, data
  is transferred by PIPE_DIRECT_CHUNK bytes maximum, to avoid running out of kva

All FreeBSD/NetBSD specific code is within appropriate #ifdef, in preparation
to feed changes back to FreeBSD tree.

This pipe implementation is optional for now, add 'options NEW_PIPE'
to your kernel config to use it.
2001-06-16 12:00:02 +00:00
jdolecek 664cf935c7 Import FreeBSD sys_pipe.c rev 1.82 for reference (this was used as a base
for the NetBSD port).
2001-06-16 09:21:34 +00:00
jdolecek c57b6d9ba4 Add DTYPE_PIPE (to be used by new pipe implementation) and handle
it accordingly.
2001-06-16 08:28:39 +00:00
thorpej 7660fd850d In check_exec(), don't bother checking P_TRACED along with
MNT_NOSUID, just check MNT_NOSUID to clear the S{U,G}ID bits
in the attributes for the vnode we're about to exec.

We now check P_TRACED right before we would actually perform
the s{u,g}id function in the exec code.

This closes a race condition between exec of a setuid binary
and ptrace(2).
2001-06-15 17:24:19 +00:00
thorpej 80cc38a1af Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads.  What we do is stick descriptors in the table, but
mark them as "larval".  This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again.  When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
2001-06-14 20:32:41 +00:00
nathanw 9e8fb68348 The trace_req() function is a no-op; garbage collect it. 2001-06-13 16:06:27 +00:00
tron 848a0e68f6 Lower interrupt priortiy properly if setting the setting the kernel time
is denied in a securelevel above 1. This fixes PR kern/13158.
2001-06-11 07:07:12 +00:00
mrg 7a84fc0483 use real \n's copyright[]; avoids gcc 3.0-prerelease warnings. 2001-06-08 12:53:30 +00:00
thorpej d9b3317e3e Rework fdalloc() even further: split fdalloc() into fdalloc() and
fdexpand().  The former will return ENOSPC if there is not space
in the current filedesc table.  The latter performs the expansion
of the filedesc table.  This means that fdalloc() won't ever block,
and it gives callers an opportunity to clean up before the
potentially-blocking fdexpand() call.

Update all fdalloc() callers to deal with the need-to-fdexpand() case.

Rewrite unp_externalize() to use fdalloc() and fdexpand() in a
safe way, using an algorithm suggested by Bill Sommerfeld:
- Use a temporary array of integers to hold the new filedesc table
  indexes.  This allows us to repeat the loop if necessary.
- Loop through the array of file *'s, assigning them to filedesc table
  slots.  If fdalloc() indicates expansion is necessary, undo the
  assignments we've done so far, expand, and retry the whole process.
- Once all file *'s have been assigned to slots, update the f_msgcount
  and unp_rights counters.
- Right before we return, copy the temporary integer array to the message
  buffer, and trim the length as before.
Note that once locking is added to the filedesc array, this entire
operation will be `atomic', in that the lock will be held while
file *'s are assigned to embryonic table slots, thus preventing anything
else from using them.
2001-06-07 01:29:16 +00:00
mrg 1ce89f683e in coredump() remove the COMPAT_NETBSD32 #ifdef, and replace it with a hook.
move coredump32() into compat/netbsd32.
2001-06-06 21:37:19 +00:00
thorpej c55795d055 Change fdalloc() to return ERESTART if we had to reallocate the
descriptor array, which may have blocked.  Change callers of
fdalloc() to restart whatever they\'re doing if this condition
happens.  (XXX unp_externalize() needs some work, but that will
be tackled later.)

Change finishdup() to close the descriptor in the `new\' slot if
one exists, and change sys_dup2() accordingly.

Closes a race condition when using kernel-assisted user threads.

While here, garbage-collect UF_MAPPED -- it is not used anywhere.
2001-06-06 17:00:00 +00:00
thorpej f1c14428bb Do the reentrancy checking if POOL_DIAGNOSTIC, not DIAGNOSTIC. Prevents
ABI change for diagnostic vs. non-diagnostic kernels.
2001-06-05 18:51:03 +00:00
mrg b49770c009 add a DEBUG for why the lkm entry point failed. 2001-06-05 12:36:08 +00:00
thorpej e93d1531c2 Avoid a sleeping malloc call while holding the spechash_slock.
XXX This is kinda gross, but prevents complete lossage on an
XXX MP system.
From Bill Sommerfeld.
2001-06-05 04:42:05 +00:00
thorpej 47c29f3cbe Assert that no locks are held if we're called with PR_WAITOK.
From Bill Sommerfeld.
2001-06-05 04:40:39 +00:00
thorpej 2fbef8e269 Assert that no locks are held if we're called with EX_WAITSPACE.
From Bill Sommerfeld.
2001-06-05 04:39:56 +00:00
thorpej 67a875a8c9 Assert that no locks are held if we're called with M_WAITOK. 2001-06-05 04:39:02 +00:00
thorpej 31769952ca Add a simple_lock_only_held() LOCKDEBUG routine, which allows code
to assert that exactly zero or one (and a specific one) locks are
held.

From Bill Sommerfeld.
2001-06-05 04:38:08 +00:00
chs 821ec03ed9 replace vm_map{,_entry}_t with struct vm_map{,_entry} *. 2001-06-02 18:09:08 +00:00
lukem d84d2c6c85 add missing #include "opt_kgdb.h" 2001-05-30 15:24:23 +00:00
mrg 09cf52ad81 regen. 2001-05-30 11:48:07 +00:00