summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_proc.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Function jailed() looks into ucred strcture, so be sure ucred is not NULL.pjd2005-03-121-4/+4
| | | | | Reviewed by: rwatson MFC after: 1 week
* Clean up a bit.pjd2005-03-121-11/+12
| | | | | Reviewed by: rwatson MFC after: 1 week
* Make a bunch of SYSCTL_NODEs static.phk2005-02-101-22/+23
|
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* Axe a.out core dump support. Neither older gdb binaries nor currentdas2004-11-271-13/+0
| | | | bfd sources understand the present format.
* Remove local definitions of RANGEOF() and use __rangeof() instead.das2004-11-201-5/+2
| | | | Also remove a few bogus casts.
* Malloc p_stats instead of putting it in the U area. We should considerdas2004-11-201-5/+44
| | | | | | simply embedding it in struct proc. Reviewed by: arch@
* Remove duplicate line.julian2004-10-101-1/+0
|
* Rework how we store process times in the kernel such that we always storejhb2004-10-051-13/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the raw values including for child process statistics and only compute the system and user timevals on demand. - Fix the various kern_wait() syscall wrappers to only pass in a rusage pointer if they are going to use the result. - Add a kern_getrusage() function for the ABI syscalls to use so that they don't have to play stackgap games to call getrusage(). - Fix the svr4_sys_times() syscall to just call calcru() to calculate the times it needs rather than calling getrusage() twice with associated stackgap, etc. - Add a new rusage_ext structure to store raw time stats such as tick counts for user, system, and interrupt time as well as a bintime of the total runtime. A new p_rux field in struct proc replaces the same inline fields from struct proc (i.e. p_[isu]ticks, p_[isu]u, and p_runtime). A new p_crux field in struct proc contains the "raw" child time usage statistics. ruadd() has been changed to handle adding the associated rusage_ext structures as well as the values in rusage. Effectively, the values in rusage_ext replace the ru_utime and ru_stime values in struct rusage. These two fields in struct rusage are no longer used in the kernel. - calcru() has been split into a static worker function calcru1() that calculates appropriate timevals for user and system time as well as updating the rux_[isu]u fields of a passed in rusage_ext structure. calcru() uses a copy of the process' p_rux structure to compute the timevals after updating the runtime appropriately if any of the threads in that process are currently executing. It also now only locks sched_lock internally while doing the rux_runtime fixup. calcru() now only requires the caller to hold the proc lock and calcru1() only requires the proc lock internally. calcru() also no longer allows callers to ask for an interrupt timeval since none of them actually did. - calcru() now correctly handles threads executing on other CPUs. - A new calccru() function computes the child system and user timevals by calling calcru1() on p_crux. Note that this means that any code that wants child times must now call this function rather than reading from p_cru directly. This function also requires the proc lock. - This finishes the locking for rusage and friends so some of the Giant locks in exit1() and kern_wait() are now gone. - The locking in ttyinfo() has been tweaked so that a shared lock of the proctree lock is used to protect the process group rather than the process group lock. By holding this lock until the end of the function we now ensure that the process/thread that we pick to dump info about will no longer vanish while we are trying to output its info to the console. Submitted by: bde (mostly) MFC after: 1 month
* The zone from which proc structures are allocated is markeddas2004-09-191-16/+5
| | | | | | | UMA_ZONE_NOFREE to guarantee type stability, so proc_fini() should never be called. Move an assertion from proc_fini() to proc_dtor() and garbage-collect the rest of the unreachable code. I have retained vm_proc_dispose(), since I consider its disuse a bug.
* Refactor a bunch of scheduler code to give basically the same behaviourjulian2004-09-051-28/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | but with slightly cleaned up interfaces. The KSE structure has become the same as the "per thread scheduler private data" structure. In order to not make the diffs too great one is #defined as the other at this time. The KSE (or td_sched) structure is now allocated per thread and has no allocation code of its own. Concurrency for a KSEGRP is now kept track of via a simple pair of counters rather than using KSE structures as tokens. Since the KSE structure is different in each scheduler, kern_switch.c is now included at the end of each scheduler. Nothing outside the scheduler knows the contents of the KSE (aka td_sched) structure. The fields in the ksegrp structure that are to do with the scheduler's queueing mechanisms are now moved to the kg_sched structure. (per ksegrp scheduler private data structure). In other words how the scheduler queues and keeps track of threads is no-one's business except the scheduler's. This should allow people to write experimental schedulers with completely different internal structuring. A scheduler call sched_set_concurrency(kg, N) has been added that notifies teh scheduler that no more than N threads from that ksegrp should be allowed to be on concurrently scheduled. This is also used to enforce 'fainess' at this time so that a ksegrp with 10000 threads can not swamp a the run queue and force out a process with 1 thread, since the current code will not set the concurrency above NCPU, and both schedulers will not allow more than that many onto the system run queue at a time. Each scheduler should eventualy develop their own methods to do this now that they are effectively separated. Rejig libthr's kernel interface to follow the same code paths as linkse for scope system threads. This has slightly hurt libthr's performance but I will work to recover as much of it as I can. Thread exit code has been cleaned up greatly. exit and exec code now transitions a process back to 'standard non-threaded mode' before taking the next step. Reviewed by: scottl, peter MFC after: 1 week
* Cause pfind() not to return processes in the PRS_NEW state. As a result,rwatson2004-08-141-1/+8
| | | | | | | | | | | | | | threads consuming the result of pfind() will not need to check for a NULL credential pointer or other signs of an incompletely created process. However, this also means that pfind() cannot be used to test for the existence or find such a process. Annotate pfind() to indicate that this is the case. A review of curent consumers seems to indicate that this is not a problem for any of them. This closes a number of race conditions that could result in NULL pointer dereferences and related failure modes. Other related races continue to exist, especially during iteration of the allproc list without due caution. Discussed with: tjr, green
* Remove typos on KASSERT messages.julian2004-08-091-3/+3
|
* * Add a "how" argument to uma_zone constructors and initialization functionsgreen2004-08-021-6/+8
| | | | | | | | | | | | | | | | | so that they know whether the allocation is supposed to be able to sleep or not. * Allow uma_zone constructors and initialation functions to return either success or error. Almost all of the ones in the tree currently return success unconditionally, but mbuf is a notable exception: the packet zone constructor wants to be able to fail if it cannot suballocate an mbuf cluster, and the mbuf allocators want to be able to fail in general in a MAC kernel if the MAC mbuf initializer fails. This fixes the panics people are seeing when they run out of memory for mbuf clusters. * Allow debug.nosleepwithlocks on WITNESS to be disabled, without changing the default. Both bmilekic and jeff have reviewed the changes made to make failable zone allocations work.
* Fill some informations about zombie processes as well.pjd2004-07-291-7/+6
| | | | | | | Before this change every zombie process were reported as an owner of PID 0 in ps(1) output. Reviewed by: julian
* Fill in the values for the ki_tid and ki_numthreads which have beengad2004-06-201-0/+2
| | | | | | | added to kproc_info. PR: bin/65803 (a tiny part...) Submitted by: Cyrille Lefevre
* Add a call to calcru() to update the kproc_info fields of ki_rusage.ru_utimegad2004-06-201-0/+2
| | | | | | and ki_rusage.ru_stime. This greatly improves the accuracy of those fields. Suggested by: bde
* Fill in the some new fields 'struct kinfo_proc', namely ki_childstime,gad2004-06-191-4/+22
| | | | | | | | | | | ki_childutime, and ki_emul. Also uses the timevaladd() routine to correct the calculation of ki_childtime. That will correct the value returned when ki_childtime.tv_usec > 1,000,000. This also implements a new KERN_PROC_GID option for kvm_getprocs(). (there will be a similar update to lib/libkvm/kvm_proc.c) Submitted by: Cyrille Lefevre
* Second half of the dev_t cleanup.phk2004-06-171-2/+2
| | | | | | | | | | | The big lines are: NODEV -> NULL NOUDEV -> NODEV udev_t -> dev_t udev2dev() -> findcdev() Various minor adjustments including handling of userland access to kernel space struct cdev etc.
* Nice, is a property of a process as a whole..julian2004-06-161-1/+1
| | | | | I mistakenly moved it to the ksegroup when breaking up the process structure. Put it back in the proc structure.
* Reference count struct tty.phk2004-06-091-1/+3
| | | | | | | | | | | Add two new functions: ttyref() and ttyrel(). ttymalloc() creates a struct tty with a reference count of one. when ttyrel sees the count go to zero, struct tty is freed. Hold references for open ttys and for ttys which are controlling terminal for sessions. Until drivers start using ttyrel(), this commit will make no difference.
* Fix a race in destruction of sessions.phk2004-06-091-2/+3
|
* Implement the new KERN_PROC_RGID option, and also implement thegad2004-05-221-0/+28
| | | | | | | | KERN_PROC_SESSION option which had been previously defined but never implemented. PR: bin/65803 (a very tiny piece of the PR)` Submitted by: Cyrille Lefevre
* Remove advertising clause from University of California Regent's license,imp2004-04-051-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core
* Remove ps_argsopen check. It is was bogus in the past and was correctedpjd2004-04-011-5/+0
| | | | | | | not quite well by me - if kern.ps_argsopen was set to 0, users weren't permitted to see arguments of even own processes. But kern.ps_argsopen is going away, so just remove this check and leave security checks for p_cansee() function.
* Fix information leakage.pjd2004-03-171-1/+6
| | | | | | | | | | | | | Without this fix it is possible to cheat policies like: - sysctl security.bsd.see_other_[gu]ids=0, - mac_seeotheruids(4), - jail(2) and get full processes list with their arguments. This problem exists from revision 1.62 of kern_proc.c when it was introduced. Reviewed by: nectar, rwatson.
* Split the mlock() kernel code into two parts, mlock(), which unpackstruckman2004-02-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the syscall arguments and does the suser() permission check, and kern_mlock(), which does the resource limit checking and calls vm_map_wire(). Split munlock() in a similar way. Enable the RLIMIT_MEMLOCK checking code in kern_mlock(). Replace calls to vslock() and vsunlock() in the sysctl code with calls to kern_mlock() and kern_munlock() so that the sysctl code will obey the wired memory limits. Nuke the vslock() and vsunlock() implementations, which are no longer used. Add a member to struct sysctl_req to track the amount of memory that is wired to handle the request. Modify sysctl_wire_old_buffer() to return an error if its call to kern_mlock() fails. Only wire the minimum of the length specified in the sysctl request and the length specified in its argument list. It is recommended that sysctl handlers that use sysctl_wire_old_buffer() should specify reasonable estimates for the amount of data they want to return so that only the minimum amount of memory is wired no matter what length has been specified by the request. Modify the callers of sysctl_wire_old_buffer() to look for the error return. Modify sysctl_old_user to obey the wired buffer length and clean up its implementation. Reviewed by: bms
* Add sysctls to allow showing threads for pgrp, tty, uid, ruid,deischen2004-02-221-7/+31
| | | | and pid.
* - Update the sched api. sched_{add,rem,clock,pctcpu} now all accept a tdjeff2003-10-161-6/+3
| | | | argument rather than a kse.
* The KERN_PROC_PROC sysctl took 4 args in 5.0-REL and 5.1-REL. We need topeter2003-10-151-1/+4
| | | | | accept this for a bit longer. Requiring the new order of 3 args only was not very helpful.
* Remove support for the unused 4th component of the KERN_PROC_PROC sysctl.tjr2003-10-061-6/+0
|
* Allow the KERN_PROC_PROC sysctl to be used without the useless 4thtjr2003-09-191-6/+18
| | | | | name component, for consistency with KERN_PROC_ALL. Support for the 4-argument form will be removed some time before 5.2-R.
* kse.h is not needed for these files.davidxu2003-08-051-1/+0
|
* Correct six return statements which returned zero instead ofrobert2003-07-171-9/+10
| | | | | | | | | | an appropriate error number after a failure condition. In particular, three of the changed statements return ESRCH for a failed pfind(), and in also three places a non-zero return from p_cansee() will be passed back, Also noticed by: rwatson
* Make the system call vector name of a process accessible to userrobert2003-07-121-0/+29
| | | | | land applications by introducing the KERN_PROC_SV_NAME sysctl node, which is searchable by PID.
* Drop the proc lock around SYSCTL_OUT in the no-threads case.scottl2003-06-171-0/+2
| | | | Submitted by: truckman
* Move the *_new_altkstack() and *_dispose_altkstack() functions out of thealc2003-06-141-1/+1
| | | | | various pmap implementations into the machine-independent vm. They were all identical.
* Add support to sysctl_kern_proc to return all threads in a proc, not just thescottl2003-06-121-56/+90
| | | | | | first one. The old behaviour can be switched by specifying KERN_PROC_PROC. Submitted by: julian, tweaks and added functionality by myself
* Use __FBSDID().obrien2003-06-111-1/+3
|
* - Merge struct procsig with struct sigacts.jhb2003-05-131-3/+7
| | | | | | | | | | | | | | | | | - Move struct sigacts out of the u-area and malloc() it using the M_SUBPROC malloc bucket. - Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(), sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared(). - Remove the p_sigignore, p_sigacts, and p_sigcatch macros. - Add a mutex to struct sigacts that protects all the members of the struct. - Add sigacts locking. - Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now that sigacts is locked. - Several in-kernel functions such as psignal(), tdsignal(), trapsignal(), and thread_stopped() are now MP safe. Reviewed by: arch@ Approved by: re (rwatson)
* Initialize and destroy the struct proc mutex in the proc zone's init andjhb2003-05-011-0/+3
| | | | | | | fini routines instead of in fork() and wait(). This has the nice side benefit that the proc lock of any process on the allproc list is always valid and sched_lock doesn't have to be used to test against PRS_NEW anymore.
* Instead of recording the Unix time in a process when it starts, record thedes2003-05-011-2/+1
| | | | | | | uptime. Where necessary, convert it back to Unix time by adding boottime to it. This fixes a potential problem in the accounting code, which would compute the elapsed time incorrectly if the Unix time was stepped during the lifetime of the process.
* Include altkstack pages in the RSS regardless of whether the processtjr2003-04-251-8/+6
| | | | is swapped out. Pointed out by jhb.
* It seems that 1 was not a magic value as I thought, but a coincidence.des2003-04-241-2/+2
| | | | | | | | Instead of applying the adjustment to processes with a start time of 1, apply it to all processes with a start time of less than 3600. None of this would be necessary if the start times were recorded in ticks instead of seconds and microseconds.
* Do a better job of calculating the RSS for swapped-out processes:tjr2003-04-241-3/+9
| | | | | | | | don't include the kernel stacks of swapped-out threads in the page count, but do include the alternate kernel stack. jhb provided some helpful comments on this. PR: 49102
* When filling out a kinfo_proc structure, if we come across a processdes2003-04-241-0/+2
| | | | | | whose p_stats->p_start has the magic value 1, replace it with boottime. Some users were apparently confused by the fact that ps(1) reported a start time in early 1970 for system processes.
* - Add a static function pgadjustjobc() to adjust the job control count forjhb2003-04-181-36/+42
| | | | | | | | | a process group. - Call pgadjustjobc() twice in fixjobc() to avoid code duplication and improve readability. - Use the proc lock to protect P_SHOULDSTOP() instead of sched_lock. - Check to see if a process is PRS_NEW with sched_lock before trying to lock its proc lock since the lock may not be constructed yet.
* Move the _oncpu entry from the KSE to the thread.julian2003-04-101-1/+1
| | | | | The entry in the KSE still exists but it's purpose will change a bit when we add the ability to lock a KSE to a cpu.
* - Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread withjeff2003-03-311-3/+6
| | | | | | | a follow on commit to kern_sig.c - signotify() now operates on a thread since unmasked pending signals are stored in the thread. - PS_NEEDSIGCHK moves to TDF_NEEDSIGCHK.
* - Cache a reference to the credential of the thread that starts a ktrace injhb2003-03-131-1/+1
| | | | | | | | | | | struct proc as p_tracecred alongside the current cache of the vnode in p_tracep. This credential is then used for all later ktrace operations on this file rather than using the credential of the current thread at the time of each ktrace event. - Now that we have multiple ktrace-related items in struct proc that are pointers, rename p_tracep to p_tracevp to make it less ambiguous. Requested by: rwatson (1)
OpenPOWER on IntegriCloud