From bd5efd46002ab435a3543c06a8463f93bf87b51e Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 14 Mar 2004 02:06:28 +0000 Subject: Make the process_exit eventhandler run without Giant. Add Giant hooks in the two consumers that need it.. processes using AIO and netncp. Update docs. Say that process_exec is called with Giant, but not to depend on it. All our consumers can handle it without Giant. --- sys/kern/kern_exec.c | 1 + sys/kern/kern_exit.c | 2 -- sys/kern/kern_fork.c | 2 -- sys/kern/vfs_aio.c | 2 ++ sys/netncp/ncp_subr.c | 2 ++ sys/sys/eventhandler.h | 4 ++-- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index a09dba2..d9f7449 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -843,6 +843,7 @@ exec_new_vmspace(imgp, sv) imgp->vmspace_destroyed = 1; + /* Called with Giant held, do not depend on it! */ EVENTHANDLER_INVOKE(process_exec, p); /* diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 885404e..dec3a97 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -214,9 +214,7 @@ exit1(struct thread *td, int rv) * e.g. SYSV IPC stuff * XXX what if one of these generates an error? */ - mtx_lock(&Giant); EVENTHANDLER_INVOKE(process_exit, p); - mtx_unlock(&Giant); MALLOC(p->p_ru, struct rusage *, sizeof(struct rusage), M_ZOMBIE, M_WAITOK); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index bd17f05..ec4caef 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -695,8 +695,6 @@ again: * Both processes are set up, now check if any loadable modules want * to adjust anything. * What if they have an error? XXX - * - * Handlers must be MPSAFE, or aquire Giant themselves if not. */ EVENTHANDLER_INVOKE(process_fork, p1, p2, flags); diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index d51d3fc..8c21215 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -543,6 +543,7 @@ aio_proc_rundown(void *arg, struct proc *p) if (ki == NULL) return; + mtx_lock(&Giant); ki->kaio_flags |= LIOJ_SIGNAL_POSTED; while ((ki->kaio_active_count > 0) || (ki->kaio_buffer_count > ki->kaio_buffer_finished_count)) { @@ -643,6 +644,7 @@ restart4: uma_zfree(kaio_zone, ki); p->p_aioinfo = NULL; + mtx_unlock(&Giant); } /* diff --git a/sys/netncp/ncp_subr.c b/sys/netncp/ncp_subr.c index c15b985..b213733 100644 --- a/sys/netncp/ncp_subr.c +++ b/sys/netncp/ncp_subr.c @@ -85,6 +85,7 @@ ncp_at_exit(void *arg, struct proc *p) struct ncp_conn *ncp, *nncp; struct thread *td; + mtx_lock(&Giant); FOREACH_THREAD_IN_PROC(p, td) { if (ncp_conn_putprochandles(td) == 0) continue; @@ -100,6 +101,7 @@ ncp_at_exit(void *arg, struct proc *p) } ncp_conn_unlocklist(td); } + mtx_unlock(&Giant); } int diff --git a/sys/sys/eventhandler.h b/sys/sys/eventhandler.h index 3f623b2..c734c19 100644 --- a/sys/sys/eventhandler.h +++ b/sys/sys/eventhandler.h @@ -158,8 +158,8 @@ EVENTHANDLER_DECLARE(vm_lowmem, vm_lowmem_handler_t); /* * Process events - * process_fork handlers are called without Giant. - * exit/exec handlers are called with Giant. + * process_fork and exit handlers are called without Giant. + * exec handlers are called with Giant, but that is by accident. */ struct proc; -- cgit v1.1