Commit Graph

2154 Commits

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