Commit Graph

298 Commits

Author SHA1 Message Date
ad
d991fcb3b6 More changes to improve kern_descrip.c.
- Avoid atomics in more places.
- Remove the per-descriptor mutex, and just use filedesc_t::fd_lock.
  It was only being used to synchronize close, and in any case we needed
  to take fd_lock to free the descriptor slot.
- Optimize certain paths for the <NDFDFILE case.
- Sprinkle more comments and assertions.
- Cache more stuff in filedesc_t.
- Fix numerous minor bugs spotted along the way.
- Restructure how the open files array is maintained, for clarity and so
  that we can eliminate the membar_consumer() call in fd_getfile().  This is
  mostly syntactic sugar; the main functional change is that fd_nfiles now
  lives alongside the open file array.

Some measurements with libmicro:

- simple file syscalls are like close() are between 1 to 10% faster.
- some nice improvements, e.g. poll(1000) which is ~50% faster.
2009-05-24 21:41:25 +00:00
rmind
be5c9950c6 kpsignal2: do not start process (when it is stopped) for all termination
signals (i.e. SA_KILL), just if SIGKILL (or SIGCONT).  Improve comments.

Make some functions static, remove unused sigrealloc() prototype.

Fixes PR/39814.  Similar patch reviewed by <ad>.
2009-03-29 05:02:46 +00:00
drochner
083fa0419a In sigput(), save the siginfo no matter whether SA_SIGINFO is set or not.
There are also sigtimedwait(2) et al. to catch signals without invoking
a signal handler. Fixes PR kern/41076 by Matteo Beccati (the first
test case, where the signal is sent before sigwaitinfo(2) gets called).
2009-03-27 10:58:38 +00:00
yamt
cb1e92d5d5 malloc -> kmem_alloc 2009-01-22 14:38:34 +00:00
ad
7a3593355a Fix a comment. 2008-12-13 20:49:49 +00:00
ad
24da1f6ca4 PR kern/36183 problem with ptrace and multithreaded processes
Fix the famous "gdb + threads = panic" problem.
Also, fix another revivesa merge botch.
2008-12-13 20:43:38 +00:00
ad
2e606b7b1b sigchecktrace: process SIGKILL before everything else. 2008-12-13 18:55:01 +00:00
ad
c90afa3efc vax uses v3 trampoline. 2008-11-25 15:05:38 +00:00
ad
92ce8c6a3d Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
2008-11-19 18:35:57 +00:00
wrstuden
0a30ab777e toall signals really are toall. The fact we're sa doesn't matter.
They are start/stop signals, and need to impact more than just
blessed lwps.
2008-10-24 18:07:36 +00:00
wrstuden
fc7511b00e Merge wrstuden-revivesa into HEAD. 2008-10-15 06:51:17 +00:00
christos
0ff103ebea - remove dup code
- make sure that sigput always initializes ksi
- initialize si_code with SI_NOINFO instead of lying (SI_USER)
- if a process is being ktraced, make siginfo available
- always pass the available siginfo to ktrace, even if it has SI_NOINFO
2008-09-12 21:33:39 +00:00
ad
40818746b1 Use pool_cache. 2008-06-25 11:05:46 +00:00
ad
5adf7333fd - PPWAIT is need only be locked by proc_lock, so move it to proc::p_lflag.
- Remove a few needless lock acquires from exec/fork/exit.
- Sprinkle branch hints.

No functional change.
2008-06-16 09:51:14 +00:00
ad
245f0726ac Reduce ifdefs due to MULTIPROCESSOR slightly. 2008-05-19 17:06:02 +00:00
ad
1074fa7182 Ignore processes with PK_MARKER set. 2008-04-29 15:55:24 +00:00
ad
ddeba2439c Ignore processes with PK_MARKER set. 2008-04-29 15:51:23 +00:00
ad
254bed5bd3 Fix a race condition that could cause a deadlock between two threads in
the same process simultaneously trying to dump core. Fixes PR kern/37704.
2008-04-29 14:04:06 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad
4079c2dd69 Use pool_cache+atomics for sigacts. 2008-04-25 11:24:11 +00:00
ad
8c71a574b0 Remove unneeded kernel_lock/splvm stuff. 2008-04-25 00:07:24 +00:00
ad
284c2b9aef Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
2008-04-24 18:39:20 +00:00
ad
6d70f903e6 Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
  be sent from a hardware interrupt handler. Signal activity must be
  deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
  and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
2008-04-24 15:35:27 +00:00
ad
be04ac4896 Make rusage collection per-LWP and collate in the appropriate places.
cloned threads need a little bit more work but the locking needs to
be fixed first.
2008-03-27 19:06:51 +00:00
ad
a9ca7a3734 Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
2008-03-21 21:54:58 +00:00
yamt
60381203e0 kpsignal2: enqueue SA_STOP signals and let issignal handle it rather
than trying to stop the process by ourselves.  this fixes SIGTSTP masking.
ok'ed by Andrew Doran.  PR/37603, PR/38060.
2008-03-08 07:56:53 +00:00
yamt
c5bb0d332c reduce code duplication. no functional changes are intended. 2008-02-20 11:48:46 +00:00
yamt
68be78c456 L_PENDSIG -> LW_PENDSIG in a comment. 2008-02-19 16:16:06 +00:00
yamt
b1eaff3725 constify 2008-02-19 12:24:34 +00:00
yamt
31a3a6f1a1 update a comment. (L_PENDSIG -> LW_PENDSIG) 2008-02-19 12:22:44 +00:00
yamt
70e552c2cb sigpause -> sigsuspend in comments. 2008-02-19 12:20:02 +00:00
ad
b993799944 Lock p->p_klist. 2008-02-05 13:33:35 +00:00
rmind
116ffc8d57 sigpost: convert to the new, inverted priorities.
From <drochner>.
2008-01-31 00:50:32 +00:00
ad
fef8681585 Mark some callouts/workqueues/kthreads MPSAFE. 2008-01-24 13:57:52 +00:00
elad
aabadd15ea Forgot to commit this in latest commit, spotted by hannken@.
Adapt to "CAN" removal...
2008-01-23 17:52:32 +00:00
christos
65c680cad7 Add PaX ASLR (Address Space Layout Randomization) [from elad and myself]
For regular (non PIE) executables randomization is enabled for:
    1. The data segment
    2. The stack

For PIE executables(*) randomization is enabled for:
    1. The program itself
    2. All shared libraries
    3. The data segment
    4. The stack

(*) To generate a PIE executable:
    - compile everything with -fPIC
    - link with -shared-libgcc -Wl,-pie

This feature is experimental, and might change. To use selectively add
    options PAX_ASLR=0
in your kernel.

Currently we are using 12 bits for the stack, program, and data segment and
16 or 24 bits for mmap, depending on __LP64__.
2007-12-26 22:11:47 +00:00
ad
598ab03ad0 Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
2007-12-05 07:06:50 +00:00
ad
27f20ecf58 Soft interrupts can now take proclist_lock, so there is no need to
double-lock alllwp or allproc.
2007-12-03 20:26:24 +00:00
ad
b470ab628d Use membar_*(). 2007-11-30 23:05:43 +00:00
ad
c3a9a185b4 Tidy up the sigacts locking a bit: sigacts can be shared between
multiple processes.
2007-11-27 01:27:30 +00:00
ad
a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
ad
0a4c80e2c7 Protect ksiginfo_pool with splvm to be on the safe side. 2007-10-03 13:21:22 +00:00
ad
c0fd052388 Fix a couple of comments. 2007-08-17 17:25:14 +00:00
ad
63c4506184 Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
2007-08-15 12:07:23 +00:00
ad
88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
yamt
f03010953f merge yamt-idlelwp branch. asked by core@. some ports still needs work.
from doc/BRANCHES:

	idle lwp, and some changes depending on it.

	1. separate context switching and thread scheduling.
	   (cf. gmcgarry_ctxsw)
	2. implement idle lwp.
	3. clean up related MD/MI interfaces.
	4. make scheduler(s) modular.
2007-05-17 14:51:11 +00:00
ad
59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
ad
c147748d84 - Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.
2007-03-09 14:11:22 +00:00
ad
0261e46854 - proc_unstop: adjust p_nrlwps correctly. Should fix PR kern/35657.
- LOCK_ASSERT -> KASSERT
- Update a couple of comments.
2007-03-05 20:29:14 +00:00
thorpej
4f3d5a9cc0 TRUE -> true, FALSE -> false 2007-02-22 06:34:42 +00:00