Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Mar 2015 20:25:35 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r280332 - head/sys/kern
Message-ID:  <201503212025.t2LKPZCC011585@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sat Mar 21 20:25:34 2015
New Revision: 280332
URL: https://svnweb.freebsd.org/changeset/base/280332

Log:
  proc: use MTX_NEW flag in proc_init
  
  This allows us to get rid of bzero which was added specifically to make
  mtx_init on p_mtx reliable.
  
  This also fixes a potential problem where mtx_init on other mutexes
  could trip over on unitialized memory and fire an assertion.
  
  Reviewed by:	kib

Modified:
  head/sys/kern/kern_proc.c

Modified: head/sys/kern/kern_proc.c
==============================================================================
--- head/sys/kern/kern_proc.c	Sat Mar 21 20:24:54 2015	(r280331)
+++ head/sys/kern/kern_proc.c	Sat Mar 21 20:25:34 2015	(r280332)
@@ -225,12 +225,11 @@ proc_init(void *mem, int size, int flags
 	p = (struct proc *)mem;
 	SDT_PROBE(proc, kernel, init, entry, p, size, flags, 0, 0);
 	p->p_sched = (struct p_sched *)&p[1];
-	bzero(&p->p_mtx, sizeof(struct mtx));
-	mtx_init(&p->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK);
-	mtx_init(&p->p_slock, "process slock", NULL, MTX_SPIN);
-	mtx_init(&p->p_statmtx, "pstatl", NULL, MTX_SPIN);
-	mtx_init(&p->p_itimmtx, "pitiml", NULL, MTX_SPIN);
-	mtx_init(&p->p_profmtx, "pprofl", NULL, MTX_SPIN);
+	mtx_init(&p->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK | MTX_NEW);
+	mtx_init(&p->p_slock, "process slock", NULL, MTX_SPIN | MTX_NEW);
+	mtx_init(&p->p_statmtx, "pstatl", NULL, MTX_SPIN | MTX_NEW);
+	mtx_init(&p->p_itimmtx, "pitiml", NULL, MTX_SPIN | MTX_NEW);
+	mtx_init(&p->p_profmtx, "pprofl", NULL, MTX_SPIN | MTX_NEW);
 	cv_init(&p->p_pwait, "ppwait");
 	cv_init(&p->p_dbgwait, "dbgwait");
 	TAILQ_INIT(&p->p_threads);	     /* all threads in proc */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503212025.t2LKPZCC011585>