summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2012-05-10 05:01:23 +0000
committerguenther <guenther@openbsd.org>2012-05-10 05:01:23 +0000
commit0303b08324c895da9001caa5e6b5e4140157dac4 (patch)
tree93f5427d2c853742dc4c32242fda8848a1f59b65 /sys/kern/kern_fork.c
parentDo not include <machine/reg.h> and pollute userland namespace with struct reg (diff)
downloadwireguard-openbsd-0303b08324c895da9001caa5e6b5e4140157dac4.tar.xz
wireguard-openbsd-0303b08324c895da9001caa5e6b5e4140157dac4.zip
Only set a process's start time when starting the main thread. There's
also no need to protect that and the setting of the AFORK accounting flag with the scheduler lock. ok mikeb@
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index e2771d04022..695cac4b619 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.139 2012/04/13 16:37:51 kettenis Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.140 2012/05/10 05:01:23 guenther Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -449,12 +449,17 @@ fork1(struct proc *curp, int exitsig, int flags, void *stack, pid_t *tidptr,
}
/*
- * Make child runnable, set start time, and add to run queue.
+ * For new processes, set accounting bits
*/
- SCHED_LOCK(s);
- getmicrotime(&pr->ps_start);
- if ((flags & FORK_THREAD) == 0)
+ if ((flags & FORK_THREAD) == 0) {
+ getmicrotime(&pr->ps_start);
pr->ps_acflag = AFORK;
+ }
+
+ /*
+ * Make child runnable and add to run queue.
+ */
+ SCHED_LOCK(s);
p->p_stat = SRUN;
p->p_cpu = sched_choosecpu_fork(curp, flags);
setrunqueue(p);