Commit Graph

2350 Commits

Author SHA1 Message Date
mjacob c9f691d778 Correct omissions inadvertantly introduced when the non-debug
version (macro) was updated in exec.h.
2000-07-13 09:34:23 +00:00
itojun f5211e847a remove m_pulldown statistics code. it is highly experimental and belong
to kame tree only (not for *bsd).
2000-07-13 05:34:21 +00:00
matt b4c1bfd1f3 modify load_file to load at relative vms'a as specified in the phdr's. 2000-07-13 02:35:25 +00:00
matt 84bbae583c remove a debugging printf. 2000-07-13 02:33:36 +00:00
thorpej ccb90e6fe9 When select(2)/poll(2) is awakened by a collision, recalculate the
timeout value for tsleep().  From Artur Grabowski <art@stacken.kth.se>.
2000-07-13 01:32:33 +00:00
matt 81ce10aa1f Extend the vmcmd stuff a bit. Add a flags field and define
VMCMD_BASE & VMCMD_RELATIVE.  This allows one to add vmcmds
which are relative to previous entries.  This is needed for
loading the VAX ld.elf_so
2000-07-13 01:24:04 +00:00
kleink a5eeea36d4 Add back a failure return statement in check_header() which I accidently
deleted in rev. 1.46; pointed out by Chris Demetriou.
2000-07-11 06:23:38 +00:00
jhawk 84fe4f536c Comment police. s/DIAGNOSTICS/DIAGNOSTIC/ 2000-07-09 14:13:04 +00:00
itojun d8a9a3cc7b add ppsratelimit(9), which does event-per-sec rate limitation.
use it from icmp6 error rate limitation code.
XXX better name for the function?
2000-07-09 06:44:57 +00:00
itojun 8f3d56a298 shorten splclock() period in ratelimit().
From: onoe
2000-07-09 06:40:08 +00:00
mycroft caf07dfa04 When unmounting, make sure to free the syncer vnode so that it can be reused. 2000-07-09 00:59:03 +00:00
sommerfeld d5906caa54 Format paranoia 2000-07-08 18:11:02 +00:00
sommerfeld bb22022c59 Format paranoia. 2000-07-08 18:10:25 +00:00
mrg 4384010332 more extent_alloc() fixes:
check that newstart + size - 1 doesn't overflow the end of the extent, rather
than the "dontcross" value, which can easily overflow the end of an extent
when being asked for an object with a large boundary requirement.  this test
is more valid, in any case, and fixes extent_alloc() failure when the start of
the extent is not "aligned".
2000-07-07 14:10:48 +00:00
jdolecek 53385f1dfd adjust maximum number of vnodes in vnode cache according
to machine memory size upon boot if the number has not been specified
explicitly in kernel config - at this moment, 0.5% of system
memory is used for vnodes (but minimum NVNODE vnodes)
2000-07-06 09:51:54 +00:00
jdolecek 1ec07d7439 change tablefull() to accept one more parameter - optional hint
use that to inform about way to raise current limit when we reach maximum
number of processes, descriptors or vnodes

XXX hopefully I catched all users of tablefull()
2000-07-04 15:33:28 +00:00
fvdl 975751cda2 vinsheadfree -> ungetnewvnode 2000-06-27 23:51:51 +00:00
fvdl c39797c045 Add vinsheadfree, a small function to push vnodes that have just
been allocated by getnewvnode, back onto the head of the free list.
Needed in some VFS_VGET functions to deal with races.
2000-06-27 23:34:45 +00:00
mrg 32aa199ccf remove include of <vm/vm.h> 2000-06-27 17:41:07 +00:00
mrg 89d0a3e519 remove redundant vm includes. 2000-06-26 14:38:50 +00:00
mrg 2f159a1bac remove/move more mach vm header files:
<vm/pglist.h> -> <uvm/uvm_pglist.h>
	<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
	<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
	<vm/vm_object.h> -> nothing
	<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
2000-06-26 14:20:25 +00:00
mrg 53be5b215c <vm/vm_pageout.h> is already empty; kill it totally. 2000-06-25 13:49:33 +00:00
pk ac2055bc9a Fix-up (#if 0'd) printf() formats. 2000-06-24 12:46:57 +00:00
matt f2bfc30377 Add some kernel printfs (under DEBUG) to print messages when bad things
happen in a exec.
2000-06-21 05:43:33 +00:00
matt d4513b2c95 Add vmcmd_readvn (which was the 2nd halt of vmcmd_map_readvn). 2000-06-21 05:41:07 +00:00
pooka 7747299e6d Correct situation where vnode was left hanging around when trying to
mount a filesystem with securelevel 2. A second mount-attempt left
everything completely frozen.

Fix by Bill Sommerfeld.
2000-06-19 18:53:55 +00:00
mrg 8c758332be in extent_alloc_subregion1(), check for EXTENT_ALIGN() overflow when
doing the boundary-case check.  approved by thorpej.
2000-06-16 16:48:56 +00:00
simonb cd36ac22df Add #ifdef checks for SYSVMSG, SYSVSEM and SYSVSHM in more places to catch
when some but not all of the SysV IPC facilities are configured.
Problem noticed by Phil Nelson.
2000-06-16 00:57:04 +00:00
simonb 00d1b6b147 Add a KERN_MSGBUF sysctl to return the message buffer. 2000-06-16 00:18:09 +00:00
fvdl 4fbe4a470d Enable passing of the MNT_SOFTDEP flag in the mount system call. 2000-06-15 22:32:44 +00:00
cgd ef767ee388 Replace my personal attribution string ("This product includes software
developed by Christopher G. Demetriou for the NetBSD Project.") with
a generic NetBSD one ("This product includes software developed for the
NetBSD Project.  See http://www.netbsd.org/ for information about NetBSD.")
so that this same set of terms can be used by others if they so desire.
(Eventually i'll be converting more/all of my code.)
2000-06-13 22:36:16 +00:00
chs b4aac1046f round the sizes of mapped text and data segments to PAGE_SIZE.
fixes PR 10079.
2000-06-13 06:21:51 +00:00
chs ded9898d88 make sure that the size we pass to uvm_map() is a multiple of PAGESIZE.
this should fix PR 10175 and prevent the panic of PR 10079.
2000-06-13 04:25:31 +00:00
simonb e907fee281 In the KERN_GETPROC* handler:
* Handle KERN_PROC_SESSION that has been defined in <sys/sysctl.h> from
  day one.
* Add handlers for KERN_PROC_GID and KERN_PROC_RGID.
* If "op" doesn't valid, return EINVAL.
2000-06-13 01:27:00 +00:00
sommerfeld c0011ad705 Fix several problems with lockf/fcntl byte range locks:
- document a data structure invariant in lockf.h
 - add KASSERT() to check the invariant.
 - be more consistent about dequeuing ourselves from the blocked list
after a tsleep().
 - Fix two places where the invariant is violated.
 - correct a few comments here and there
 - If we're still following a lock dependancy chain after maxlockdepth
processes and haven't gotten back to the start, assume that we're in a
cycle anyway and return EDEADLK.

Fix is a superset of an existing fix in FreeBSD, but independantly
derived.

Fixes kern/3860.
2000-06-12 14:33:04 +00:00
sommerfeld e964d558a7 Fix assorted bugs around shutdown/reboot/panic time.
- add a new global variable, doing_shutdown, which is nonzero if
vfs_shutdown() or panic() have been called.
- in panic, set RB_NOSYNC if doing_shutdown is already set on entry
so we don't reenter vfs_shutdown if we panic'ed there.
 - in vfs_shutdown, don't use proc0's process for sys_sync unless
curproc is NULL.
 - in lockmgr, attribute successful locks to proc0 if doing_shutdown
&& curproc==NULL, and  panic if we can't get the lock right away; avoids the
spurious lockmgr DIAGNOSTIC panic from the ddb reboot command.
 - in subr_pool, deal with curproc==NULL in the doing_shutdown case.
 - in mfs_strategy, bitbucket writes if doing_shutdown, so we don't
wedge waiting for the mfs process.
 - in ltsleep, treat ((curproc == NULL) && doing_shutdown) like the
panicstr case.

Appears to fix: kern/9239, kern/10187, kern/9367.
May also fix kern/10122.
2000-06-10 18:44:43 +00:00
assar 6c734cd283 make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument.  also make makefstype
take a const parameter.  update all the callers.
2000-06-10 18:27:01 +00:00
oki 41608c00a3 PE/COFF (Win32) compatible binary support (experimental).
It currentry supports only i386.
2000-06-09 22:38:56 +00:00
thorpej 6ea30ef2e8 Use ltsleep(). 2000-06-08 05:50:59 +00:00
thorpej fcc7898856 Change tsleep() to ltsleep(), which takes an interlock argument. The
interlock is released once the scheduler is locked, so that a race
between a sleeper and an awakener is prevented in a multiprocessor
environment.  Provide a tsleep() macro that provides the old API.
2000-06-08 05:50:37 +00:00
soren 14573dc679 defopt SYSCALL_DEBUG. 2000-06-06 18:26:32 +00:00
thorpej 1e0957307e Make this build as a regression test with the latest simple lock
changes.
2000-06-06 17:32:50 +00:00
thorpej 0a3a6e34f8 Oops, missed a couple of places where CMSG_*() should be used. No
functional change in this case, but the code is now correct.
2000-06-05 16:29:45 +00:00
thorpej 724a90318e - Fix file descriptor passing AGAIN. This has apparently been broken
on LP64 systems (and probably the SPARC) since the __cmsg_alignbytes()
  changes went in.
- Change file descriptor passing to use CMSG_DATA(), not (cm + 1).  This
  pretty much has to be done in order to make it work properly on LP64,
  and considering that it's been broken this long...
- Use CMSG_SPACE() to determine the mbuf length needed for a given
  control message, and CMSG_LEN() to stash in the cmsg_len member.
2000-06-05 06:06:07 +00:00
cgd cffb580806 Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
2000-06-04 19:14:14 +00:00
mycroft 9dcdff8f25 Add stubs for PE/COFF. 2000-06-04 16:26:11 +00:00
thorpej 5b281c5932 Move schedticks and cp_time into schedstate_percpu. Also, allow
non-primary CPUs to call hardclock(), but make them bail about
before updating global timekeeping state (that's the job of the
primary CPU).
2000-06-03 20:42:42 +00:00
cgd 8d519faff4 fix type of sysctl_ntptime 'where' arg in defined(NTP) case 2000-06-02 18:22:44 +00:00
simonb 7e6435a651 White space nit in previous. 2000-06-02 16:05:49 +00:00
simonb 38cc1b3975 Add new sysctl node "KERN_SYSVIPC_INFO" with "KERN_SYSVIPC_MSG_INFO",
"KERN_SYSVIPC_SEM_INFO" and "KERN_SYSVIPC_SHM_INFO" to return the
info and data structures for the relevent SysV IPC types.  The return
structures use fixed-size types and should be compat32 safe.  All
user-visible changes are protected with
	#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)

Make all variable declarations extern in msg.h, sem.h and shm.h and
add relevent variable declarations to sysv_*.c and remove unneeded
header files from those .c files.

Make compat14 SysV IPC conversion functions and sysctl_file() static.

Change the data pointer to "void *" in sysctl_clockrate(),
sysctl_ntptime(), sysctl_file() and sysctl_doeproc().
2000-06-02 15:53:03 +00:00
cgd 00b28e7a52 another mod of opportunity: const poison. (cfprint_t should take
const char * as second arg, too, but that's Hard.)  also, convert use
of "(char *)0" to NULL.
2000-06-02 01:48:50 +00:00
cgd a556975be3 __P and K&R declarations -> ANSI protos + declarations. tweak NetBSD IDs,
and __KERNEL_RCSID to subr_autoconf.c.
2000-06-02 01:31:52 +00:00
pk e1859436f1 Fix lossage when transferring a pointer value into an off_t var. 2000-06-01 18:30:03 +00:00
simonb dbbe2b1dd7 Plug a slow kernel memory leak - a page was lost for each system or
zombie process queried with the KERN_PROC_ARGS sysctl.  Fixed by moving
a malloc call after all possible early return conditions.
2000-06-01 13:36:51 +00:00
pk b74050d677 Allow a pool's pagesz to larger than the VM page size.
Enforce the required page alignment restriction in pool_prime_page().
2000-05-31 15:29:42 +00:00
pk b60b3fb997 Assert that the pool item size does not exceed the page size. 2000-05-31 15:03:54 +00:00
enami 52a5cc1c5e Make this file compile with DIAGNOSTIC. 2000-05-31 06:18:03 +00:00
thorpej 956b3ca3b3 Track which process a CPU is running/has last run on by adding a
p_cpu member to struct proc.  Use this in certain places when
accessing scheduler state, etc.  For the single-processor case,
just initialize p_cpu in fork1() to avoid having to set it in the
low-level context switch code on platforms which will never have
multiprocessing.

While I'm here, comment a few places where there are known issues
for the SMP implementation.
2000-05-31 05:02:31 +00:00
mycroft da42c608fe Use a better multiplier for the 60Hz case. 2000-05-29 23:48:33 +00:00
jhawk 0ff7191f39 Ensure that a fault inside the traceback printing code
(i.e. db_stack_trace_print()) does not cause an infinite loop of
faults.
2000-05-29 23:10:03 +00:00
sommerfeld a3edbba355 Add null-pointer tests in ktrsamefile 2000-05-29 22:29:01 +00:00
sommerfeld 879eaa480a Fix clearing of ktrace points:
- need deep compare of open files, not a shallow pointer compare.
 - reorder fdrelease()/FILE_UNUSE() invocations so fdrelease doesn't
block waiting for something which can't happen until after it returns.
2000-05-29 22:04:11 +00:00
mycroft 7513b8e18d Update an outdated comment.
Allow all powers of 2 from 2^0 to 2^16 for hz.
Enable hz==1200.
2000-05-29 15:05:10 +00:00
mycroft 8dcf08ff77 Improve the time_adj multiplier for the 100Hz and 1000Hz cases, and add a
1200Hz case.
2000-05-29 14:58:59 +00:00
jhawk b4c87e6d41 Add proc0 to pidhashtbl so pfind(0) works.
Now trace/t 0 works in ddb, etc.
2000-05-28 18:52:32 +00:00
jhawk 0866399258 brain-oh in last. test logsoftc.sc_pgid, not p. 2000-05-28 18:31:13 +00:00
jhawk 8a49d6bd31 Ensure that all callers of pfind() can deal with pfind(0) returning
a real procp* rather than NULL.
2000-05-28 18:17:07 +00:00
sommerfeld a56cb94b43 Deal with NULL file pointer for KTROP_CLEAR 2000-05-28 15:27:51 +00:00
thorpej e03e9e8086 Rather than starting init and creating kthreads by forking and then
doing a cpu_set_kpc(), just pass the entry point and argument all
the way down the fork path starting with fork1().  In order to
avoid special-casing the normal fork in every cpu_fork(), MI code
passes down child_return() and the child process pointer explicitly.

This fixes a race condition on multiprocessor systems; a CPU could
grab the newly created processes (which has been placed on a run queue)
before cpu_set_kpc() would be performed.
2000-05-28 05:48:59 +00:00
mycroft 4656dfd24f Add a new function to remove extra buffers when truncating a file. This is
more generic than the vinvalbuf(V_SAVEMETA) case, avoiding synchronous
operations when truncating to a non-zero length.
2000-05-28 04:13:56 +00:00
sommerfeld f460c85cb3 Remove existing semaphore system locking mechanism and turn
sys_semconfig into a placebo system call, to avoid giving folks an
easy way to wedge processes which use semaphores.

NOTE: unlike 386bsd and freebsd, processes which did not have
semaphore undo records would not be affected by this problem (reducing
it from a serious local denial-of-service problem to a largely
cosmetic problem, since virtually nobody uses semaphores).  But the
code is just Wrong so we're ripping it out anyway.
2000-05-27 21:00:25 +00:00
thorpej 6d02ce1e66 All users of the old sleep() are now gone; nuke it. 2000-05-27 05:00:47 +00:00
thorpej 21fc65e1a8 sleep() -> tsleep() 2000-05-27 04:52:27 +00:00
simonb abae45a32c Set *sizep correctly if returning the number of elements. Pointed out
by Anders Magnusson.

Honor elem_count in the KERN_PROC2 case, as well as overall buffer
space.  The only user-land code to use this set the elem_count to
"buffer_space / elem_size", so we've had no incorrect behaviour to date.
2000-05-27 03:24:50 +00:00
enami ec808c5ba9 Make this file compiles with !DIAGNOSTIC. 2000-05-27 01:43:27 +00:00
sommerfeld 40339b39f9 Reduce use of curproc in several places:
- Change ktrace interface to pass in the current process, rather than
p->p_tracep, since the various ktr* function need curproc anyway.

 - Add curproc as a parameter to mi_switch() since all callers had it
handy anyway.

 - Add a second proc argument for inferior() since callers all had
curproc handy.

Also, miscellaneous cleanups in ktrace:

 - ktrace now always uses file-based, rather than vnode-based I/O
(simplifies, increases type safety); eliminate KTRFLAG_FD & KTRFAC_FD.
Do non-blocking I/O, and yield a finite number of times when receiving
EWOULDBLOCK before giving up.

 - move code duplicated between sys_fktrace and sys_ktrace into ktrace_common.

 - simplify interface to ktrwrite()
2000-05-27 00:40:29 +00:00
sommerfeld 951310bf3f Remove a gratuitous use of curproc 2000-05-27 00:11:12 +00:00
sommerfeld 137a54db78 Improve #error message slightly. 2000-05-26 23:18:26 +00:00
sommerfeld f822e85903 Eliminate incorrect use of "curproc" in a comment. 2000-05-26 23:10:36 +00:00
thorpej 3bcdc30c81 Adjust kinfo_proc2's p_schedflags assignment to match new reality. 2000-05-26 22:59:31 +00:00
thorpej a7d0570e67 First sweep at scheduler state cleanup. Collect MI scheduler
state into global and per-CPU scheduler state:

	- Global state: sched_qs (run queues), sched_whichqs (bitmap
	  of non-empty run queues), sched_slpque (sleep queues).
	  NOTE: These may collectively move into a struct schedstate
	  at some point in the future.

	- Per-CPU state, struct schedstate_percpu: spc_runtime
	  (time process on this CPU started running), spc_flags
	  (replaces struct proc's p_schedflags), and
	  spc_curpriority (usrpri of processes on this CPU).

	- Every platform must now supply a struct cpu_info and
	  a curcpu() macro.  Simplify existing cpu_info declarations
	  where appropriate.

	- All references to per-CPU scheduler state now made through
	  curcpu().  NOTE: this will likely be adjusted in the future
	  after further changes to struct proc are made.

Tested on i386 and Alpha.  Changes are mostly mechanical, but apologies
in advance if it doesn't compile on a particular platform.
2000-05-26 21:19:19 +00:00
jhawk 1fe6e4844f If db_onpanic is unset and DDB is compiled in, panic() now calls
db_stack_trace_print(__builtin_frame_address(0),...), to printf() the
stack trace to the message bufffer and console. Idea from SunOS/Solaris.
Useful when dumping fails.
2000-05-26 20:25:57 +00:00
simonb 40f8a88c3f Fill in locators for process argv/envp data after ps_strings is built. 2000-05-26 02:24:37 +00:00
simonb 485b240b6f Add some new sysctls to help abolish the dreaded "proc size mismatch"
errors from ps(1) and some other kernel grovellers, and return some
data that has previously only been accessable with /dev/kmem read
access.  The sysctls are:

 + KERN_PROC2 - return an array of fixed sized "struct kinfo_proc2"
   structures that contain most of the useful user-level data in
   "struct proc" and "struct user".  The sysctl also takes the size of
   each element, so that if "struct kinfo_proc2" grows over time old
   binaries will still be able to request a fixed size amount of data.
 + KERN_PROC_ARGS - return the argv or envv for a particular process id.
   envv will only be returned if the process has the same user id as the
   requestor or if the requestor is root.
 + KERN_FSCALE - return the current kernel fixpt scale factor.
 + KERN_CCPU - return the scheduler exponential decay value.
 + KERN_CP_TIME - return cpu time state counters.

With input and suggestions from many people on tech-kern.
2000-05-26 02:23:12 +00:00
thorpej 8964c35eca Introduce a new process state distinct from SRUN called SONPROC
which indicates that the process is actually running on a
processor.  Test against SONPROC as appropriate rather than
combinations of SRUN and curproc.  Update all context switch code
to properly set SONPROC when the process becomes the current
process on the CPU.
2000-05-26 00:36:42 +00:00
jhawk d30834ad42 Support ddb-specific nonstandard printf formats %r and %z in kprintf(),
even when not called with (flags&TODDB != 0), such that ddb print routines
can use them when printing elsewhere, such as to the message buffer.
2000-05-25 21:32:41 +00:00
jhawk a403c3e1c3 Kludge:
Change #define's of the form
	#define panic(a) printf(a)
to
	#define \
	panic(a) printf(a)
to prevent ctags(1) from detecting there is a tag.
Otherwise, the tags file claims panic() is in subr_extent.c
instead of subr_prf.c.
2000-05-24 02:22:36 +00:00
thorpej 75dbbed64a Fix a typo, and add some lint comments. 2000-05-23 05:17:11 +00:00
perseant f0728fdce1 Change the sementics of the last parameter from a boolean ("waitfor") to
a set of flags ("flags").  Two flags are defined, UPDATE_WAIT and
UPDATE_DIROP.

Under the old semantics, VOP_UPDATE would block if waitfor were set,
under the assumption that directory operations should be done
synchronously.  At least LFS and FFS+softdep do not make this
assumption; FFS+softdep got around the problem by enclosing all relevant
calls to VOP_UPDATE in a "if(!DOINGSOFTDEP(vp))", while LFS simply
ignored waitfor, one of the reasons why NFS-serving an LFS filesystem
did not work properly.

Under the new semantics, the UPDATE_DIROP flag is a hint to the
fs-specific update routine that the call comes from a dirop routine, and
should be wait for, or not, accordingly.

Closes PR#8996.
2000-05-13 23:43:06 +00:00
enami c6f0aaa60f Check malloc failure. 2000-05-10 02:16:15 +00:00
enami 007d263ce9 Cosmetic change. 2000-05-10 02:14:41 +00:00
thorpej c7bff4127b __predict_false() the DIAGNOSTIC and other error condition checks. 2000-05-08 20:09:44 +00:00
thorpej bc3d58f129 __predict_false() the DIAGNOSTIC error checks. 2000-05-08 20:07:37 +00:00
thorpej bfca0515b2 __predict_false() uvm_useracc() failure. 2000-05-08 20:03:20 +00:00
thorpej e633df2afa __predict_false() the check for bogus malloc type, running out of space
in kmem_map, and the DIAGNOSTIC error checks.
2000-05-08 20:02:21 +00:00
thorpej bc074bcbcf ktrgenio(): __predict_false() ktrwrite() failing.
ktrwrite(): __predict_true() no error occuring.
2000-05-08 20:01:05 +00:00
thorpej 9f95aebc81 __predict_false() fork1() failing. 2000-05-08 19:59:48 +00:00
thorpej a58b73be13 __predict_false() the test for full process table, user exceeding their
process limit, and USPACE valloc failure.
2000-05-08 19:59:21 +00:00
thorpej 9fcc4f1a12 __predict_false() the test for init exiting. 2000-05-08 19:58:17 +00:00
thorpej f10e7dc65b Don't reset file size limit to infinity on exit. Instead, temporarily
raise the limit to infinity when writing out the accounting file.

From Artur Grabowski <art@stacken.kth.se>.
2000-05-08 19:06:36 +00:00
itojun e6469f14ad move static function getstr() to cons.c, make it publically available
as cngetsn().  there will be other consumer.
2000-05-08 16:30:57 +00:00
sommerfeld 4d573016ed Let MULTIPROCESSOR && LOCKDEBUG case compile again 2000-05-03 13:53:59 +00:00
pk 716a862d08 Lock internals have changed, and we depend on those in here. 2000-05-02 09:29:39 +00:00
thorpej 8185691694 - If a platform defines __HAVE_ATOMIC_OPERATIONS, use them for counting
in the MULTIPROCESSOR case.
- Move a misplaced #ifdef so that LK_REENABLE actually works.
2000-05-02 04:32:33 +00:00
thorpej f51470a514 Require that each each MACHINE/MACHINE_ARCH supply a lock.h. This file
contains the values __SIMPLELOCK_LOCKED and __SIMPLELOCK_UNLOCKED, which
replace the old SIMPLELOCK_LOCKED and SIMPLELOCK_UNLOCKED.  These files
are also required to supply inline functions __cpu_simple_lock(),
__cpu_simple_lock_try(), and __cpu_simple_unlock() if locking is to be
supported on that platform (i.e. if MULTIPROCESSOR is defined in the
_KERNEL case).  Change these functions to take an int * (&alp->lock_data)
rather than the struct simplelock * itself.

These changes make it possible for userland to use the locking primitives
by including <machine/lock.h>.
2000-04-29 03:31:45 +00:00
minoura d982197440 Regen. 2000-04-21 16:16:15 +00:00
minoura f6051edef5 Add native issetugid() call.
Implementation from compat/freebsd.
2000-04-21 16:15:39 +00:00
thorpej c6fa58a322 - Allocate the ktrace operation header on the stack rather than using
MALLOC()/FREE().
- In ktrgenio():
	- Don't allocate the entire size of the I/O for the temporary
	  buffer used to write the data to the trace file.  Instead,
	  do it in page-sized chunks.
	- As in uiomove(), preempt the process if we are hogging the CPU.
	- If writing to the trace file errors, abort rather than continuing
	  to loop through the buffer.

From Artur Grabowski <art@stacken.kth.se>, with some additional cleanup
by me.
2000-04-19 19:14:17 +00:00
mrg 9dc12ba15b regen 2000-04-17 14:33:11 +00:00
mrg a6f7a7855f implement lchflags(2), which does the chflags(2) dance without following
symlinks, and thus can operate on symlinks.  remove a bogus comment in
chflags(1) that claims symlinks do not have file flags.

XXX: todo -- make chflags(1) use lchflags(2) when given the right options.
2000-04-17 14:31:21 +00:00
chs 9431f1857b change "nextvnodeid" from a global in namei.h to a static in
the one function that uses it.
2000-04-16 21:41:49 +00:00
chs d0fb21715e limit the number of namecache entries to numvnodes rather than desiredvnodes.
getnewvnode() has been changed to virtually guarantee that we'll have more
vnodes than "desired", so previously there would always be more vnodes
than namecache entries.  this fixes PR 9792.
2000-04-16 21:39:57 +00:00
simonb dd06794f0b Remove shmsegs declaration from conf/param.c - it doesn't belong here.
Instead, put it in kern/sysv_shm.c.
2000-04-15 16:49:35 +00:00
simonb 55bf62c1a1 For the KERN_PROC sysctl, when using KERN_PROC_TTY allow
KERN_PROC_TTY_NODEV to select processes with no controlling
tty and KERN_PROC_TTY_REVOKE to select processes with a
revoked controlling tty.
2000-04-15 04:38:07 +00:00
chs c81c7aa367 always define PI_MAGIC so this compiles in all cases. 2000-04-13 00:44:19 +00:00
simonb 6008cfd5de Remove bogus "#ifdef EIDRM" checks and warnings that BSD doesn't define
EIDRM - EIDRM was added over two years ago!
2000-04-12 13:08:26 +00:00
fvdl ea3e5a38b8 Fix from Ethan Solomita <ethan@geocast.com> to avoid a livelock problem
where the buffer cache code would be recycling B_AGE buffers with
dependencies.
2000-04-12 11:33:43 +00:00
chs a6d33cc1f2 add a new function vn_marktext() for exec code to let others know
that the vnode is now being used as process text.
2000-04-11 04:37:47 +00:00
chs 1c084aee4f add ddb commands for printing vnodes and bufs. 2000-04-10 02:22:13 +00:00
chs 9faf1824c8 in pool_put(), fill the entire object with PI_MAGIC instead of just the
first element.
2000-04-10 02:17:42 +00:00
augustss c87c1861bb Add a special option, DEBUG_HALT_BUSY, that allows you to debug when the
system doesn't want to halt cleanly.  The code was there before, but only
with the DEBUG option.
2000-03-30 09:32:25 +00:00
augustss 264f1d27c6 Get rid of register declarations. 2000-03-30 09:27:11 +00:00
simonb 6fa443065b Delete redundant decl of union_vnodeop_p, it's in <miscfs/union/union.h>. 2000-03-30 02:15:09 +00:00
simonb d1f05e517a Delete redundant decl of dounmount(), it's in <sys/mount.h>. 2000-03-30 02:12:25 +00:00
simonb 9ff7681a33 Don't need to include <sys/conf.h> here. 2000-03-29 03:43:31 +00:00
simonb 6043a575b2 Remove declaration of db_radix - <ddb/db_output.h> has one.
Also remove <sys/conf.h> - don't need it here.
2000-03-29 03:05:18 +00:00
simonb 2f1fef39b3 Centralise the declarations of cpu_model, machine, machine_arch,
osrelease, and ostype and remove "extern char foo[];" (for hostname
and domainname too).

Also delete redunctant decl of boottime in kern_info_43.c.
2000-03-28 23:57:24 +00:00
simonb bb1fc886cf endtsleep() is prototyped at the top of the file, delete duplicate
declaration inside tsleep().
2000-03-28 22:04:46 +00:00
simonb 468456cf00 Delete duplicate definition of kernel time variable (in <sys/kernel.h>). 2000-03-28 22:01:52 +00:00
kleink 2e68f6172e Cast timeval members to types we know the printf conversions of. 2000-03-28 18:39:03 +00:00
augustss 61462c55a3 Get rid of a lot of register declarations.
(Why isn't this done everywhere in the kernel already?)
2000-03-28 17:30:10 +00:00
simonb 071bde5df6 Don't need to declare nblkdev, nchrdev - these are in <sys/systm.h>. 2000-03-28 06:26:22 +00:00
kleink 230876cf26 Merge parts of chs-ubc2 into the trunk:
* Remove the casts to vaddr_t from the round_page() and trunc_page() macros to
  make them type-generic, which is necessary i.e. to operate on file offsets
  without truncating them.
* In due course, cast pointer arguments to these macros to an appropriate
  integral type (paddr_t, vaddr_t).

Originally done by Chuck Silvers, updated by myself.
2000-03-26 20:42:21 +00:00
enami f9c7a69ff5 Call the routine to calculate callwheelsize from allocsys() instead of
main() since some port like alpha and mips calls allocsys() before main()
is called.  While I'm here, I renamed some function.
2000-03-24 11:57:14 +00:00
thorpej 2b58edac40 Remove the CALLWHEEL_SORT code. It was implemented just for experimenting,
and I had no plans to ever enable it.  A record of the code is now in the
CVS history of the file, so we can unclutter now.
2000-03-23 20:51:09 +00:00
thorpej 7c8b72d592 uiomove(): if we're informed that we should yield the CPU, use the new
preempt() primitive to do so.
2000-03-23 20:39:58 +00:00
thorpej 68054a285a Track if a process has been through a round-robin cycle without yielding
the CPU, and mark that it should yield if that happens.

Based on a discussion with Artur Grabowski.
2000-03-23 20:37:58 +00:00
soren 93c531f872 Tiny comment update. 2000-03-23 14:32:41 +00:00
thorpej b667a5a357 New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
  resource allocation.
- Insertion and removal of callouts is constant time, important as
  this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
2000-03-23 06:30:07 +00:00
thorpej dabbfde70a Implement fdremove() which is used in place of all the code that
did the "fdp->fd_ofiles[fd] = 0" assignment; fdremove() make sure
the fd_freefiles hints stay in sync.

From OpenBSD.
2000-03-23 05:16:12 +00:00
ws 7da71e5f9e Make IPKDB working again.
Add support for i386 debugging and pci-based ne2000 boards.
2000-03-22 20:58:25 +00:00
thorpej d488aca2aa Pool'ify filedesc0 allocation. 2000-03-22 17:42:57 +00:00
fvdl c3167b9545 Do previous better. Use FSYNC_RECLAIM as it was before. 2000-03-17 01:25:06 +00:00
darrenr 08227b6c88 build stkbuf out of u_long rather than char for sys_ioctl() to ensure we get an aligned array 2000-03-17 00:01:48 +00:00
jdolecek 89015c4648 Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.
2000-03-16 18:08:17 +00:00
jdolecek 677d6a9962 add hashdone() - frees memory previously allocated via hashinit() 2000-03-16 17:19:53 +00:00
fvdl 14cbd3e2b0 In fdatasync, do not call bioops.io_fsync, since we're not flushing
metadata. If you do call it, there's actually a fair chance that it
will panic because its metadata dependencies were not cleared in
the VOP_FSYNC above (with FSYNC_DATAONLY).
2000-03-15 16:30:39 +00:00
fvdl 01db605567 Do the previous slightly different: any files on MNT_SOFTDEP filesystems do
not want all their metadata dependencies flushed from vinvalbuf() if
there are no dirty blocks.
2000-03-15 16:28:45 +00:00
perseant 61fa9e1409 Move vinvalbuf's check for dirty blocks into ffs_fsync, to ensure that
mode and ownership bits are flushed to disk before the vnode is
reclaimed.

The check, introduced in the softdep merge, assumes that if no blocks
are dirty, no file data *or metadata* needs to be flushed to disk.  This
is true of ffs, but is not true of lfs, and may not be true of other
filesystems.

Tested by myself and Bill Squier <groo@cs.stevens-tech.edu>.
2000-03-11 05:00:18 +00:00
enami 01a5f6c995 Create new kernel thread to issue statfs(2) system call to check free
disk space rather than doing it in timeout handler.  This fixes long
standing bug that accounting file can't be put on NFS file system (so,
e.g, we couldn't turn on accounting on diskless system).
2000-03-10 01:13:18 +00:00
mycroft 1d915f4130 Allow my disk to actually spin down using `-o async' again.
Note: This uses the same questionable logic as vfs_bio.c to check MNT_ASYNC.
Something needs to be done about this.
2000-03-03 05:21:03 +00:00
itojun 04ac848d6f introduce m->m_pkthdr.aux to hold random data which needs to be passed
between protocol handlers.

ipsec socket pointers, ipsec decryption/auth information, tunnel
decapsulation information are in my mind - there can be several other usage.
at this moment, we use this for ipsec socket pointer passing.  this will
avoid reuse of m->m_pkthdr.rcvif in ipsec code.

due to the change, MHLEN will be decreased by sizeof(void *) - for example,
for i386, MHLEN was 100 bytes, but is now 96 bytes.
we may want to increase MSIZE from 128 to 256 for some of our architectures.

take caution if you use it for keeping some data item for long period
of time - use extra caution on M_PREPEND() or m_adj(), as they may result
in loss of m->m_pkthdr.aux pointer (and mbuf leak).

this will bump kernel version.

(as discussed in tech-net, tested in kame tree)
2000-03-01 12:49:27 +00:00
enami 13d92f98ce Remove unnecessary asterisk in comment (probably it was comment leader of
multiline comment).
2000-03-01 03:51:29 +00:00
enami 543db3a000 Cosmetic changes. 2000-03-01 03:50:04 +00:00
itojun c47506aed1 more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).
2000-02-29 19:14:59 +00:00
itojun 959ca07b4b add hw.alignbytes sysctl mib. this gives you the value of ALIGNBYTES
at the kernel compilation time (ALIGNBYTES that the kernel uses).
2000-02-27 06:13:35 +00:00
sommerfeld cd14e5fa0c Add a fifth "divisor" argument to humanize_number; suitable values are
either 1024 or 1000.
Needed because frequencies use decimal rather than power-of-two SI
prefixes.
2000-02-20 19:32:28 +00:00
itojun 83176f3b3c fix alignment problem in ancillary messages (alpha).
the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>
2000-02-18 05:19:23 +00:00
itojun 791a70292c correct ratecheck() signedness. without this fix, ratecheck() will never
success again after first success with lasttime=(0,0).
2000-02-16 12:36:19 +00:00
fvdl c13f6dd258 Introduce a sysctl to enable/disable if non-root users can mount filesystems.
Default: off.
2000-02-16 11:57:45 +00:00
fvdl fe39281ea4 Fixes to the softdep code from Ethan Solomita <ethan@geocast.com>.
* Fix buffer ordering when it has dependencies.
* Alleviate memory problems.
* Deal with some recursive vnode locks (sigh).
* Fix other bugs.
2000-02-14 22:00:21 +00:00
thorpej 445e42d77a One small piece from UBC: create a pool for I/O buffers. One small piece
not from UBC: make physio use it instead of its own home-grown thing.
2000-02-14 20:12:02 +00:00
thorpej 2649d26c0e Use ratecheck(). 2000-02-14 19:28:19 +00:00
oster 919df6690a Add support for / on RAID. A bit of a gross hack, but sufficient for now.
Note that this doesn't help you much until the RAID autoconfig code
in sys/dev/raidframe/rf_netbsdkintf.c is turned on.
2000-02-13 04:57:44 +00:00
thorpej eb9cbbe294 Add some very simple code to auto-size the kmem_map. We take the
amount of physical memory, divide it by 4, and then allow machine
dependent code to place upper and lower bounds on the size.  Export
the computed value to userspace via the new "vm.nkmempages" sysctl.

NKMEMCLUSTERS is now deprecated and will generate an error if you
attempt to use it.  The new option, should you choose to use it,
is called NKMEMPAGES, and two new options NKMEMPAGES_MIN and
NKMEMPAGES_MAX allow the user to configure the bounds in the kernel
config file.
2000-02-11 19:22:52 +00:00
sommerfeld 39db0e9c7e Three MULTIPROCESSOR + LOCKDEBUG fixes:
1) fix typo preventing compilation (missing comma).
2) in SLOCK_WHERE, display cpu number in the MP case.
3) the folowing race condition was observed in _simple_lock:
	cpu 1 releases lock,
	cpu 0 grabs lock
 	cpu 1 sees it's already locked.
	cpu 1 sees that lock_holder== "cpu 1"
	cpu 1 assumes that it already holds it and barfs.
	cpu 0 sets lock_holder == "cpu 0"
Fix: set lock_holder to LK_NOCPU in _simple_unlock().
2000-02-09 16:46:09 +00:00
fair 554df2b994 remove kern_logsigexit being "on" for DIAGNOSTIC 2000-02-08 04:13:51 +00:00
thorpej fe551f0e64 Fix a bug in disksort_*() which caused non-optimal ordering when multiple
active partitions were on a single spindle.  Add a b_rawblkno member to
struct buf which contains the non-partition-relative block number to sort
by.
2000-02-07 20:16:47 +00:00
jonathan b19c0fbb0a Make kernel SOMAXCONN patchable. Will add sysctl once we
decide on namespace.
2000-02-07 18:43:26 +00:00
eeh 8636e8eef7 Update for compat_netbsd32. 2000-02-06 16:49:51 +00:00
itojun 90736ab608 fix include pathname for better rfc2292 compliance. 2000-02-06 12:49:37 +00:00
fair c75556a12f Add kernel logging of processes which exit on signals which can
cause a core to drop, and whether the core dropped, or, if it did
not, why not (i.e. error number). Logs process ID, name, signal that
hit it, and whether the core dump was successful.

logging only happens if kern_logsigexit is non-zero, and it can be
changed by the new sysctl(3) value KERN_LOGSIGEXIT. The name of this
sysctl and its function are taken from FreeBSD, at the suggestion
of Greg Woods in PR 6224. Default behavior is zero for a normal
kernel, and one for a kernel compiled with DIAGNOSTIC.
2000-02-06 07:29:56 +00:00
thorpej 113a379cba Implement pffinddomain(), and use it as appropriate. 2000-02-06 02:54:15 +00:00
cgd dd84ecc7ac Implement ratecheck(), a function which can help programmers implement
rate-limited actions.  See ratecheck(9) for details of its use.
2000-02-03 23:04:45 +00:00
thorpej 9069b40366 Add a sanity check to ensure that a region being free()'d is actually
within the KVA range malloc() would return.
2000-02-01 19:37:58 +00:00
enami 3669884c32 Factor out a common functionality into a subroutine. 2000-02-01 05:28:01 +00:00
danw f77befbc84 #define __HAVE_DEVICE_REGISTER on ports that have it, and check for
that, rather than a list of architecture defines, in config_attach
2000-02-01 04:01:19 +00:00
assar a49e53d3df (sys_open, sys_fhopen): remove declaration of vnops, now in
<sys/file.h>
2000-02-01 01:24:38 +00:00
assar e4b59906e1 (exec_script_makecmds): remove declaration of vnops, now in
<sys/file.h>
2000-02-01 01:23:29 +00:00
christos 3d9c5d0450 Regen 2000-01-31 15:13:24 +00:00
christos 3cbe025990 __semctl13 -> ____semctl13 because this now is not called directly.
The fourth argument to it is a pointer to union semun not union semun,
because passing structs and unions to syscalls cannot be handled portably.
2000-01-31 15:12:30 +00:00
hannken a6ee792cee The decision that `disksort_cylinder' uses to decide if the buffer needs
to go to the inversion list is incomplete. If the cylinders are equal
block numbers must be checked.

This caused lockups if some buffers with the same cylinder were cycling
through the list, as it may happen with softdep enabled.

Fixes PR #9197.
2000-01-28 09:27:38 +00:00
thorpej b58f7c1079 Remove unused global `consintr'. Rob Black, kern/3841. 2000-01-26 07:50:33 +00:00
enami a119cb3677 In the diagnostic check in config_detach, inform the name of parent and
its child who shouldn't be exist.
2000-01-25 13:23:26 +00:00
enami 65c138fea0 - Print a name of root device even if it is a network device.
- If RB_ASKNAME, only dumpdv holds the results asked interactively.
  Examie dumpspec only when !RB_ASKNAME.  This allows us to override
  dumps on none in kernel config file by booting kernel with RB_ASKNAME.
- Slightly rearrange code so that it more matches to comment.
2000-01-25 09:23:59 +00:00
enami 047cc5e94f Cleanup setroot() a bit:
- No longer necessary to use goto, just breaking the loop like other case
  is enough.
- Don't caliculate loop invariant every time.  Just reuse.
2000-01-25 03:42:36 +00:00
fvdl 65e677bd99 Add an exec hook mechanism, where kernel subsystem can register to
execute certain functions when a process does an exec(). Currently
uses a global list. Could possibly be done using a per-process list,
but this needs more thought.
2000-01-25 01:15:14 +00:00
thorpej 5aa64075cc Add a `config_pending' semaphore to block mounting of the root file system
until all device driver discovery threads have had a chance to do their
work.  This in turn blocks initproc's exec of init(8) until root is
mounted and process start times and CWD info has been fixed up.

Addresses kern/9247.
2000-01-24 18:03:19 +00:00
thorpej 6068308fcd In cwdinit(), if there isn't a cdir vnode yet, don't VREF() it. 2000-01-24 17:57:34 +00:00
mycroft 0153fa8a4d Regen. 2000-01-23 01:01:51 +00:00
mycroft db70ed30f4 Use proper varargs format for __semctl13. 2000-01-23 01:01:30 +00:00
thorpej 2ad35b74df After some discussion with Mycroft, change splstatclock() to splclock().
The rule is that you don't get to call scheduler-related functions (e.g.
wakeup()) above the clock interrupt.  Going to statclock unnecessarily
hoses e.g. serial interrupts on the SPARC.
2000-01-22 16:53:50 +00:00
thorpej 2ab34248eb Back out rev 1.36... what was I thinking? Also, update the comment that
led me astray to reflect reality.
2000-01-22 16:32:02 +00:00
thorpej 0ef111e8ee - Implement bowrite() -- perform an asynchronous, ordered write. 2000-01-21 23:22:24 +00:00
thorpej e3d3905ac7 Preserve B_ORDERED. 2000-01-21 23:21:46 +00:00
thorpej 05c6b5a9a0 - Add a B_ORDERED flag to communicate to drivers that an I/O request should
be issued/completed in order; that is, provide a barrier for I/O queues.
- Change the buffer driver queue links to a TAILQ, rather than using
  a home-grown equivalent.  Provide BUFQ_*() macros to manipulate buffer
  queues; these deal with the barrier provided by B_ORDERED.
- Update disksort() accordingly, and provide 3 versions:
	- disksort_cylinder(): historical disksort(), which keys on
	  b_cylinder (and b_blkno for the case when b_cylinder matches).
	- disksort_blkno(): sorts only on b_blkno.  Essentially the
	  same as disksort_cylinder(), but with fewer comparisons.
	- disksort_tail(): requests are simply inserted into the queue
	  at the tail.  This is provided as an option so that drivers
	  can simply have a pointer to the appropriate sort function.
  Note that disksort() now pays attention to B_ORDERED.
2000-01-21 23:20:51 +00:00
thorpej a0397a2573 Move callout initialization to a single location; no need to duplicate
that code all over the place.
2000-01-19 20:05:30 +00:00
cgd ccfb44f360 use the old cloning-device cf_unit increment behaviour, if
__BROKEN_CONFIG_UNIT_USAGE is defined.
2000-01-18 07:45:04 +00:00
matt 2dd872c9b4 defopt COMPAT_VAX1K 2000-01-17 02:59:25 +00:00
assar 70aab8de7d (sysctl_doeproc): make sure we release the proclist_lock even if
copyout fails
2000-01-16 15:07:48 +00:00