Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2012 04:18:42 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r244373 - stable/9/sys/kern
Message-ID:  <201212180418.qBI4Ig2j051841@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Dec 18 04:18:42 2012
New Revision: 244373
URL: http://svnweb.freebsd.org/changeset/base/244373

Log:
  MFC r243869:
  Fix a race between kern_setitimer() and realitexpire(),
  by using the process mutex to interlock the callout start.

Modified:
  stable/9/sys/kern/init_main.c
  stable/9/sys/kern/kern_fork.c
  stable/9/sys/kern/kern_time.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/init_main.c
==============================================================================
--- stable/9/sys/kern/init_main.c	Tue Dec 18 01:23:37 2012	(r244372)
+++ stable/9/sys/kern/init_main.c	Tue Dec 18 04:18:42 2012	(r244373)
@@ -497,7 +497,7 @@ proc0_init(void *dummy __unused)
 	strncpy(p->p_comm, "kernel", sizeof (p->p_comm));
 	strncpy(td->td_name, "swapper", sizeof (td->td_name));
 
-	callout_init(&p->p_itcallout, CALLOUT_MPSAFE);
+	callout_init_mtx(&p->p_itcallout, &p->p_mtx, 0);
 	callout_init_mtx(&p->p_limco, &p->p_mtx, 0);
 	callout_init(&td->td_slpcallout, CALLOUT_MPSAFE);
 

Modified: stable/9/sys/kern/kern_fork.c
==============================================================================
--- stable/9/sys/kern/kern_fork.c	Tue Dec 18 01:23:37 2012	(r244372)
+++ stable/9/sys/kern/kern_fork.c	Tue Dec 18 04:18:42 2012	(r244373)
@@ -592,7 +592,7 @@ do_fork(struct thread *td, int flags, st
 	LIST_INIT(&p2->p_children);
 	LIST_INIT(&p2->p_orphans);
 
-	callout_init(&p2->p_itcallout, CALLOUT_MPSAFE);
+	callout_init_mtx(&p2->p_itcallout, &p2->p_mtx, 0);
 
 	/*
 	 * If PF_FORK is set, the child process inherits the

Modified: stable/9/sys/kern/kern_time.c
==============================================================================
--- stable/9/sys/kern/kern_time.c	Tue Dec 18 01:23:37 2012	(r244372)
+++ stable/9/sys/kern/kern_time.c	Tue Dec 18 04:18:42 2012	(r244373)
@@ -659,13 +659,11 @@ realitexpire(void *arg)
 	struct timeval ctv, ntv;
 
 	p = (struct proc *)arg;
-	PROC_LOCK(p);
 	kern_psignal(p, SIGALRM);
 	if (!timevalisset(&p->p_realtimer.it_interval)) {
 		timevalclear(&p->p_realtimer.it_value);
 		if (p->p_flag & P_WEXIT)
 			wakeup(&p->p_itcallout);
-		PROC_UNLOCK(p);
 		return;
 	}
 	for (;;) {
@@ -677,7 +675,6 @@ realitexpire(void *arg)
 			timevalsub(&ntv, &ctv);
 			callout_reset(&p->p_itcallout, tvtohz(&ntv) - 1,
 			    realitexpire, p);
-			PROC_UNLOCK(p);
 			return;
 		}
 	}



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