summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* pass size argument to free()deraadt2014-11-031-2/+2
| | | | ok doug tedu
* Delete procfs; it's always had races and is now unused: no one noticed forguenther2014-09-081-2/+2
| | | | | | months that I broke it before the 5.5 release. confirmed as not being required by ports by sthen@, ajacoutot@, dcoppa@
* KERNEL_ASSERT_LOCKED(9): Assertion for kernel lock (Rev. 3)uebayasi2014-07-131-2/+2
| | | | | | | | | | | | | | | This adds a new assertion macro, KERNEL_ASSERT_LOCKED(), to assert that kernel_lock is held. In the long process of removing kernel_lock, there will be a lot (hundreds or thousands) of use of this; virtually almost all functions in !MP-safe subsystems should have this assertion. Thus this assertion should have a short, good name. Not only that "KERNEL_ASSERT_LOCKED" is consistent with other KERNEL_* and SCHED_ASSERT_LOCKED() macros. Input from dlg@ guenther@ kettenis@. OK dlg@ guenther@
* 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.
* Use membar_producer() to force visibility instead of misusingguenther2014-07-111-6/+7
| | | | | | atomic_setbits_int() ok kettenis@
* decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.hderaadt2014-07-081-1/+2
| | | | | don't need to be married. ok guenther miod beck jsing kettenis
* fork1: FORK_THREAD requires FORK_SHAREFILESmatthew2014-07-071-2/+4
| | | | | | | | Now that file descriptor tables have moved from a per-thread resource to per-process, it's impossible to fork a thread without sharing the file descriptor table. ok guenther
* Track whether a process is a zombie or not yet fully built via flagsguenther2014-07-041-9/+15
| | | | | | | | | | | 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-16/+21
| | | | | | | | | | 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@
* Include <sys/vmmeter.h> directly instead of relying on it beingmpi2014-05-061-1/+2
| | | | | | | | | | | | | | pulled by <uvm/uvm_extern.h> and turn uvm_total() into a private function. The preferred way to get memory stats is through the VM_UVMEXP sysctl(3) since VM_METER is just a wrapper on top of it. In the kernel, use `uvmexp' directly instead of uvm_total(). This change does not remove <sys/vmmeter.h> from <uvm/uvm_extern.h> to give some more time to port maintainers to fix their ports. ok guenther@ as part of a larger diff.
* Add PS_SYSTEM, the process-level mirror of the thread-level P_SYSTEM,guenther2014-05-041-2/+6
| | | | | | | and FORK_SYSTEM as a flag to set them. This eliminates needing to peek into other processes threads in various places. Inspired by NetBSD ok miod@ matthew@
* Move the u-area allocation and pmap-magic logic to its own functionguenther2014-05-031-5/+2
| | | | | | uvm_uarea_alloc() function name from NetBSD; arm testing by miod@
* Have each thread keeps its own (counted!) reference to the process's ucredsguenther2014-04-181-2/+4
| | | | | | | | | to avoid possible use-after-free references when swapping ids in threaded processes. "Do I have the right creds?" checks are always made with the threads creds. Inspired by FreeBSD and NetBSD "right time" deraadt@
* Eliminates struct pcred by moving the real and saved ugids intoguenther2014-03-301-5/+4
| | | | | | | | | 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@
* Reduce uvm include madness. Use <uvm/uvm_extern.h> instead ofmpi2014-03-281-3/+2
| | | | | | <uvm/uvm.h> if possible and remove double inclusions. ok beck@, mlarkin@, deraadt@
* Move p_emul and p_sigcode from proc to process.guenther2014-03-261-4/+4
| | | | | | | | | 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@
* Move p_sigacts from struct proc to struct process.guenther2014-03-221-29/+27
| | | | testing help mpi@
* Eliminate the exit sig handling, which was only invokable via theguenther2014-02-121-7/+5
| | | | | | | | Linux-compat clone() syscall when *not* using CLONE_THREAD. pirofti@ confirms Opera runs in compat without this, so out it goes; one less hair to choke on in kern_exit.c ok tedu@ pirofti@
* arc4random_uniform() returns a value strictly less than its argument; fixguenther2014-02-101-2/+2
| | | | | | arithmetic so that PID_MAX can be reached. ok otto@ zhuk@ miod@
* Threads can't be zombies, only processes, so change zombproc to zombprocess,guenther2014-01-201-10/+12
| | | | | | | | 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 p_textvp from struct proc to struct process so that the exit codeguenther2014-01-201-6/+6
| | | | | | can be further simplified. ok kettenis@
* Fix delivery of SIGPROF and SIGVTALRM to threaded processes by havingguenther2013-10-081-3/+1
| | | | | | | | hardclock() set a flag on the running thread and force AST processing, and then have the thread signal itself from userret(). idea and flag names from FreeBSD ok jsing@
* The last user of the old __tfork() was updated to the current one,guenther2013-08-141-26/+1
| | | | | | | so COMPAT_O51 can go. The complete ABI role means COMPAT_O53 can be removed as well. ok jsing@ tedu@
* convert some easy bcopy to memcpy and clean up fdexpand a bit.tedu2013-06-111-10/+10
| | | | ok kettenis
* Prevent idle thread from being stolen on startup.haesbaert2013-06-061-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a race condition which might trigger a case where two cpus try to run the same idle thread. The problem arises when one cpu steals the idle proc of another cpu and this other cpu ends up running the idle thread via spc->spc_idleproc, resulting in two cpus trying to cpu_switchto(idleX). On startup, idle procs are scaterred around different runqueues, the decision for scheduling is: 1 look at my runqueue. 2 if empty, look at other dudes runqueue. 3 if empty, select idle proc via spc->spc_idleproc. The problem is that cpu0's idle0 might be running on cpu1 due to step 1 or 2 and cpu0 hits step 3. So cpu0 will select idle0, while cpu1 is in fact running it already. The solution is to never place idle on a runqueue, therefore being only selectable through spc->spc_idleproc. This race can be more easily triggered on a HT cpu on virtualized environments, where the guest more often than not doesn't have the cpu for itself, so timing gets shuffled. ok tedu@ guenther@ go ahead after t2k13 deraadt@
* factor out pid allocation to functions. add a small cache of recentlytedu2013-06-051-9/+38
| | | | | exited pids that won't get recycled. ok deraadt
* When creating a thread, don't add it to the process's thread listguenther2013-06-031-10/+11
| | | | | | | until it's fully built, so that it can't get a signal from realitexpire(), as seen by sthen@ and espie@ in ports builds. Exact bits moved down worked out with tedu@, ok deraadt@
* Convert some internal APIs to use timespecs instead of timevalsguenther2013-06-031-2/+2
| | | | ok matthew@ deraadt@
* As found by kurt, there's a twisty race between exit1 and fork1tedu2013-06-011-1/+9
| | | | | | with threaded processes. Fix this by checking for an attempt to go single threaded in fork1 and account for the new thread as well. ok espie guenther kurt
* rthreads are always enabled. remove the sysctl.tedu2013-04-061-3/+1
| | | | ok deraadt guenther kettenis matthew
* the 5.1 era tfork syscall claws its way out of the grave. we failed totedu2013-03-141-1/+26
| | | | | | fully deprecate it (notably the go port was still using it as of 5.3) so to give users a little more time to update, __tfork51 lives again. okish deraadt guenther
* No longer need the 5.1 version of the __tfork syscallguenther2013-03-021-26/+1
| | | | ok deraadt@
* If uvm_km_kmemalloc_pla() fails when just creating a thread (and not aguenther2012-11-191-3/+5
| | | | | | process), then don't decrement the total and per-user counts of processes. ok deraadt@ miod@
* Apply profiling to all threads instead of just the thread that calledguenther2012-08-021-5/+7
| | | | | | | profil() by moving P_PROFIL from proc->p_flag to process->ps_flags with matching adjustment in fork1() and exit1() ok matthew@
* __tfork() needs to set the stack address of the new thread in the kernel,guenther2012-06-211-3/+33
| | | | | | | | | so that it can't get a signal while still running on the parent thread's stack. Also, pass in sizeof(struct __tfork) to provide forward compat when more members are added. This is an ABI change, so switch syscall numbers and bump lib majors this time. ok deraadt@ matthew@
* Only set a process's start time when starting the main thread. There'sguenther2012-05-101-5/+10
| | | | | | | also no need to protect that and the setting of the AFORK accounting flag with the scheduler lock. ok mikeb@
* First stab at making ptrace(2) usable for debugging multi-threaded programs.kettenis2012-04-131-1/+2
| | | | | | | | | | It implements a full-stop model where all threads are stopped before handing over control to the debugger. Events are reported as before through wait(2); you will have to call ptrace(PT_GET_PROCESS_STATE, ...) to find out which thread hit the event. Since this changes the size of struct ptrace_state, you will have to recompile gdb. ok guenther@
* remove rfork(); ok guenther miodderaadt2012-04-121-51/+2
|
* move accounting flags to struct process; idea and ok guenthermikeb2012-04-121-2/+3
|
* Make the KERN_NPROCS and KERN_MAXPROC sysctl()s and the RLIMIT_NPROC rlimitguenther2012-04-101-16/+36
| | | | | | | | 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-7/+6
| | | | | | | of per-rthread. Handling of per-thread tick and runtime counters inspired by how FreeBSD does it. ok kettenis@
* First steps for making ptrace work with rthreads:guenther2012-02-201-23/+22
| | | | | | | | | | - move the P_TRACED and P_INEXEC flags, and p_oppid, p_ptmask, and p_ptstat member from struct proc to struct process - sort the PT_* requests into those that take a PID vs those that can also take a TID - stub in PT_GET_THREAD_FIRST and PT_GET_THREAD_NEXT ok kettenis@
* Handle rthreads consistently in ktrace by moving the flags and vnode intoguenther2011-12-141-6/+4
| | | | | | | | struct process; KTRFAC_ACTIVE becomes P_INKTR. Also, save the credentials used to open the file in sys_ktrace() and use them for all writes to the vnode. much feedback and ok jsing@
* Move struct proc's sigaltstack struct from the zeroed area into thejoshe2011-11-221-1/+3
| | | | | | | | | copied area, and initialize it properly in the FORK_THREAD case. This restores the behavior of a forked process inheriting its parent's signal stack. ok guenther@
* Change fork1() and kthread_create() to match the rest of the treeguenther2011-11-091-85/+87
| | | | | | | | and use curp vs p instead of p1 vs p2. Add curpr and pr variables for the respective struct processes. Make sigactsshare() return the shared sigacts intead of taking the struct proc to update. ok deraadt@
* I had moved earlier the adding of processes to the pgrp and children listsguenther2011-11-051-3/+5
| | | | | | | | | during the big rework at c2k10, but it's too early as signals can be posted before the process is fully built. Move those list adds back down to the late stage they were before. Problem seen on sebastia@'s sparc. ok deraadt@ miod@
* "TLS-lite": add kernel support for a per-thread userspace pointer,guenther2011-10-151-3/+52
| | | | | | | | | | | for pointing to the thread-control-block. Support for mapping this to the correct hardware register can be added as it's finished; start with support for amd64, sparc, and sparc64. Includes syscalls for getting and setting it (for a portable __errno implementation) as well as creating a new thread with an initial value for it. discussed with miod@, kettenis@, deraadt@; committing to get the syscalls in with the impending libc bump and do further refinements in tree
* Functions used in files other than where they are defined should beguenther2011-07-071-3/+1
| | | | | | | declared in .h files, not in each .c. Apply that rule to endtsleep(), scheduler_start(), updatepri(), and realitexpire() ok deraadt@ tedu@
* Clean up after P_BIGLOCK removal.art2011-07-061-2/+2
| | | | | | | KERNEL_PROC_LOCK -> KERNEL_LOCK KERNEL_PROC_UNLOCK -> KERNEL_UNLOCK oga@ ok
* push kernel malloc(9) and kernel stacks into non-dma memory, since thatderaadt2011-06-061-2/+2
| | | | | | appears to be safe now. If not, we'll know soon where the bugs lie, so that we can fix them. This diff has been in snapshots for many months. ok oga miod