diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-11-03 03:03:36 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-11-03 03:03:36 +0000 |
commit | 0bd5a83eeaa6d68965d3f62ae717ad2b5c0965d3 (patch) | |
tree | aec8daf03109f1923b603631d03bdd181b87ad10 /sys/kern/kern_fork.c | |
parent | 3214cd0df2879b0699ec286c4475b351cab0f81a (diff) |
pre-allocate the ptrace_state we may need to tie to the new process
in case we need it. the idea is to try to get rid of some potential
sleeps..
ok tedu
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r-- | sys/kern/kern_fork.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 4d435e85aa2..e87bf06c0ce 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.98 2008/10/14 18:27:29 guenther Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.99 2008/11/03 03:03:35 deraadt Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -181,6 +181,7 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, int s; extern void endtsleep(void *); extern void realitexpire(void *); + struct ptrace_state *newptstat; /* * Although process entries are dynamically created, we still keep @@ -383,6 +384,8 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, forkstat.sizkthread += vm->vm_dsize + vm->vm_ssize; } + newptstat = malloc(sizeof(struct ptrace_state), M_SUBPROC, M_WAITOK); + /* Find an unused pid satisfying 1 <= lastpid <= PID_MAX */ do { lastpid = 1 + (randompid ? arc4random() : lastpid) % PID_MAX; @@ -402,8 +405,8 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, * Set ptrace status. */ if (flags & FORK_FORK) { - p2->p_ptstat = malloc(sizeof(*p2->p_ptstat), - M_SUBPROC, M_WAITOK); + p2->p_ptstat = newptstat; + newptstat = NULL; p1->p_ptstat->pe_report_event = PTRACE_FORK; p2->p_ptstat->pe_report_event = PTRACE_FORK; p1->p_ptstat->pe_other_pid = p2->p_pid; @@ -426,6 +429,9 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, setrunqueue(p2); SCHED_UNLOCK(s); + if (newptstat) + free(newptstat, M_SUBPROC); + /* * Notify any interested parties about the new process. */ |