Commit Graph

2174 Commits

Author SHA1 Message Date
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