summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.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@
* setpriority(2): don't treat booleans as scalarscheloha2020-09-251-5/+5
| | | | | | | | | | | | The variable "found" in sys_setpriority() is used as a boolean. We should set it to 1 to indicate that we found the object we were looking for instead of incrementing it. deraadt@ notes that the current code is not buggy, because OpenBSD cannot support anywhere near 2^32 processes, but agrees that incrementing the variable signals the wrong thing to the reader. ok millert@ deraadt@
* Stop calling resched_proc() after changing the nice(3) value of a process.mpi2019-07-151-2/+1
| | | | | | | | | | | Changing the scheduling priority of a process happens rarely, so it isn't strictly necessary to update the current priority of every threads instantly. Moreover resched_proc() isn't well suited to perform this action: it doesn't consider the state of each thread nor move them to another runqueue. ok visa@
* Untangle code setting the scheduling priority of a thread.mpi2019-07-081-3/+5
| | | | | | | | | | | | | | | - `p_estcpu' and `p_usrpri' represent the priority and are now only set in a single function. - Call resched_proc() after updating the priority and stop calling it from schedclock() since `spc_curpriority' should match curproc's priority. - Rename updatepri() to match decay_cpu() and stop updating per-thread member. - Merge two resched_proc() in one inside setrunnable(). Tweak and ok visa@
* Guard uvm_map_protect() with kernel lock to prepare dosetrlimit()visa2019-06-241-1/+3
| | | | | | for unlocking. OK semarie@ mpi@ deraadt@ anton@
* Make resource limit access MP-safe. So far, the copy-on-write sharingvisa2019-06-211-22/+168
| | | | | | | | | | of resource limit structs has been done between processes. By applying copy-on-write also between threads, threads can read rlimits in a nearly lock-free manner. Inspired by code in DragonFly BSD and FreeBSD. OK mpi@, agreement from jmatthew@ and anton@
* Avoid changing resource limits in rucheck() by introducing a new statevisa2019-06-101-8/+9
| | | | | | | variable that tracks when to send next SIGXCPU. This eases MP work and prevents accidental alteration of shared resource limit structs. OK mpi@ semarie@
* Move initialization of limit0 into a dedicated function. This newvisa2019-06-021-8/+24
| | | | | | | | | function is also a proper place for setting up the plimit pool. While here, raise the IPL of the plimit pool to IPL_MPFLOOR, needed in upcoming MP work. OK claudio@
* Revert to using the SCHED_LOCK() to protect time accounting.mpi2019-06-011-30/+25
| | | | | | | | | It currently creates a lock ordering problem because SCHED_LOCK() is taken by hardclock(). That means the "priorities" of a thread should be moved out of the SCHED_LOCK() first in order to make progress. Reported-by: syzbot+8e4863b3dde88eb706dc@syzkaller.appspotmail.com via anton@ as well as by kettenis@
* Use a per-process mutex to protect time accounting instead of SCHED_LOCK().mpi2019-05-311-25/+30
| | | | | | | Note that hardclock(9) still increments p_{u,s,i}ticks without holding a lock. ok visa@, cheloha@
* Rename struct plimit field p_refcnt to pl_refcnt to avoid confusionvisa2019-05-311-4/+4
| | | | | | | with the fields of struct proc. Make pl_refcnt unsigned for upcoming atomic updating. OK deraadt@ guenther@
* Fix unsafe use of ptsignal() in mi_switch().visa2019-01-061-1/+39
| | | | | | | | | | | | | | | | | | ptsignal() has to be called with the kernel lock held. As ensuring the locking in mi_switch() is not easy, and deferring the signaling using the task API is not possible because of lock order issues in mi_switch(), move the CPU time checking into a periodic timer where the kernel can be locked without issues. With this change, each process has a dedicated resource check timer. The timer gets activated only when a CPU time limit is set. Because the checking is not done as frequently as before, some precision is lost. Use of timers adapted from FreeBSD. OK tedu@ Reported-by: syzbot+2f5d62256e3280634623@syzkaller.appspotmail.com
* Remove almost unused `flags' argument of suser().mpi2018-02-191-3/+3
| | | | | | | The account flag `ASU' will no longer be set but that makes suser() mpsafe since it no longer mess with a per-process field. No objection from millert@, ok tedu@, bluhm@
* all pools have their ipl set via pool_setipl, so fold it into pool_init.dlg2016-09-151-4/+3
| | | | | | | | | | | | | | | | | | | | | | 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);
* pool_setipldlg2016-08-251-1/+2
| | | | ok kettenis@
* remove stale lint annotationstedu2015-12-051-5/+1
|
* Stop using USRSTACK as the edge of the stack, but rather use the vmspacemiod2015-02-091-6/+11
| | | | | | | | vm_minsaddr or vm_maxsaddr, depending upon the direction the stack goes in. This should have no effect on the existing behaviourrr. ok kettenis@ deraadt@
* start retiring the nointr allocator. specify PR_WAITOK as a flag as atedu2014-12-191-3/+3
| | | | marker for which pools are not interrupt safe. ok dlg
* convert bcopy to memcpy. ok millerttedu2014-12-101-2/+2
|
* Replace a plethora of historical protection options with justderaadt2014-11-161-3/+3
| | | | | | | PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h. PROT_MASK is introduced as the one true way of extracting those bits. Remove UVM_ADV_* wrapper, using the standard names. ok doug guenther kettenis
* Eliminates struct pcred by moving the real and saved ugids intoguenther2014-03-301-7/+7
| | | | | | | | | 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@
* exit1() needs to do a final aggregation of the thread's [us]ticksguenther2014-01-241-3/+7
| | | | | | | | and runtime to the process totals. Also, add ktracing of struct rusage in wait4() and getrusage(). problem pointed out by tedu@ ok deraadt@
* bzero -> memsettedu2014-01-211-2/+2
|
* Threads can't be zombies, only processes, so change zombproc to zombprocess,guenther2014-01-201-14/+9
| | | | | | | | 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@
* Move the declarations for dogetrusage(), itimerround(), and dowait4()guenther2013-10-251-3/+1
| | | | | | | | | | to sys/*.h headers so that the compat/linux code can use them. Change dowait4() to not copyout() the status value, but rather leave that for its caller, as compat/linux has to translate it, with the side benefit of simplifying the native code. Originally written months ago as part of the time_t work; long memory, prodding, and ok from pirofti@
* Eliminate the unused retval argument from dogetrusage()guenther2013-09-141-4/+4
|
* Snapshots for all archs have been built, so remove the T32 codeguenther2013-09-141-23/+1
|
* Switch time_t, ino_t, clock_t, and struct kevent's ident and dataguenther2013-08-131-11/+42
| | | | | | | | | | | | | | | | | | | | members to 64bit types. Assign new syscall numbers for (almost all) the syscalls that involve the affected types, including anything with time_t, timeval, itimerval, timespec, rusage, dirent, stat, or kevent arguments. Add a d_off member to struct dirent and replace getdirentries() with getdents(), thus immensely simplifying and accelerating telldir/seekdir. Build perl with -DBIG_TIME. Bump the major on every single base library: the compat bits included here are only good enough to make the transition; the T32 compat option will be burned as soon as we've reached the new world are are happy with the snapshots for all architectures. DANGER: ABI incompatibility. Updating to this kernel requires extra work or you won't be able to login: install a snapshot instead. Much assistance in fixing userland issues from deraadt@ and tedu@ and build assistance from todd@ and otto@
* Convert some internal APIs to use timespecs instead of timevalsguenther2013-06-031-17/+31
| | | | ok matthew@ deraadt@
* Make setrlimit() return EINVAL if rlim_cur > rlim_max, per POSIX.guenther2013-04-011-5/+4
| | | | | | Use limfree() instead of decrementing the reference counter directly. ok kettenis@
* Make the KERN_NPROCS and KERN_MAXPROC sysctl()s and the RLIMIT_NPROC rlimitguenther2012-04-101-2/+2
| | | | | | | | 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@
* Make rusage totals, itimers, and profile settings per-process insteadguenther2012-03-231-32/+59
| | | | | | | of per-rthread. Handling of per-thread tick and runtime counters inspired by how FreeBSD does it. ok kettenis@
* Add tracing and dumping of "pointer to struct" syscall arguments forguenther2012-03-191-3/+15
| | | | | | structs timespec, timeval, sigaction, and rlimit. ok otto@ jsing@
* The scheduling 'nice' value is per-process, not per-thread, so move itguenther2011-03-071-15/+11
| | | | | | into struct process. ok tedu@ deraadt@
* Correct the links between threads, processes, pgrps, and sessions,guenther2010-07-261-27/+65
| | | | | | | | | 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
* Eliminate struct plimit's PL_SHAREMOD flag: it was for COMPAT_IRIXguenther2010-06-291-4/+2
| | | | | sproc() support, but we don't have COMPAT_IRIX. ok krw@ tedu@
* Don't decrement the refcnt on a plimits until after we're doneguenther2010-01-041-3/+6
| | | | | | | copying it, so that the process can't sleep in pool_get() and have the source structure get pool_put() or modified behind its back. ok deraadt@
* Use LIST_FOREACH() instead of handrolling.thib2008-05-221-3/+3
| | | | | From: Pierre Riteau pierre.riteau_att_gmail.com OK miod@
* move p_limit and p_cred into struct processtedu2007-04-121-5/+5
| | | | | leave macros behind for now to keep the commit small ok art beck miod pedro
* ansi/deregister.jsg2005-11-281-49/+25
| | | | 'go for it' deraadt@
* sched work by niklas and art backed out; causes panicsderaadt2005-05-291-2/+2
|
* This patch is mortly art's work and was done *a year* ago. Art wants to thankniklas2005-05-251-2/+2
| | | | | | | | | | | | | | | | everyone for the prompt review and ok of this work ;-) Yeah, that includes me too, or maybe especially me. I am sorry. Change the sched_lock to a mutex. This fixes, among other things, the infamous "telnet localhost &" problem. The real bug in that case was that the sched_lock which is by design a non-recursive lock, was recursively acquired, and not enough releases made us hold the lock in the idle loop, blocking scheduling on the other processors. Some of the other processors would hold the biglock though, which made it impossible for cpu 0 to enter the kernel... A nice deadlock. Let me just say debugging this for days just to realize that it was all fixed in an old diff noone ever ok'd was somewhat of an anti-climax. This diff also changes splsched to be correct for all our architectures.
* Use list and queue macros where applicable to make the code easier to read;miod2004-12-261-4/+3
| | | | no change in compiler assembly output.
* debranch SMP, have funniklas2004-06-131-1/+5
|
* Add id_t type as per POSIX and use it for [gs]etpriority(2).millert2003-12-111-3/+3
| | | | OK henning@ and deraadt@
* POSIX says rlim_t should be unsigned so make it u_quad_t. Also addmillert2003-12-111-4/+1
| | | | | POSIX-mandated RLIM_SAVED_MAX and RLIM_SAVED_CUR defines. On OpenBSD these are identical to RLIM_INFINITY as allowed by POSIX. OK deraadt@
* match syscallargs comments with realityhenning2003-09-011-2/+2
| | | | | from Patrick Latifi <patrick.l@hermes.usherb.ca> ok jason@ tedu@
* change arguments to suser. suser now takes the process, and a flagstedu2003-08-151-3/+3
| | | | | | | | | argument. old cred only calls user suser_ucred. this will allow future work to more flexibly implement the idea of a root process. looks like something i saw in freebsd, but a little different. use of suser_ucred vs suser in file system code should be looked at again, for the moment semantics remain unchanged. review and input from art@ testing and further review miod@
* Remove the advertising clause in the UCB license which Berkeleymillert2003-06-021-6/+2
| | | | rescinded 22 July 1999. Proofed by myself and Theo.