Commit Graph

1954 Commits

Author SHA1 Message Date
thorpej ea8fb3e04a Turn the proclist lock into a read/write spinlock. Update proclist locking
calls to reflect this.  Also, block statclock rather than softclock during
in the proclist locking functions, to address a problem reported on
current-users by Sean Doran.
1999-07-25 06:30:33 +00:00
thorpej 50f9f26fe1 Add a spin lock mode to the lock manager. Provides a read/write
spin lock facility.  Some code and ideas from Ross Harvey.
1999-07-25 06:24:22 +00:00
tron d5442d74c5 Fix NULL pointer access. Patch supplied by Dave Huang in PR kern/8055. 1999-07-24 15:10:02 +00:00
thorpej 014078a731 Garbage collect. 1999-07-22 23:31:07 +00:00
thorpej 2860ae9b30 Add proclist locking where appropriate (forgot to commit this file previously). 1999-07-22 23:00:27 +00:00
thorpej 01a8cffe77 Add a read/write lock to the proclists and PID hash table. Use the
write lock when doing PID allocation, and during the process exit path.
Use a read lock every where else, including within schedcpu() (interrupt
context).  Note that holding the write lock implies blocking schedcpu()
from running (blocks softclock).

PID allocation is now MP-safe.

Note this actually fixes a bug on single processor systems that was probably
extremely difficult to tickle; it was possible that schedcpu() would run
off a bad pointer if the right clock interrupt happened to come in the
middle of a LIST_INSERT_HEAD() or LIST_REMOVE() to/from allproc.
1999-07-22 21:08:30 +00:00
thorpej e8485145c1 Rearrange some code slightly. 1999-07-22 18:28:30 +00:00
thorpej 2715b812d1 Rework the process exit path, in preparation for making process exit
and PID allocation MP-safe.  A new process state is added: SDEAD.  This
state indicates that a process is dead, but not yet a zombie (has not
yet been processed by the process reaper).

SDEAD processes exist on both the zombproc list (via p_list) and deadproc
(via p_hash; the proc has been removed from the pidhash earlier in the exit
path).  When the reaper deals with a process, it changes the state to
SZOMB, so that wait4 can process it.

Add a P_ZOMBIE() macro, which treats a proc in SZOMB or SDEAD as a zombie,
and update various parts of the kernel to reflect the new state.
1999-07-22 18:13:36 +00:00
thorpej 32e1fd0d03 Move the call of cpu_wait() out of the wait4() functions, and into the
body of reaper(), right before the call to uvm_exit().  cpu_wait() must
be done before uvm_exit() because the resources it frees might be located
in the PCB.
1999-07-20 21:54:05 +00:00
chs fce05250f9 more cleanup:
remove simplelockrecurse, lockpausetime and PAUSE():
none of these serve any purpose anymore.
in the LOCKDEBUG functions, expand the splhigh() region to
cover the entire function.  without this there can still be races.
1999-07-19 03:21:11 +00:00
chs 327e64d87b remove simplelockrecurse, it's no longer needed. 1999-07-19 03:17:42 +00:00
thorpej c581bf97c5 A few things to make the Linux clone(2) emulation work a bit better:
- When the exit signal is specified to be 0, don't just assume they
  meant SIGCHLD.  In the Linux world, this appears to mean "don't deliver
  an exit signal at all".
- Simplify P_EXITSIG(); don't check against initproc here, just change
  the exit signal to SIGCHLD if reparenting to initproc.

A very simple clone(2) test program now works, and the MpegTV package
starts, but doesn't run properly yet (I believe there is a separate
bug which keeps it from working properly).
1999-07-15 23:18:41 +00:00
wrstuden a0f2937049 Define VLAYER and make layered fs's set this flag when creating their vnodes.
getnewvnode now checks this bit, and it if's set makes sure a vnode's not
locked before removing it from the free list.

Closes PR 7954 by Alan Barrett <apb@iafrica.com>.
1999-07-15 21:30:31 +00:00
thorpej 5fdbf26214 Regen. 1999-07-12 23:01:47 +00:00
thorpej bee019244f Remove two lines that were apparently added by accident. 1999-07-12 23:01:27 +00:00
kleink dfa5aad003 Regen. 1999-07-12 22:04:00 +00:00
kleink e79a283e47 XSH5: change function signature to `void *sbrk(intptr_t)'. 1999-07-12 21:55:19 +00:00
sommerfeld c4fe7934c5 Fix kern/7944: getcwd permission checking was overly restrictive.
(Don't require start directory to have read permission).
1999-07-11 09:27:23 +00:00
thorpej f9a7668b3f defopt IPSEC and IPSEC_ESP (both into opt_ipsec.h). 1999-07-09 22:57:15 +00:00
wrstuden 379a26972f Modify file systems to deal with struct lock in struct vnode. All leaf
fs's other than nfs use genfs_lock() for locking.

Modify lookup routines to set PDIRUNLOCK when they unlock the parrent.
1999-07-08 01:05:58 +00:00
wrstuden 332bef3064 Regen to reflect WILLPUT & WILLUNLOCK syntax. 1999-07-07 23:33:50 +00:00
wrstuden 99a1c75bcb Update syntax to support WILLUNLOCK and WILLPUT syntax. Change calls which
really vput to indicate that rather than just WILLRELE.
1999-07-07 23:32:50 +00:00
ws 974de8f7f8 Handle misalignment in vmcmd_map_readvn and vmcmd_map_zero correctly. 1999-07-07 20:23:45 +00:00
thorpej 7b3258b6a7 Make the kthread API a bit more friendly to loadable kernel modules. 1999-07-06 21:44:09 +00:00
sommerfeld 140b1ee075 Housecleaning time:
Fix and document naming convention for vnode variables (always use
lvp/lvpp and uvp/uvpp instead of a hash of cvp, vpp, dvpp, pvp, pvpp).

Delete old stale #if 0'ed code at the end.

Change error path code in getcwd_getcache() slightly (merge common
cleanup code; shouldn't affect behavior any).
1999-07-04 20:16:57 +00:00
sommerfeld e303e2ee8b Fix kern/7906: race between unmount and getnewvnode()
mp->mnt_flags & MNT_MWAIT is replaced by mp->mnt_wcnt, and a new mount
flag MNT_GONE is created (reusing the same bit).

In insmntque(), add DIAGNOSTIC check to fail if the filesystem vnode
is being moved to is in the process of being unmounted.

getnewvnode() now protects the list of vnodes active on mp with
vfs_busy()/vfs_unbusy().

To avoid generating spurious errors during a doomed unmount, change
the "wait for unmount to finish" protocol between dounmount() and
vfs_busy().  In vfs_busy(), instead of only sleeping once, sleep until
either MNT_UNMOUNT is clear or MNT_GONE is set; also, maintain a count
of waiters in mp->mnt_wcnt so that dounmount() knows when it's safe to
free mp.

tested by running a "while :; do mount /d1; umount -f /d1; done" loop
against multiple find(1) processes.
1999-07-04 16:20:12 +00:00
sommerfeld 6f57fc7820 fix typo in previous 1999-07-04 06:17:52 +00:00
sommerfeld c7e5c39191 Don't permanently lose the async bit on an failed unmount 1999-07-04 06:16:29 +00:00
wrstuden b101a0685c Make fhopen use FILE_UNUSE, and don't leak file descriptors.
Patch from Jason Thorpe. Also should close PR 7889 from
Assar Westerlund <assar@sics.se> describing this problem.
1999-07-01 18:58:16 +00:00
itojun 118d2b1d4f IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
  data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
  package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
  file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.
1999-07-01 08:12:45 +00:00
itojun 9765602d90 add PR_LISTEN for UNIX domain socket, SOCK_STREAM case. 1999-07-01 07:59:57 +00:00
darrenr cd92b615fa fix sys_accept() to return EOPNOTSUPP for protocols which don't support
listen/accept (PR_LISTEN flag in protosw) and detect obvious faults in
parameters passed.  It is still possible for the address used for copying
the socket information to become invalid between that check and the copyout
so close the connection's allocated fd if the copyout fails so that we can
return EFAULT without allocating an fd and the application not knowing about
it.  Ideally we'd be able to queue the connection back up so a later accept
could retrieve it but unfortunately that's not possible.
1999-07-01 05:56:32 +00:00
is b4b3d042fd Only check for ETXTBSY if the access would otherwise be allowed.
Needed to fix pr4134.
1999-06-30 10:00:06 +00:00
fvdl 811a6162c3 Allow execution of shared objects. This is silly, but is allowed in,
for example, Solaris and Linux, and at least one Linux ldd implementation
even depends on it.
1999-06-29 23:39:06 +00:00
wrstuden 6e06666498 Add fhopen, fhstat, fhstatfs syscalls. Also move getfh in from the nfs
syscall code.
1999-06-29 22:18:47 +00:00
wrstuden a9e728797e regen. 1999-06-29 22:17:39 +00:00
wrstuden d55b282c54 Add fhopen, fhstat, fhstatfs. 1999-06-29 22:15:31 +00:00
ross d13c150e3b include <string.h> for memset(3) when compiling userland test setup 1999-06-27 06:18:33 +00:00
augustss 94b815050e Add powerhooks, i.e., the ability to register a function that will be
called when the machine does a suspend or resume.
XXX Will go away when Jason's kevents come to life.
1999-06-26 08:25:25 +00:00
kleink 7b67bca335 Add compile-time and run-time feature test knobs for the 1003.1 Mapped Files,
Process Memory Locking, Range Memory Locking and Memory Protection options.
1999-06-24 14:18:10 +00:00
sommerfeld c45e268d01 Fix PR7373 for real: Rearrange locking to avoid need for LOCKPARENT in lookup 1999-06-21 05:11:09 +00:00
sommerfeld 8d750c058f regen (no actual change, but comments in the master file changed) 1999-06-21 02:30:53 +00:00
sommerfeld 9bad197221 Correct comment about how LOCKPARENT affects VOP_LOOKUP 1999-06-21 02:28:46 +00:00
christos c029fe53c6 Fix umask inheritance problem introduced by the cwdi changes, whereby
children processes will not inherit the parent's umask but 022.
1999-06-20 08:54:13 +00:00
ragge 5ad2718e7c Add vax to user of device_register. 1999-06-20 00:51:37 +00:00
sommerfeld 1425b5931b Fix PR7761: clip overly large length rather than failing 1999-06-19 18:01:26 +00:00
thorpej bbf19ba181 Um, hi, let's initialize pointers before we use them. 1999-06-17 23:17:45 +00:00
thorpej 12347b2657 Make uvm_vslock() return the error code from uvm_fault_wire(). All places
which use uvm_vslock() should now test the return value.  If it's not
KERN_SUCCESS, wiring the pages failed, so the operation which is using
uvm_vslock() should error out.

XXX We currently just EFAULT a failed uvm_vslock().  We may want to do
more about translating error codes in the future.
1999-06-17 15:47:22 +00:00
thorpej ad528dfdf0 Regen. 1999-06-15 23:29:17 +00:00
thorpej 0cec533f77 Add mlockall at #242 and munlockall at #243. 1999-06-15 23:28:16 +00:00
christos e13d964178 Regen 1999-06-09 04:25:54 +00:00
christos 3f8f92f2b4 Add EXCL keyword as described in tech_kern, and fix comments. Make the
vtrace syscall UNIMPL because it is.
1999-06-09 04:25:30 +00:00
thorpej c146fe969e Regen. 1999-06-08 03:08:32 +00:00
thorpej 8b35c542b5 mincore: caddr_t -> void * 1999-06-08 03:07:39 +00:00
thorpej 84380f9fbe In sosend(), if so_error is set, clear it before returning the error to
the process (i.e. pre-Reno behavior).  The 4.4BSD behavior (introduced
in Reno) caused transient errors to stick incorrectly.

This is from PR #7640 (Havard Eidnes), cross-checked w/ FreeBSD, where
Bill Fenner committed the same fix (as described in a comment in the
Vat sources, by Van Jacobsen).
1999-06-08 02:39:57 +00:00
thorpej 1c5f2999b2 Make sure `olddelta' is a valid pointer before performing the guts of
the adjtime(2) system call.  Fixes PR #7721, Darren Reed.
1999-06-07 22:33:53 +00:00
thorpej d76e7b8c6d Don't pass a nam2blk around at all; just have setroot() and friends reference
dev_name2blk[] directly.  Addresses PR #7622 (ITOH Yasufumi), although
in a different way.
1999-06-07 20:16:08 +00:00
thorpej 4476366369 Make sure the regression test compiles. 1999-06-07 02:25:05 +00:00
pk 62cb666f4a Guard our global resource `phpool' against all interrupts. 1999-06-06 22:20:15 +00:00
pk 0e286f5c1f Guard our global resource `expool' against all interrupts. 1999-06-06 22:14:53 +00:00
thorpej 2c3dc83a64 Keep interrupt-safe maps on an additional queue. In uvm_fault(), if we're
looking up a kernel address, check to see if the address is on this
"interrupt-safe" list.  If so, return failure immediately.  This prevents
a locking screw if a page fault is taken on an interrupt-safe map in or
out of interrupt context.
1999-06-04 23:38:41 +00:00
lukem 5e76cbddfb in humanize_number(), when printing a u_int64_t, use '%qu' (unsigned long long)
instead of '%qd' (long long)
1999-06-02 05:53:56 +00:00
lukem 6a62a9cff3 sanity check bufcache before using it 1999-06-01 00:40:48 +00:00
thorpej e50ef977d1 Don't use a read lock on an intrsafe map; these maps can only use exclusive,
non-sleeping locks.
1999-05-28 19:40:09 +00:00
thorpej 2580d306ab Change the vm_map's "entries_pageable" member to a r/o flags member, which
has PAGEABLE and INTRSAFE flags.  PAGEABLE now really means "pageable",
not "allocate vm_map_entry's from non-static pool", so update all map
creations to reflect that.  INTRSAFE maps are maps that are used in
interrupt context (e.g. kmem_map, mb_map), and thus use the static
map entry pool (XXX as does kernel_map, for now).  This will eventually
change now these maps are locked, as well.
1999-05-26 19:16:28 +00:00
thorpej 701868a6c8 Pass the appropriate access_type to uvm_vslock() for the given physio
operation: B_READ == VM_PROT_READ|VM_PROT_WRITE, B_WRITE == VM_PROT_READ.
1999-05-26 01:08:03 +00:00
thorpej 497248ca55 XXX Pass VM_PROT_NONE to uvm_vslock() as access_type. Why are we even
vslocking here?!  copyout() on its own seems to suffice just about everwhere
else, and it's not like the process is going to exit; it's in a system
call!
1999-05-26 01:07:06 +00:00
tron bb5689beb3 Only attempt to remove symbol table from DDB's lists of symbol tables
if we really loaded one.
1999-05-25 00:16:08 +00:00
thorpej ba2bc023f7 Call the mdcallback immediately after computing bufpages; bufpages may
need to be clipped, and this needs to be done before computing nbuf.
1999-05-21 00:05:12 +00:00
thorpej 3aa41b1b36 Make this actually work if the BUFCACHE option is not specified, by falling
back on the traditional BSD formula of 10% of first 2MB and 5% of remaining.
1999-05-20 20:01:28 +00:00
lukem 091ffad669 MI implementation of allocsys() 1999-05-20 05:59:52 +00:00
lukem 03b1725220 rework format_bytes() into a more generic humanize_number().
implement the former with the latter.
1999-05-20 05:58:19 +00:00
sommerfeld 6c63af182f Delete test code. 1999-05-15 22:37:22 +00:00
sommerfeld c01c0d9453 Revise previous fix:
1) protect socket flags under splsoftnet()
	2) avoid leaking memory on an error
1999-05-15 22:36:34 +00:00
tv fc3f28c6bd Wow, that was much easier than I originally thought. Fix PR kern/7583:
serious race condition in sosend().  Upon closer inspection, the appropriate
flags are checked within splsoftnet() for soreceive(), so no change needed
there.  Also a little KNFing in sosend().
1999-05-15 16:42:48 +00:00
thorpej c10a926030 Allow the caller to specify a stack for the child process. If NULL,
the child inherits the stack pointer from the parent (traditional
behavior).  Like the signal stack, the stack area is secified as
a low address and a size; machine-dependent code accounts for stack
direction.

This is required for clone(2).
1999-05-13 21:58:32 +00:00
thorpej a6c810d72a Fix a (currently) harmless brian-o in last. 1999-05-13 17:28:30 +00:00
thorpej 5d97669cfe Allow an alternate exit signal (i.e. not SIGCHLD) to be delivered to the
parent, specified at fork time.  Specify a new flag to wait4(2), WALTSIG,
to wait for processes which use an alternate exit signal.

This is required for clone(2).
1999-05-13 00:59:03 +00:00
drochner 4a60ccd128 fix 2 problems with subregion allocation:
-a subregion start was ignored if all previous allocations were before
the subregion, reported by Lennart Augustsson in PR kern/7539
-an existing allocation which overlaps the beginning of the subregion
was ignored (ie overlapped) if is is not the last allocation
1999-05-11 11:02:54 +00:00
thorpej 6c37e2b392 Make sure page allocations are counted everywhere that they need to be. 1999-05-10 21:15:42 +00:00
thorpej 4b6d8943c2 Improve the pool allocator's diagnostic helpers, adding the ability to
log on a per-pool basis, reentrancy checking, and dumping various pool
information from DDB.
1999-05-10 21:13:05 +00:00
lukem 719cd63d24 Implement format_bytes(), which pretty prints a given u_int64_t into a
given buffer, and if necessary, reducing the display width of the
number to fit in the buffer by increasing the units (from kilobytes
(2^10) through to exabytes (2^60)).
1999-05-09 13:48:44 +00:00
tv 4c9c896cc8 FILE_UNUSE wasn't updated in the FDSCRIPTS block. 1999-05-07 17:38:41 +00:00
christos e649afd171 Add NTFS for the compat names. 1999-05-06 17:11:04 +00:00
thorpej e3669c3393 Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
1999-05-05 20:01:01 +00:00
thorpej 4913e22a19 Fix alignment problem in the garbage-collection code path. 1999-05-05 19:05:43 +00:00
christos a32f7169fc Align struct timeval time to the same alignment requirements of a quad.
This broke the sparc elf kernel which in microtime uses ldd to load both
words at the same time. The a.out kernel, just got lucky.
1999-05-04 16:16:54 +00:00
sommerfe c0d15c5c7c Count lockmgr locks held by process if LOCKDEBUG || DIAGNOSTIC.
(previously, it was just under LOCKDEBUG).
1999-05-04 15:58:53 +00:00
cgd 1bce8c40fc ep_arglen is in units of 'sizeof (char *)', not in units of bytes. use
howmany(value, sizeof (char *)) to get the right value.
1999-04-30 23:02:06 +00:00
thorpej 645d5bd5f6 Share everything with proc0. 1999-04-30 21:40:30 +00:00
thorpej b699afcb5b Pay attention to FORK_SHARECWD, FORK_SHAREFILES, and FORK_SHARESIGS. 1999-04-30 21:39:51 +00:00
thorpej 2835fc6e46 Pull signal actions out of struct user, make them a separate proc
substructure, and allow them to be shared.

Required for clone(2).
1999-04-30 21:23:49 +00:00
thorpej 882d9195a3 Oops, forgot to commit this one. Free the cwdinfo on exit. 1999-04-30 20:54:04 +00:00
thorpej 16936c9565 Break cdir/rdir/cmask info out of struct filedesc, and put it in a new
substructure, `cwdinfo'.  Implement optional sharing of this substructure.

This is required for clone(2).
1999-04-30 18:42:58 +00:00
cgd ee94a4dacb add checks for COMPAT_OSF1 in the appropriate places 1999-04-30 05:29:20 +00:00
scottr 3d5c979e43 Pull in opt_poollog.h for POOL_LOGSIZE. 1999-04-29 17:47:19 +00:00
cgd e85db685e9 * don't have the [onz]magic setup functions set up the stack.
* add arguments describing the vnode and ecoff header of the executable
  being set up to the [onz]magic setup functions.
* export the stack setup function and the [onz]magic setup functions.
* call the MD ecoff hook _before_ the [onz]magic and stack setup
  functions, and bail out early if the MD hook sets up vmcmds.
1999-04-27 05:36:43 +00:00
cgd 5338149302 correct comment: turn off set-id if MNT_NOSUID is set, not MNT_NOEXEC. 1999-04-27 05:28:44 +00:00
thorpej 3d23eb3ce3 More improvements to mbuf and mbuf cluster allocation:
- Initialize mbpool and mclpool with msize and mclbytes, respectively,
so that those values may be patched and have an actual affect on the
next system reboot.

- Set low water marks on mbpool (default: 16) and mclpool (default: 8).
This should be of great help for diskless systems, which need to allocate
mbufs in order to clean dirty pages; the low water marks increase the
chances of this being possible to do in memory starvation situations.

- Add support for getting/setting some mbuf-related parameters via sysctl.
* msize and mclsize (read-only)
* nmbclusters (read-only unless the platform has direct-mapped pool pages,
in which case the value can be increased).
* mblowat and mcllowat (read/write)
1999-04-26 22:04:28 +00:00
thorpej 879070ef90 Add support for the kern.mbuf sysctl node. 1999-04-26 21:56:23 +00:00