summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_proc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Revert the convertion of per-process thread into a SMR_TAILQ.mpi2021-02-081-3/+3
| | | | | We did not reach a consensus about using SMR to unlock single_thread_set() so there's no point in keeping this change.
* Convert the per-process thread list into a SMR_TAILQ.mpi2020-12-071-3/+3
| | | | | | | Currently all iterations are done under KERNEL_LOCK() and therefor use the *_LOCKED() variant. From and ok claudio@
* Remove the PR_WAITOK flag from the ucred_pool. The pool items are smallkettenis2020-09-261-2/+2
| | | | | | | | | | enough that this pool uses the single page allocator for which PR_WAITOK is a no-op. However it presence suggests that pool_put(9) may sleep. The single page allocator will never actually do that. This makes it obvious that refreshcreds() will not sleep. ok deraadt@, visa@
* Move duplicated code to send an uncatchable SIGABRT into a function.mpi2020-09-161-7/+2
| | | | ok claudio@
* Split `p_priority' into `p_runpri' and `p_slppri'.mpi2020-01-301-2/+2
| | | | | | | | | | | Using different fields to remember in which runqueue or sleepqueue threads currently are will make it easier to split the SCHED_LOCK(). With this change, the (potentially boosted) sleeping priority is no longer overwriting the thread priority. This let us get rids of the logic required to synchronize `p_priority' with `p_usrpri'. Tested by many, ok visa@
* Add a mechanism for managing asynchronous IO signal registrations.visa2018-11-121-1/+3
| | | | | | | | | It centralizes IO signal privilege checking and makes possible to revoke a registration when the target process or process group is deleted. Adapted from FreeBSD. OK kettenis@ mpi@ guenther@
* Use atomic operations for updating cred structure reference countsvisa2018-06-211-2/+2
| | | | | | | | | | | to make crfree() and crhold() MP-safe. Make crhold() a proper function. Put the definition into file kern_prot.c to constrain the need of the <sys/atomic.h> header. While there, adjust the IPL of ucred_pool to avoid lock order problems with the kernel lock (pointed out by kettenis@). OK mpi@
* Make sure that programs violating a pledge(2) promise or some memorympi2018-03-271-1/+2
| | | | | | | | protection cannot block the final SIGABRT. While here apply the same logic to ddb(4)'s kill command. From semarie@, ok deraadt@
* Serialize access to UID data with a rwlock.mpi2018-02-261-4/+22
| | | | | | | Caller must call uid_release() after making whatever change they needed on the result of uid_find(). Adapted from guenther@'s proctree diff, ok dlg@, visa@
* Introduce enternewpgrp() & enterthispgrp(), from FreeBSD via guenther@.mpi2018-02-201-55/+44
| | | | | | | This code shuffling will ease the introduction of the proctree lock in sys_setsid() and sys_setpgid(). Extracted from a larger diff from guenther@, ok visa@
* Move cleanup job control bits to their own function.mpi2018-02-101-1/+44
| | | | | | Part of the larger 'proctreelk' diff from guenther@ No functional change, ok benno@, tedu@
* Delete unnecessary <sys/file.h> includesguenther2017-12-301-2/+1
| | | | ok millert@ krw@
* Change __mp_lock_held() to work with an arbitrary CPU info structure andmpi2017-12-041-4/+12
| | | | | | | extend ddb(4) "ps /o" output to print which CPU is currently holding the KERNEL_LOCK(). Tested by dhill@, ok visa@
* New ddb(4) command: kill.mpi2017-09-291-1/+23
| | | | | | | | Send an uncatchable SIGABRT to the process specified by the pid argument. Useful in case of CPU exhaustion to kill the DoSing process and generate a core for later inspection. ok phessler@, visa@, kettenis@, miod@
* Update usage for ps/w to match previous commitguenther2017-02-041-2/+2
|
* Display process group in "ps /w" since they got removed from "ps /n".mpi2017-01-241-9/+11
| | | | | | While here fix the formating of /w /o and /a. ok guenther@
* Display the thread ID (TID) rather than the process group ID (PGRP)mpi2017-01-241-9/+14
| | | | | | | | in ddb(4)'s default 'ps' view. This allow to use 'tr /p' easily now that it requires a TID. With inputs from guenther@
* Rename pfind(9) into tfind(9) to reflect that it deals with threads.mpi2017-01-241-2/+2
| | | | | | While here document prfind(9. with and ok guenther@
* p_comm is the process's command and isn't per thread, so move it fromguenther2017-01-211-6/+6
| | | | | | struct proc to struct process. ok deraadt@ kettenis@
* Split PID from TID, giving processes a PID unrelated to the TID of theirguenther2016-11-071-14/+17
| | | | | | initial thread ok jsing@ kettenis@
* all pools have their ipl set via pool_setipl, so fold it into pool_init.dlg2016-09-151-19/+13
| | | | | | | | | | | | | | | | | | | | | | the ioff argument to pool_init() is unused and has been for many years, so this replaces it with an ipl argument. because the ipl will be set on init we no longer need pool_setipl. most of these changes have been done with coccinelle using the spatch below. cocci sucks at formatting code though, so i fixed that by hand. the manpage and subr_pool.c bits i did myself. ok tedu@ jmatthew@ @ipl@ expression pp; expression ipl; expression s, a, o, f, m, p; @@ -pool_init(pp, s, a, o, f, m, p); -pool_setipl(pp, ipl); +pool_init(pp, s, a, ipl, f, m, p);
* add a concept of 'verified auth' to sessions. When set via ioctl,tedu2016-09-021-1/+11
| | | | | | | | the user and parent process are recorded. Later, this info may be tested and used to bypass authorization requirements. ie, doas won't ask for your password again. Great idea from henning. ok deraadt guenther henning
* pool_setipldlg2016-08-251-1/+7
| | | | ok kettenis@
* Repair kill(2) on zombie processes.jca2016-06-271-1/+15
| | | | | | | | | | kill(2) is supposed to find zombie processes, this probably got broken when the process reaper was introduced. As a temporary(tm) workaround, walk the list of zombie processes if we can't find the target pid in the main process list. Problem with zsh initially reported by Geoff Wozniak on misc@, analysis done by naddy@. ok kettenis@ tedu@
* repair documentation for inferior(); from Michal Mazurekderaadt2016-03-041-2/+2
|
* Add ddb ps/o, displaying just the non-idle on-proc threadsguenther2015-09-111-8/+30
| | | | ok deraadt@
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-2/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* start retiring the nointr allocator. specify PR_WAITOK as a flag as atedu2014-12-191-13/+13
| | | | marker for which pools are not interrupt safe. ok dlg
* convert bcopy to memcpy. ok millerttedu2014-12-101-2/+2
|
* pass size argument to free()deraadt2014-11-031-2/+2
| | | | ok doug tedu
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-2/+2
| | | | after discussions with beck deraadt kettenis.
* Track whether a process is a zombie or not yet fully built via flagsguenther2014-07-041-2/+2
| | | | | | | | | | | PS_{ZOMBIE,EMBRYO} on the process instead of peeking into the process's thread data. This eliminates the need for the thread-level SDEAD state. Change kvm_getprocs() (both the sysctl() and kvm backends) to report the "most active" scheduler state for the process's threads. tweaks kettenis@ feedback and ok matthew@
* Move from struct proc to process the reference-count-holding pointersguenther2014-05-151-4/+3
| | | | | | | | | | to the process's vmspace and filedescs. struct proc continues to keep copies of the pointers, copying them on fork, clearing them on exit, and (for vmspace) refreshing on exec. Also, make uvm_swapout_threads() thread aware, eliminating p_swtime in kernel. particular testing by ajacoutot@ and sebastia@
* Eliminates struct pcred by moving the real and saved ugids intoguenther2014-03-301-5/+2
| | | | | | | | | struct ucred; struct process then directly links to the ucred Based on a discussion at c2k10 or so before noting that FreeBSD and NetBSD did this too. ok matthew@
* Move p_emul and p_sigcode from proc to process.guenther2014-03-261-2/+2
| | | | | | | | | Tweak the handling of ktrace EMUL when changing ktracing: only generate one per process (not one per thread) and pass the correct proc pointer down to the VFS layer. Permit generating of NAMI and CSW records inside ktrace(2) itself. ok deraadt@ millert@
* Threads can't be zombies, only processes, so change zombproc to zombprocess,guenther2014-01-201-38/+41
| | | | | | | | make it a list of processes, and change P_NOZOMBIE and P_STOPPED from thread flags to process flags. Add allprocess list for the code that just wants to see processes. ok tedu@
* format string fix: p_*ticks are u_intsf2013-10-021-2/+2
|
* Stop merging the per-thread and per-process flags when reportingguenther2013-09-221-2/+2
| | | | | | | | them via sysctl(KERN_PROC). In struct kinfo_proc the per-process flags move to p_psflags, leaving the per-thread flags in p_flags. Flag descriptions in ps(1) updated to be less obtuse. discussed with matthew@ some time ago; ok jca@, manpage bits ok jmc@
* The ps flags are split between thread and process. It is usefulbluhm2013-08-121-4/+6
| | | | | | | for ddb to show both. So or them together in the ps overview and list them explicitly for the specific thread. Also sync the ddb bit names with the define names. OK miod@
* Uncomment kprintf format attributes for sys/kernsyl2013-08-081-2/+2
| | | | tested on vax (gcc3) ok miod@
* Comment out recently added __attribute__((__format__(__kprintf__))) annotationsmiod2013-02-171-2/+2
| | | | | | in MI code; gcc 2.95 does not accept such annotation for function pointer declarations, only function prototypes. To be uncommented once gcc 2.95 bites the dust.
* Add explicit __attribute__ ((__format__(__kprintf__)))) to the functions andmiod2013-02-091-2/+3
| | | | | | function pointer arguments which are {used as,} wrappers around the kernel printf function. No functional change.
* Make the KERN_NPROCS and KERN_MAXPROC sysctl()s and the RLIMIT_NPROC rlimitguenther2012-04-101-4/+4
| | | | | | | | count processes instead of threads. New sysctl()s KERN_NTHREADS and KERN_MAXTHREAD count and limit threads. The nprocs and maxproc kernel variables are replaced by nprocess, maxprocess, nthreads, and maxthread. ok tedu@ mikeb@
* %, is not a valid format specifiermiod2011-09-181-2/+2
|
* The scheduling 'nice' value is per-process, not per-thread, so move itguenther2011-03-071-2/+2
| | | | | | into struct process. ok tedu@ deraadt@
* Correct the links between threads, processes, pgrps, and sessions,guenther2010-07-261-64/+74
| | | | | | | | | so that the process-level stuff is to/from struct process and not struct proc. This fixes a bunch of problem cases in rthreads. Based on earlier work by blambert and myself, but mostly written at c2k10. Tested by many: deraadt, sthen, krw, ray, and in snapshots
* Rollback the allproclk and fileheadlk addition. When grabbing anguenther2010-07-191-4/+1
| | | | | | | | rwlock, the thread will release biglock if it sleeps, means that atomicity from before the rw_enter() to after it is not guaranteed. The change didn't address those, so pulling it until it does. "go for it" tedu@
* A process on the zombie list can have a NULL p_pgrp if it sleeps whenguenther2010-07-101-2/+3
| | | | | | | grabbing allproclk in proc_zap(); skip such processes in sysctl(KERN_PROC*) and handle the NULL pointer in ddb's ps. ok tedu@
* Add a rwlock around the filehead and allproc lists, mainly to protecttedu2010-03-241-1/+4
| | | | | list walkers in sysctl that can block. As a reward, no more vslock. With some feedback from art, guenther, phessler. ok guenther.
* Make sure the process tree is is loop-free by forbidding ptrace()guenther2010-01-281-5/+5
| | | | | | | | of a direct ancestor, closing a localhost DoS. As an exception, do permit ptrace() of pid 1 and have inferiors() stop climbing if it hits that. ok tedu@ hpux_compat suggestion from miod@