summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_proc.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Completely redo thread states.julian2002-09-111-5/+5
| | | | Reviewed by: davidxu@freebsd.org
* Make UAREA_PAGES and KSTACK_PAGES visible to userland via sysctl, likepeter2002-09-071-0/+6
| | | | | | | | PS_STRINGS and USRSTACK is. This is necessary in order to decode a.out core dumps. kern_proc.c was already referring to both of these values but was missing the #include "opt_kstack_pages.h". Make the sysctl variables visible so that certain kld modules can see how their parent kernel was configured.
* Minor spelling tweak: assume "his" is actually "This".rwatson2002-09-061-1/+1
|
* Use UMA as a complex object allocator.julian2002-09-061-17/+31
| | | | | | | | | | | | | | | The process allocator now caches and hands out complete process structures *including substructures* . i.e. it get's the process structure with the first thread (and soon KSE) already allocated and attached, all in one hit. For the average non threaded program (non KSE that is) the allocated thread and its stack remain attached to the process, even when the process is unused and in the process cache. This saves having to allocate and attach it later, effectively bringing us (hopefully) close to the efficiency of pre-KSE systems where these were a single structure. Reviewed by: davidxu@freebsd.org, peter@freebsd.org
* Fix typos; each file has at least one s/seperat/separat/schweikh2002-08-111-5/+5
| | | | | | | | | | (I skipped those in contrib/, gnu/ and crypto/) While I was at it, fixed a lot more found by ispell that I could identify with certainty to be errors. All of these were in comments or text, not in actual code. Suggested by: bde MFC after: 3 days
* Wire the sysctl output buffer before grabbing any locks to preventtruckman2002-07-281-0/+1
| | | | | | | SYSCTL_OUT() from blocking while locks are held. This should only be done when it would be inconvenient to make a temporary copy of the data and defer calling SYSCTL_OUT() until after the locks are released.
* Thinking about it I came to the conclusion that the KSE states were incorrectlyjulian2002-07-141-2/+0
| | | | | | | | | | | | | | formulated. The correct states should be: IDLE: On the idle KSE list for that KSEG RUNQ: Linked onto the system run queue. THREAD: Attached to a thread and slaved to whatever state the thread is in. This means that most places where we were adjusting kse state can go away as it is just moving around because the thread is.. The only places we need to adjust the KSE state is in transition to and from the idle and run queues. Reviewed by: jhb@freebsd.org
* Collect all the (now equivalent) pmap_new_proc/pmap_dispose_proc/peter2002-07-071-2/+103
| | | | | | | | | | | | | pmap_swapin_proc/pmap_swapout_proc functions from the MD pmap code and use a single equivalent MI version. There are other cleanups needed still. While here, use the UMA zone hooks to keep a cache of preinitialized proc structures handy, just like the thread system does. This eliminates one dependency on 'struct proc' being persistent even after being freed. There are some comments about things that can be factored out into ctor/dtor functions if it is worth it. For now they are mostly just doing statistics to get a feel of how it is working.
* If the process is a zombie, then you must not try dereference the threadjulian2002-06-301-53/+55
| | | | | because there isn't one. Of course this code only possibly works for single threaded processes anyhow..
* Part 1 of KSE-IIIjulian2002-06-291-73/+144
| | | | | | | | | | | | | The ability to schedule multiple threads per process (one one cpu) by making ALL system calls optionally asynchronous. to come: ia64 and power-pc patches, patches for gdb, test program (in tools) Reviewed by: Almost everyone who counts (at various times, peter, jhb, matt, alfred, mini, bernd, and a cast of thousands) NOTE: this is still Beta code, and contains lots of debugging stuff. expect slight instability in signals..
* Always drop the p_args reference we held for copyout, even if we're aboutmini2002-06-221-3/+2
| | | | | | | to change it. This fixes a leak triggered by setproctitle(3). Approved by: alfred Noticed by: Peter Jeremy <peter.jeremy@alcatel.com.au>
* Properly lock accesses to p_tracep and p_traceflag. Also make a fewjhb2002-06-071-2/+12
| | | | ktrace-only things #ifdef KTRACE that were not before.
* Change p_can{debug,see,sched,signal}()'s first argument to be a threadjhb2002-05-191-3/+3
| | | | | | | pointer instead of a proc pointer and require the process pointed to by the second argument to be locked. We now use the thread ucred reference for the credential checks in p_can*() as a result. p_canfoo() should now no longer need Giant.
* Make funsetown() take a 'struct sigio **' so that the locking canalfred2002-05-061-4/+1
| | | | | | | | | | | | | | | | be done internally. Ensure that no one can fsetown() to a dying process/pgrp. We need to check the process for P_WEXIT to see if it's exiting. Process groups are already safe because there is no such thing as a pgrp zombie, therefore the proctree lock completely protects the pgrp from having sigio structures associated with it after it runs funsetownlst. Add sigio lock to witness list under proctree and allproc, but over proc and pgrp. Seigo Tanimura helped with this.
* As malloc(9) and free(9) are now Giant-free, remove the Giant locktanimura2002-05-031-5/+1
| | | | across malloc(9) and free(9) of a pgrp or a session.
* Fix the lock order reversal between the sigio lock and a process/pgrp lock intanimura2002-05-031-0/+2
| | | | funsetownlst() by locking the sigio lock across funsetownlst().
* Free(9) should be Giant-free.tanimura2002-04-241-1/+1
| | | | Suggested by: jhb
* Push down Giant for setpgid(), setsid() and aio_daemon(). Giant protects onlytanimura2002-04-201-1/+5
| | | | malloc(9) and free(9).
* - Merge the pgrpsess_lock and proctree_lock sx locks into one proctree_lockjhb2002-04-161-14/+10
| | | | | | | | | | | | sx lock. Trying to get the lock order between these locks was getting too complicated as the locking in wait1() was being fixed. - leavepgrp() now requires an exclusive lock of proctree_lock to be held when it is called. - fixjobc() no longer gets a shared lock of proctree_lock now that it requires an xlock be held by the caller. - Locking notes in sys/proc.h are adjusted to note that everything that used to be protected by the pgrpsess_lock is now protected by the proctree_lock.
* - Change fill_kinfo_proc() to require that the process is locked when itjhb2002-04-091-14/+20
| | | | | | | | | | | | | | is called. - Change sysctl_out_proc() to require that the process is locked when it is called and to drop the lock before it returns. If this proves too complex we can change sysctl_out_proc() to simply acquire the lock at the very end and have the calling code drop the lock right after it returns. - Lock the process we are going to export before the p_cansee() in the loop in sysctl_kern_proc() and hold the lock until we call sysctl_out_proc(). - Don't call p_cansee() on the process about to be exported twice in the aforementioned loop.
* Use CTASSERT rather than a runtime check to detect kinfo_proc size changes.jake2002-04-061-16/+2
| | | | Remove the ugly yuck code to busy wait for 20 seconds.
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-3/+3
| | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64
* Stage-2 commit of the critical*() code. This re-inlines cpu_critical_enter()dillon2002-04-011-0/+1
| | | | | | | | | | | | | | | | | | | | | and cpu_critical_exit() and moves associated critical prototypes into their own header file, <arch>/<arch>/critical.h, which is only included by the three MI source files that need it. Backout and re-apply improperly comitted syntactical cleanups made to files that were still under active development. Backout improperly comitted program structure changes that moved localized declarations to the top of two procedures. Partially re-apply one of the program structure changes to move 'mask' into an intermediate block rather then in three separate sub-blocks to make the code more readable. Re-integrate bug fixes that Jake made to the sparc64 code. Note: In general, developers should not gratuitously move declarations out of sub-blocks. They are where they are for reasons of structure, grouping, readability, compiler-localizability, and to avoid developer-introduced bugs similar to several found in recent years in the VFS and VM code. Reviewed by: jake
* Close some holes with p->p_args by NULL'ing out the p->p_args pointeralfred2002-03-311-3/+10
| | | | | | | while holding the proc lock, and by holding the pargs structure when accessing it from outside of the owner. Submitted by: Jonathan Mini <mini@haikugeek.com>
* To remove nested include of sys/lock.h and sys/mutex.h from sys/proc.halfred2002-03-281-0/+44
| | | | | | make the pargs_* functions into non-inlines in kern/kern_proc.c. Requested by: bde
* Make the reference counting of 'struct pargs' SMP safe.alfred2002-03-271-7/+5
| | | | | | | | | There is still some locations where the PROC lock should be held in order to prevent inconsistent views from outside (like the proc->p_fd fix for kern/vfs_syscalls.c:checkdirs()) that can be fixed later. Submitted by: Jonathan Mini <mini@haikugeek.com>
* Add a new mtx_init option "MTX_DUPOK" which allows duplicate acquires of locksjeff2002-03-271-1/+1
| | | | | | | | | | | with this flag. Remove the dup_list and dup_ok code from subr_witness. Now we just check for the flag instead of doing string compares. Also, switch the process lock, process group lock, and uma per cpu locks over to this interface. The original mechanism did not work well for uma because per cpu lock names are unique to each zone. Approved by: jhb
* oops, forgot to commit this. td->td_savecrit = 0 replaced by APIdillon2002-03-271-0/+1
| | | | call cpu_thread_link().
* Make this compile.jake2002-03-271-1/+0
| | | | Pointy hat to: dillon
* Fixed some style bugs in the removal of __P(()). The main ones werebde2002-03-241-4/+4
| | | | | | not removing tabs before "__P((", and not outdenting continuation lines to preserve non-KNF lining up of code with parentheses. Switch to KNF formatting and/or rewrap the whole prototype in some cases.
* Remove references to vm_zone.h and switch over to the new uma API.jeff2002-03-201-4/+5
| | | | | Also, remove maxsockets. If you look carefully you'll notice that the old zone allocator never honored this anyway.
* Remove __P.alfred2002-03-191-4/+4
|
* Lock struct pgrp, session and sigio.tanimura2002-02-231-79/+211
| | | | | | | | | | | | | | | | | | | | | | | | | New locks are: - pgrpsess_lock which locks the whole pgrps and sessions, - pg_mtx which protects the pgrp members, and - s_mtx which protects the session members. Please refer to sys/proc.h for the coverage of these locks. Changes on the pgrp/session interface: - pgfind() needs the pgrpsess_lock held. - The caller of enterpgrp() is responsible to allocate a new pgrp and session. - Call enterthispgrp() in order to enter an existing pgrp. - pgsignal() requires a pgrp lock held. Reviewed by: jhb, alfred Tested on: cvsup.jp.FreeBSD.org (which is a quad-CPU machine running -current)
* Convert p->p_runtime and PCPU(switchtime) to bintime format.phk2002-02-221-1/+3
|
* Oops, used wrong error value for unimplemented syscalls.julian2002-02-201-6/+6
|
* Add stub syscalls and definitions for KSE calls.julian2002-02-191-0/+45
| | | | "Book'em Danno"
* The previous commit included a change to fill_kinfo_proc() that resultsalc2002-02-121-1/+1
| | | | in a NULL pointer dereference. Repair this mistake.
* In a threaded world, differnt priorirites become properties ofjulian2002-02-111-5/+7
| | | | | | different entities. Make it so. Reviewed by: jhb@freebsd.org (john baldwin)
* Fix a fatal trap when using ksched_setscheduler() (eg: mozilla, netscapepeter2002-02-081-1/+1
| | | | etc) which use: td->td_last_kse->ke_flags |= KEF_NEEDRESCHED;
* remove superfluous blank linejulian2002-02-081-1/+0
|
* Fix a couple of style bugs introduced (or touched by) previous commit.peter2002-02-071-0/+2
|
* Pre-KSE/M3 commit.julian2002-02-071-60/+80
| | | | | | | | | | this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the process. It IS still embeded there but remove all teh code that assumes that in preparation for the next commit which will actually move it out. Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
* Fix a bug where the mutex name wasn't always displayed for processes injhb2002-01-051-1/+1
| | | | | | | | SMTX in utils such as ps and top. The KI_CTTY flag was assigned to kinfo_proc->ki_kiflag rather than or'd into the flag, thus clobbering any flags set earlier, including KI_MTXBLOCK. Prodding by: peter
* As a followup to the previous fixes to inferior, revert some of thejhb2001-11-131-6/+3
| | | | | | | changes in 1.80 that were needed for locking that are no longer needed now that a lock is simply asserted. Submitted by: bde
* Clean up breakage in inferior() I introduced in 1.92 of kern_proc.c:jhb2001-11-121-9/+7
| | | | | | | | | | - Restore inferior() to being iterative rather than recursive. - Assert that the proctree_lock is held in inferior() and change the one caller to get a shared lock of it. This also ensures that we hold the lock after performing the check so the check can't be made invalid out from under us after the check but before we act on it. Requested by: bde
* - Combine kern.ps_showallprocs and kern.ipc.showallsockets intorwatson2001-10-091-4/+0
| | | | | | | | | | | | | | | | | | | | | | | a single kern.security.seeotheruids_permitted, describes as: "Unprivileged processes may see subjects/objects with different real uid" NOTE: kern.ps_showallprocs exists in -STABLE, and therefore there is an API change. kern.ipc.showallsockets does not. - Check kern.security.seeotheruids_permitted in cr_cansee(). - Replace visibility calls to socheckuid() with cr_cansee() (retain the change to socheckuid() in ipfw, where it is used for rule-matching). - Remove prison_unpcb() and make use of cr_cansee() against the UNIX domain socket credential instead of comparing root vnodes for the UDS and the process. This allows multiple jails to share the same chroot() and not see each others UNIX domain sockets. - Remove unused socheckproc(). Now that cr_cansee() is used universally for socket visibility, a variety of policies are more consistently enforced, including uid-based restrictions and jail-based restrictions. This also better-supports the introduction of additional MAC models. Reviewed by: ps, billf Obtained from: TrustedBSD Project
* KSE Milestone 2julian2001-09-121-15/+89
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Add on UPAGES to ki_rssize since it is there as result of the processpeter2001-09-101-0/+2
| | | | and can be swapped out with the process.
* Fix part of another problem that bde pointed out. This is differentpeter2001-08-161-2/+3
| | | | to what bde suggested though.
* Remove redundant null-termination. The buffer is already explicitlypeter2001-08-161-8/+1
| | | | | | | zeroed, and we intentionally leave -1 on the strncpy length to leave the original \0. Submitted by: bde
OpenPOWER on IntegriCloud