Commit Graph

2262 Commits

Author SHA1 Message Date
augustss 72afbf03cf Run power hooks in reverse installation order when powering down and
installation order when powering up.  This allows drivers in a hierarchy
to DTRT.
2000-07-26 12:24:52 +00:00
tron 6f6272c9e9 Include "uvm/uvm_param.h" to get definition of "VM_MAX_KERNEL_BUF" as
suggested by Richard Earnshaw. This fixes PR kern/10649.
2000-07-23 10:41:35 +00:00
simonb da251cb08f Delete a couple of <uvm/uvm_extern.h> includes that were for
<sys/sysctl.h> only.
2000-07-22 16:11:02 +00:00
jdolecek b0fb24279c change the lf_advlock() arguments from
int     lf_advlock __P((struct lockf **,
           off_t, caddr_t, int, struct flock *, int));
to

int     lf_advlock __P((struct vop_advlock_args *, struct lockf **, off_t));

This matches common usage and is also compatible with similar change
in FreeBSD (though they use u_quad_t as last arg).
2000-07-22 15:26:11 +00:00
jeffs ddc66457b1 Same change in the kgdb code as was done in ddb:
Move platform db_trap callback from arch/mips into ddb as suggested by
  jhawk.  This callback is used by platform code to manage things like
  watchdogs that should be disabled while in ddb.  Done as a callback
  for processors such as mips that support lots of different systems.
2000-07-18 21:49:08 +00:00
fvdl 57e3691758 Don't wait for B_READ buffers to finish in vfs_shutdown, it makes no sense
to do so.

From Ethan Solomita.
2000-07-16 21:07:24 +00:00
fvdl 9067306192 Don't use *(unsigned int *)data to get the signal number out; this will
fail on LP64-BE systems. Also, fix up the invalid signal number check.
2000-07-14 12:10:58 +00:00
thorpej 195bf5c09f - Fix the likely cause of the "ps(1) hangs machine" problem. Always
vslock the user pages for the data being copied out to userspace,
  so that we won't sleep while holding a lock in case we need to
  fault the pages in.
- Sprinkle some const and ANSI'ify some things while here.
2000-07-14 07:21:21 +00:00
thorpej 8fd9032b90 ANSI'ify. 2000-07-14 07:14:33 +00:00
thorpej c55e09bd44 Add a comment about the hzto() return value. 2000-07-13 17:32:06 +00:00
thorpej c0c8481a2a New hzto() function from FreeBSD and Artur Grabowski <art@stacken.kth.se>.
Stops sleeps from returning early (by up to a clock tick), and return 0
ticks for timeouts that should happen now or in the past.

Returning 0 is different from the legacy hzto() interface, and callers
need to check for it.
2000-07-13 17:06:15 +00:00
simonb b10a1b69be Add a KERN_CONSDEV sysctl that returns cn_tab->cn_dev (if cn_tab is not
NULL).
2000-07-13 14:26:43 +00:00
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