summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2008-03-19 06:19:01 +0000
committerjeff <jeff@FreeBSD.org>2008-03-19 06:19:01 +0000
commit46f09d5bc3f6480ce5db48b9d76f3e83299f588c (patch)
tree720fece23c8482c35e341e275a0f4068ee43126f /sys/vm
parentf8600f40e7fcf241985d8a978c63889de0969bfb (diff)
downloadFreeBSD-src-46f09d5bc3f6480ce5db48b9d76f3e83299f588c.zip
FreeBSD-src-46f09d5bc3f6480ce5db48b9d76f3e83299f588c.tar.gz
- Relax requirements for p_numthreads, p_threads, p_swtick, and p_nice from
requiring the per-process spinlock to only requiring the process lock. - Reflect these changes in the proc.h documentation and consumers throughout the kernel. This is a substantial reduction in locking cost for these fields and was made possible by recent changes to threading support.
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_glue.c19
-rw-r--r--sys/vm/vm_meter.c5
-rw-r--r--sys/vm/vm_pageout.c6
3 files changed, 8 insertions, 22 deletions
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index a1157ed..9f9dc5a 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -338,6 +338,7 @@ vm_thread_new(struct thread *td, int pages)
* Allocate an object for the kstack.
*/
ksobj = vm_object_allocate(OBJT_DEFAULT, pages);
+
/*
* Get a kernel virtual address for this thread's kstack.
*/
@@ -645,10 +646,8 @@ faultin(p)
FOREACH_THREAD_IN_PROC(p, td)
vm_thread_swapin(td);
PROC_LOCK(p);
- PROC_SLOCK(p);
swapclear(p);
p->p_swtick = ticks;
- PROC_SUNLOCK(p);
wakeup(&p->p_flag);
@@ -700,7 +699,6 @@ loop:
continue;
}
swtime = (ticks - p->p_swtick) / hz;
- PROC_SLOCK(p);
FOREACH_THREAD_IN_PROC(p, td) {
/*
* An otherwise runnable thread of a process
@@ -726,7 +724,6 @@ loop:
}
thread_unlock(td);
}
- PROC_SUNLOCK(p);
PROC_UNLOCK(p);
}
sx_sunlock(&allproc_lock);
@@ -868,7 +865,7 @@ retry:
if (p->p_lock != 0 ||
(p->p_flag & (P_STOPPED_SINGLE|P_TRACED|P_SYSTEM|P_WEXIT)
) != 0) {
- goto nextproc2;
+ goto nextproc;
}
/*
* only aiod changes vmspace, however it will be
@@ -876,7 +873,7 @@ retry:
* for P_SYSTEM
*/
if ((p->p_flag & (P_INMEM|P_SWAPPINGOUT|P_SWAPPINGIN)) != P_INMEM)
- goto nextproc2;
+ goto nextproc;
switch (p->p_state) {
default:
@@ -885,7 +882,6 @@ retry:
break;
case PRS_NORMAL:
- PROC_SLOCK(p);
/*
* do not swapout a realtime process
* Check all the thread groups..
@@ -947,17 +943,14 @@ retry:
(minslptime > swap_idle_threshold2))) {
if (swapout(p) == 0)
didswap++;
- PROC_SUNLOCK(p);
PROC_UNLOCK(p);
vm_map_unlock(&vm->vm_map);
vmspace_free(vm);
sx_sunlock(&allproc_lock);
goto retry;
}
-nextproc:
- PROC_SUNLOCK(p);
}
-nextproc2:
+nextproc:
PROC_UNLOCK(p);
vm_map_unlock(&vm->vm_map);
nextproc1:
@@ -980,7 +973,6 @@ swapclear(p)
struct thread *td;
PROC_LOCK_ASSERT(p, MA_OWNED);
- PROC_SLOCK_ASSERT(p, MA_OWNED);
FOREACH_THREAD_IN_PROC(p, td) {
thread_lock(td);
@@ -1002,7 +994,6 @@ swapout(p)
struct thread *td;
PROC_LOCK_ASSERT(p, MA_OWNED);
- PROC_SLOCK_ASSERT(p, MA_OWNED | MA_NOTRECURSED);
#if defined(SWAP_DEBUG)
printf("swapping out %d\n", p->p_pid);
#endif
@@ -1037,7 +1028,6 @@ swapout(p)
}
td = FIRST_THREAD_IN_PROC(p);
++td->td_ru.ru_nswap;
- PROC_SUNLOCK(p);
PROC_UNLOCK(p);
/*
@@ -1050,7 +1040,6 @@ swapout(p)
PROC_LOCK(p);
p->p_flag &= ~P_SWAPPINGOUT;
- PROC_SLOCK(p);
p->p_swtick = ticks;
return (0);
}
diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c
index d71eabf..c644631 100644
--- a/sys/vm/vm_meter.c
+++ b/sys/vm/vm_meter.c
@@ -130,13 +130,16 @@ vmtotal(SYSCTL_HANDLER_ARGS)
FOREACH_PROC_IN_SYSTEM(p) {
if (p->p_flag & P_SYSTEM)
continue;
+ PROC_LOCK(p);
PROC_SLOCK(p);
switch (p->p_state) {
case PRS_NEW:
PROC_SUNLOCK(p);
+ PROC_UNLOCK(p);
continue;
break;
default:
+ PROC_SUNLOCK(p);
FOREACH_THREAD_IN_PROC(p, td) {
thread_lock(td);
switch (td->td_state) {
@@ -164,7 +167,7 @@ vmtotal(SYSCTL_HANDLER_ARGS)
thread_unlock(td);
}
}
- PROC_SUNLOCK(p);
+ PROC_UNLOCK(p);
/*
* Note active objects.
*/
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index bf899a6..a3ecc98 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -1206,7 +1206,6 @@ unlock_and_continue:
* If the process is in a non-running type state,
* don't touch it. Check all the threads individually.
*/
- PROC_SLOCK(p);
breakout = 0;
FOREACH_THREAD_IN_PROC(p, td) {
thread_lock(td);
@@ -1219,7 +1218,6 @@ unlock_and_continue:
}
thread_unlock(td);
}
- PROC_SUNLOCK(p);
if (breakout) {
PROC_UNLOCK(p);
continue;
@@ -1249,9 +1247,7 @@ unlock_and_continue:
sx_sunlock(&allproc_lock);
if (bigproc != NULL) {
killproc(bigproc, "out of swap space");
- PROC_SLOCK(bigproc);
sched_nice(bigproc, PRIO_MIN);
- PROC_SUNLOCK(bigproc);
PROC_UNLOCK(bigproc);
wakeup(&cnt.v_free_count);
}
@@ -1560,7 +1556,6 @@ vm_daemon()
* if the process is in a non-running type state,
* don't touch it.
*/
- PROC_SLOCK(p);
breakout = 0;
FOREACH_THREAD_IN_PROC(p, td) {
thread_lock(td);
@@ -1573,7 +1568,6 @@ vm_daemon()
}
thread_unlock(td);
}
- PROC_SUNLOCK(p);
if (breakout) {
PROC_UNLOCK(p);
continue;
OpenPOWER on IntegriCloud