summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Move PPWAIT flag from struct proc to process, so that rthreads inguenther2011-04-031-6/+10
| | | | | | | | | a vforked child behave correctly. Have the parent in a vfork() wait on a (different) flag in *its* process instead of the child to prevent a possible use-after-free. When ktracing the child return from a fork, call it rfork if an rthread was created. ok blambert@
* Move P_SUGID and P_SUGIDEXEC from struct proc to struct process, soguenther2011-04-021-2/+2
| | | | | | that you can't evade the checks by doing the dirty work in an rthread ok blambert@, deraadt@
* The return of rfork(RFTHREAD) must be consistent with getthrid().guenther2010-10-311-2/+3
| | | | Fixes rthread breakage observed by Vladimir Kirillov.
* Correct the links between threads, processes, pgrps, and sessions,guenther2010-07-261-15/+20
| | | | | | | | | 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
* Make sure the u area of new processes is zero-filled; this got lost inmiod2010-07-231-2/+3
| | | | 1.119.
* Rollback the allproclk and fileheadlk addition. When grabbing anguenther2010-07-191-3/+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@
* add an align argument to uvm_km_kmemalloc_pla.art2010-07-021-2/+4
| | | | | | | | | Use uvm_km_kmemalloc_pla with the dma constraint to allocate kernel stacks. Yes, that means DMA is possible to kernel stacks, but only until we've fixed all the scary drivers. deraadt@ ok
* style nitthib2010-06-301-3/+2
|
* Move the plimit and pcred bits in fork1() into process_new() and makeguenther2010-06-301-13/+18
| | | | | | process_new() handle the new struct process like fork1() does struct proc, with a range of members zeroed and a range copied from the parent process. ok tedu@
* We always copy struct pcred when creating a new process, so the referenceguenther2010-06-291-2/+1
| | | | | count was always one. That's pointless, so remove the member and the code. ok tedu@
* Eliminate struct plimit's PL_SHAREMOD flag: it was for COMPAT_IRIXguenther2010-06-291-13/+3
| | | | | sproc() support, but we don't have COMPAT_IRIX. ok krw@ tedu@
* some late breaking style comments from guenthertedu2010-06-291-7/+3
|
* Eliminate RTHREADS kernel option in favor of a sysctl. The actual statustedu2010-06-291-17/+5
| | | | | (not done) hasn't changed, but now it's less work to test things. ok art deraadt
* A process on the zombie list can have a NULL p_pgrp if it sleeps whenguenther2010-06-271-2/+2
| | | | | | | grabbing allproclk in proc_zap(); don't dereference the process's p_pgrp if that happens. ok art@ thib@
* As noted by art, two processes with the same pid would be bad. Grabguenther2010-05-291-3/+3
| | | | | | | | the allproclk before searching for a free pid so that we don't sleep between picking one and adding it to the list that is searched. Also, keep holding the lock until after the PIDHASH update. ok art@, tedu@
* move knote list to struct process. ok guenthertedu2010-05-181-3/+4
|
* Add a rwlock around the filehead and allproc lists, mainly to protecttedu2010-03-241-1/+3
| | | | | list walkers in sysctl that can block. As a reward, no more vslock. With some feedback from art, guenther, phessler. ok guenther.
* fix typos in comments, no code changes;schwarze2010-01-141-2/+2
| | | | | from Brad Tilley <brad at 16systems dot com>; ok oga@
* Sanity check flags in fork1(), banning some combos we don't supportguenther2009-12-281-4/+17
| | | | | | | | | | | and catching FORK_THREAD when RTHREADS wasn't compiled in. Simplify sys_rfork() based on that. Flesh out the Linux clone support with more flags, but stricter checks for missing support or bad combos. Still not enough for NPTL to work, mind you. ok kettenis@
* The process's rdomain should be, well, per-process and not per-rthread,guenther2009-12-231-5/+7
| | | | | | | | so put it in struct process instead of struct proc. While at it, move the p_emul member inside struct proc so that it gets copied automatically instead of requiring manual assignment. ok deraadt@
* Add setrdomain() and getrdomain() system calls. Committing now toguenther2009-11-271-1/+2
| | | | | | | | catch the libc major bump per request from deraadt@ Diff by reyk. ok guenther@
* Remove the VREF() macro and replaces all instances with a call to verf(),thib2009-07-091-3/+3
| | | | | | | | | | | which is exactly what the macro does. Macro's that are nothing more then: #define FUNCTION(arg) function(arg) are almost always pointless and should go away. OK blambert@ Agreed by many.
* Some tweaks to the cpu affinity code.art2009-04-141-1/+2
| | | | | | | | | | | | | | - Split up choosing of cpu between fork and "normal" cases. Fork is very different and should be treated as such. - Instead of implicitly choosing a cpu in setrunqueue, do it outside where it actually makes sense. - Just because a cpu is marked as idle doesn't mean it will be soon. There could be a thundering herd effect if we call wakeup from an interrupt handler, so subtract cpus with queued processes when deciding which cpu is actually idle. - some simplifications allowed by the above. kettenis@ ok (except one bugfix that was not in the intial diff)
* Processor affinity for processes.art2009-03-231-3/+1
| | | | | | | | | | | | | | - Split up run queues so that every cpu has one. - Make setrunqueue choose the cpu where we want to make this process runnable (this should be refined and less brutal in the future). - When choosing the cpu where we want to run, make some kind of educated guess where it will be best to run (very naive right now). Other: - Set operations for sets of cpus. - load average calculations per cpu. - sched_is_idle() -> curcpu_is_idle() tested, debugged and prodded by many@
* slightly optimized the ptrace stat allocation to only happen when needed.tedu2008-11-111-3/+4
| | | | ok deraadt
* systrace activation happens in the middle of a rather sensitive piece ofderaadt2008-11-091-3/+10
| | | | | | | fork(), i worry about it a lot but cannot prove yet that sleeping there is bad. Anyways, this change makes us never sleep in that area -- the memory needed is allocated ealier like the ptrace state. tested by many developers.
* pre-allocate the ptrace_state we may need to tie to the new processderaadt2008-11-031-3/+9
| | | | | | in case we need it. the idea is to try to get rid of some potential sleeps.. ok tedu
* Back-in; problems were apparently elsewhere.guenther2008-10-141-1/+3
| | | | | | | | | Put a reference count in struct process to prevent use-after-free if the main thread reaches the reaper ahead of some other thread in the process. Use the reference count to update the user process count correctly when changin real uid. "please re-commit before something else nasty comes in" deraadt@
* backout; is causing some people difficultyderaadt2008-10-101-3/+1
|
* Put a reference count in struct process to prevent use-after-freeguenther2008-10-091-1/+3
| | | | | | | if the main thread reaches the reaper ahead of some other thread in the process. ok art@ tedu@
* set p_flag to 0 sooner, so we don't overwrite the thread flag. and correctlytedu2008-05-111-2/+2
| | | | free things when exiting a threaded proc. from philip guenther
* share signal handlers for rthreads. from philip guenthertedu2008-05-111-2/+2
|
* Make context switching much more MI:art2007-10-101-2/+6
| | | | | | | | | | | | | | | | | | | | - Move the functionality of choosing a process from cpu_switch into a much simpler function: cpu_switchto. Instead of having the locore code walk the run queues, let the MI code choose the process we want to run and only implement the context switching itself in MD code. - Let MD context switching run without worrying about spls or locks. - Instead of having the idle loop implemented with special contexts in MD code, implement one idle proc for each cpu. make the idle loop MI with MD hooks. - Change the proc lists from the old style vax queues to TAILQs. - Change the sleep queue from vax queues to TAILQs. This makes wakeup() go from O(n^2) to O(n) there will be some MD fallout, but it will be fixed shortly. There's also a few cleanups to be done after this. deraadt@, kettenis@ ok
* Back out the tracking of procs in struct selinfo. There's one seriousart2007-07-251-3/+1
| | | | | | | bug in the code, but as soon as I try to fix it, it seems to trigger some other bugs. Instead of trying to figure out what's going on while everyone suffers, it's better to back out and figure out the bugs outside the tree.
* The world of __HAVEs and __HAVE_NOTs is reducing. All architecturesart2007-05-161-3/+1
| | | | | | have cpu_info now, so kill the option. eyeballed by jsg@ and grange@
* move p_limit and p_cred into struct processtedu2007-04-121-11/+25
| | | | | leave macros behind for now to keep the commit small ok art beck miod pedro
* Start moving state that is shared among threads in a process intoart2007-04-031-18/+30
| | | | | | | | | | | a new struct. Instead of doing a huge rename and deal with the fallout for weeks, like other projects that need no mention, we will slowly and carefully move things out of struct proc into a new struct process. - Create struct process and the infrastructure to create and remove them. - Move threads in a process into struct process. deraadt@, tedu@ ok
* Kill the horrible hack of storing the pid in struct selinfo.art2007-03-241-1/+3
| | | | | | | | Instead, keep the proc pointer in it and put the selinfo on a list in struct proc in selrecord. Then clean up the list when leaving sys_select and sys_poll. miod@ ok, testing by many, including Bobs spamd boxes.
* Since p_flag is often manipulated in interrupts and without biglockart2007-03-151-7/+7
| | | | | | | | | | | | it's a good idea to use atomic.h operations on it. This mechanic change updates all bit operations on p_flag to atomic_{set,clear}bits_int. Only exception is that P_OWEUPC is set by MI code before calling need_proftick and it's automatically cleared by ADDUPC. There's no reason for MD handling of that flag since everyone handles it the same way. kettenis@ ok
* reintroduce rev 1.83 -- put the new process on the proc listsmickey2007-01-171-10/+13
| | | | | | later when more of it's resources have been allocated and thus kill(2)ing such a process has more predictable results. now w/ a couple of kettenis remarks; kettenis@ miod@ ok