From 46f09d5bc3f6480ce5db48b9d76f3e83299f588c Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 19 Mar 2008 06:19:01 +0000 Subject: - 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. --- sys/vm/vm_glue.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'sys/vm/vm_glue.c') 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); } -- cgit v1.1