summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.c
Commit message (Collapse)AuthorAgeFilesLines
* - Don't set td_priority directly here, use sched_prio().jeff2003-10-271-1/+1
|
* Extend the mutex pool implementation to permit the creation and use oftruckman2003-07-131-1/+1
| | | | | | | | | | | | | | | | multiple mutex pools with different options and sizes. Mutex pools can be created with either the default sleep mutexes or with spin mutexes. A dynamically created mutex pool can now be destroyed if it is no longer needed. Create two pools by default, one that matches the existing pool that uses the MTX_NOWITNESS option that should be used for building higher level locks, and a new pool with witness checking enabled. Modify the users of the existing mutex pool to use the appropriate pool in the new implementation. Reviewed by: jhb
* Use __FBSDID().obrien2003-06-111-1/+3
|
* Remove Giant from [gs]etpriority().jhb2003-04-231-6/+0
|
* Lock both the proc lock and sched_lock when calling sched_nice sincejhb2003-04-221-0/+2
| | | | | | kg_nice is now protected by both. Being protected by both means that other places in the kernel that want to read kg_nice only need one of the two locks.
* Add a couple of sched_lock asserts.jhb2003-04-181-0/+2
|
* - Adjust sched hooks for fork and exec to take processes as arguments insteadjeff2003-04-111-1/+1
| | | | | | | | | | of ksegs since they primarily operation on processes. - KSEs take ticks so pass the kse through sched_clock(). - Add a sched_class() routine that adjusts a ksegrp pri class. - Define a sched_fork_{kse,thread,ksegrp} and sched_exit_{kse,thread,ksegrp} that will be used to tell the scheduler about new instances of these structures within the same process. These will be used by THR and KSE. - Change sched_4bsd to reflect this API update.
* Back out previous. The locking here needs a rethink.tjr2003-03-131-15/+3
|
* Acquire sched_lock around use of FOREACH_KSEGRP_IN_PROC, accessestjr2003-03-121-3/+15
| | | | | to kg_nice and calls to sched_nice() in getpriority() and setpriority() (really donice()).
* Remove the PL_SHAREMOD flag from struct plimit, which could have beentjr2003-02-201-3/+1
| | | | | | used to share resource limits between rfork threads, but never was. Removing it makes resource limit locking much simpler -- only the current process can change the contents of the structure that p_limit points to.
* Back out M_* changes, per decision of the TRB.imp2003-02-191-2/+2
| | | | Approved by: trb
* - Move ke_sticks, ke_iticks, ke_uticks, ke_uu, ke_su, and ke_iu back intojeff2003-02-171-74/+60
| | | | | | | the proc. These counters are only examined through calcru. Submitted by: davidxu Tested on: x86, alpha, UP/SMP
* Add an XXX comment noting that getrusage() accesses p_stats->p_rutjr2003-02-131-0/+1
| | | | and p_stats->p_cru without holding the appropriate locks.
* Reversion of commit by Davidxu plus fixes since applied.julian2003-02-011-60/+74
| | | | | | | | I'm not convinced there is anything major wrong with the patch but them's the rules.. I am using my "David's mentor" hat to revert this as he's offline for a while.
* Move UPCALL related data structure out of kse, introduce a newdavidxu2003-01-261-74/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | data structure called kse_upcall to manage UPCALL. All KSE binding and loaning code are gone. A thread owns an upcall can collect all completed syscall contexts in its ksegrp, turn itself into UPCALL mode, and takes those contexts back to userland. Any thread without upcall structure has to export their contexts and exit at user boundary. Any thread running in user mode owns an upcall structure, when it enters kernel, if the kse mailbox's current thread pointer is not NULL, then when the thread is blocked in kernel, a new UPCALL thread is created and the upcall structure is transfered to the new UPCALL thread. if the kse mailbox's current thread pointer is NULL, then when a thread is blocked in kernel, no UPCALL thread will be created. Each upcall always has an owner thread. Userland can remove an upcall by calling kse_exit, when all upcalls in ksegrp are removed, the group is atomatically shutdown. An upcall owner thread also exits when process is in exiting state. when an owner thread exits, the upcall it owns is also removed. KSE is a pure scheduler entity. it represents a virtual cpu. when a thread is running, it always has a KSE associated with it. scheduler is free to assign a KSE to thread according thread priority, if thread priority is changed, KSE can be moved from one thread to another. When a ksegrp is created, there is always N KSEs created in the group. the N is the number of physical cpu in the current system. This makes it is possible that even an userland UTS is single CPU safe, threads in kernel still can execute on different cpu in parallel. Userland calls kse_create to add more upcall structures into ksegrp to increase concurrent in userland itself, kernel is not restricted by number of upcalls userland provides. The code hasn't been tested under SMP by author due to lack of hardware. Reviewed by: julian
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-2/+2
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* - Create a new scheduler api that is defined in sys/sched.hjeff2002-10-121-2/+2
| | | | | | | | | | - Begin moving scheduler specific functionality into sched_4bsd.c - Replace direct manipulation of scheduler data with hooks provided by the new api. - Remove KSE specific state modifications and single runq assumptions from kern_switch.c Reviewed by: -arch
* - Move p_cpulimit to struct proc from struct plimit and protect it withjhb2002-10-091-4/+3
| | | | | | | | | | | | | | | sched_lock. This means that we no longer access p_limit in mi_switch() and the p_limit pointer can be protected by the proc lock. - Remove PRS_ZOMBIE check from CPU limit test in mi_switch(). PRS_ZOMBIE processes don't call mi_switch(), and even if they did there is no longer the danger of p_limit being NULL (which is what the original zombie check was added for). - When we bump the current processes soft CPU limit in ast(), just bump the private p_cpulimit instead of the shared rlimit. This fixes an XXX for some value of fix. There is still a (probably benign) bug in that this code doesn't check that the new soft limit exceeds the hard limit. Inspired by: bde (2)
* Change p_cpulimit to be in seconds instead of microseconds. Sincejhb2002-09-301-2/+1
| | | | | | | p_runtime now is a bintime, it is no longer an optimization to store p_cpulimit as microseconds. Suggested by: phk
* Use the fields in the sysentvec and in the vm map header in place of thejake2002-09-211-3/+6
| | | | | | | | constants VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK and PS_STRINGS. This is mainly so that they can be variable even for the native abi, based on different machine types. Get stack protections from the sysentvec too. This makes it trivial to map the stack non-executable for certain abis, on machines that support it.
* Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.julian2002-09-151-20/+48
| | | | | | | | | next step is to allow > 1 to be allocated per process. This would give multi-processor threads. (when the rest of the infrastructure is in place) While doing this I noticed libkvm and sys/kern/kern_proc.c:fill_kinfo_proc are diverging more than they should.. corrective action needed soon.
* Widen struct sockbuf's sb_timeo member to int from short. Withjdp2002-07-241-2/+2
| | | | | | | | | | | | | non-default but reasonable values of hz this member overflowed, breaking NFS over UDP. Also, as long as I'm plowing up struct sockbuf ... Change certain members from u_long/long to u_int/int in order to reduce wasted space on 64-bit machines. This change was requested by Andrew Gallatin. Netstat and systat need to be rebuilt. I am incrementing __FreeBSD_version in case any ports need to change.
* more caddr_t removal.alfred2002-06-291-8/+5
|
* Change p_can{debug,see,sched,signal}()'s first argument to be a threadjhb2002-05-191-9/+9
| | | | | | | 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.
* Lock proctree_lock instead of pgrpsess_lock.jhb2002-04-161-6/+6
|
* - Change donice() to take a thread as the first argument instead of ajhb2002-04-131-37/+40
| | | | | | | | | | | | | | | process so it can use td_ucred. - Require the target process of donice() to be locked when donice() is called. - Use td_ucred. - Lock the target process of p_cansee() and while reading the credentials of a process. - Change the logic of rtprio() slightly so it does it's copyin() if needed prior to locking the target process. - rtprio() no longer needs Giant. In theory with full KSE it would still need Giant to protect p_ucred of curproc for the p_canfoo() functions but p_canfoo() will be changing to using td_ucred of curthread before full KSE hits the tree.
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-1/+1
| | | | | | | 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
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-3/+3
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* Remove __P.alfred2002-03-191-2/+2
|
* Cast the variable, not the constant to 64 bits.phk2002-02-261-1/+1
|
* Lock struct pgrp, session and sigio.tanimura2002-02-231-6/+28
| | | | | | | | | | | | | | | | | | | | | | | | | 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-13/+9
|
* In a threaded world, differnt priorirites become properties ofjulian2002-02-111-15/+17
| | | | | | different entities. Make it so. Reviewed by: jhb@freebsd.org (john baldwin)
* use mutex pool mutexes for uidinfo locking.alfred2002-01-201-15/+15
| | | | | | | replace mutex_lock calls on uidinfo with macro calls: mtx_lock(&uidp->ui_mtx) -> UIDINFO_LOCK(uidp) Terry Lambert <tlambert2@mindspring.com> helped with this.
* *** empty log message ***peter2001-11-041-3/+3
|
* o Move suser() calls in kern/ to using suser_xxx() with an explicitrwatson2001-11-011-2/+3
| | | | | | | | | credential selection, rather than reference via a thread or process pointer. This is part of a gradual migration to suser() accepting a struct ucred instead of a struct proc, simplifying the reference and locking semantics of suser(). Obtained from: TrustedBSD Project
* Adjust printfs to be time_t agnostic.dillon2001-10-281-3/+3
|
* Make MAXTSIZ, DFLDSIZ, MAXDSIZ, DFLSSIZ, MAXSSIZ, SGROWSIZ loaderps2001-10-101-9/+8
| | | | | | | tunable. Reviewed by: peter MFC after: 2 weeks
* KSE Milestone 2julian2001-09-121-99/+124
| | | | | | | | | | | | | | 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
* Use sched_lock to protect rtp_to_pri() and pri_to_rtp() when needed.jhb2001-09-021-0/+4
|
* Giant Pushdown. Saved the worst P4 tree breakage for last.dillon2001-09-011-21/+81
| | | | | | | | | | | | reboot() getpriority() setpriority() rtprio() osetrlimit() ogetrlimit() setrlimit() getrlimit() getrusage() getpid() getppid() getpgrp() getpgid() getsid() getgid() getegid() getgroups() setsid() setpgid() setuid() seteuid() setgid() setegid() setgroups() setreuid() setregid() setresuid() setresgid() getresuid() getresgid () __setugid() getlogin() setlogin() modnext() modfnext() modstat() modfind() kldload() kldunload() kldfind() kldnext() kldstat() kldfirstmod() kldsym() getdtablesize() dup2() dup() fcntl() close() ofstat() fstat() nfsstat() fpathconf() flock()
* add prototype for dosetrlimitassar2001-07-221-2/+0
|
* o Replace calls to p_can(..., P_CAN_xxx) with calls to p_canxxx().rwatson2001-07-051-9/+9
| | | | | | | | | | | | | | | | | | | | | The p_can(...) construct was a premature (and, it turns out, awkward) abstraction. The individual calls to p_canxxx() better reflect differences between the inter-process authorization checks, such as differing checks based on the type of signal. This has a side effect of improving code readability. o Replace direct credential authorization checks in ktrace() with invocation of p_candebug(), while maintaining the special case check of KTR_ROOT. This allows ktrace() to "play more nicely" with new mandatory access control schemes, as well as making its authorization checks consistent with other "debugging class" checks. o Eliminate "privused" construct for p_can*() calls which allowed the caller to determine if privilege was required for successful evaluation of the access control check. This primitive is currently unused, and as such, serves only to complicate the API. Approved by: ({procfs,linprocfs} changes) des Obtained from: TrustedBSD Project
* With Alfred's permission, remove vm_mtx in favor of a fine-grained approachdillon2001-07-041-2/+2
| | | | | | | | | (this commit is just the first stage). Also add various GIANT_ macros to formalize the removal of Giant, making it easy to test in a more piecemeal fashion. These macros will allow us to test fine-grained locks to a degree before removing Giant, and also after, and to remove Giant in a piecemeal fashion via sysctl's on those subsystems which the authors believe can operate without Giant.
* Introduce a global lock for the vm subsystem (vm_mtx).alfred2001-05-191-0/+2
| | | | | | | | | | | | | | | | | | | vm_mtx does not recurse and is required for most low level vm operations. faults can not be taken without holding Giant. Memory subsystems can now call the base page allocators safely. Almost all atomic ops were removed as they are covered under the vm mutex. Alpha and ia64 now need to catch up to i386's trap handlers. FFS and NFS have been tested, other filesystems will need minor changes (grabbing the vm lock when twiddling page properties). Reviewed (partially) by: jake, jhb
* Make rtprio work again.jake2001-04-291-19/+14
| | | | | | | | | | - add a missing break which caused RTP_SET to always return EINVAL - break instead of returning if p_can fails so proc_lock is always dropped correctly - only copyin data that is actually needed - use break instead of goto - make rtp_to_pri return EINVAL instead of -1 if the values are out or range so we don't have to translate
* Change the pfind() and zpfind() functions to lock the process that theyjhb2001-04-241-24/+36
| | | | | | find before releasing the allproc lock and returning. Reviewed by: -smp, dfr, jake
* o Limit process information leakage by introducing a p_can(...P_CAN_SEE...)rwatson2001-04-121-0/+2
| | | | | | in rtprio()'s RTP_LOOKIP implementation. Obtained from: TrustedBSD Project
* Convert the allproc and proctree locks from lockmgr locks to sx locks.jhb2001-03-281-4/+5
|
* Catch up to header include changes:jhb2001-03-281-2/+2
| | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
OpenPOWER on IntegriCloud