Module Name:    src
Committed By:   ozaki-r
Date:           Tue Aug 14 01:06:01 UTC 2018

Modified Files:
        src/sys/kern: kern_synch.c subr_pserialize.c

Log Message:
Change the place to check if a context switch doesn't happen within a 
pserialize read section

The previous place (pserialize_switchpoint) was not a good place because at that
point a suspect thread is already switched so that a backtrace gotten on
a KASSERT failure doesn't point out where a context switch happens.


To generate a diff of this commit:
cvs rdiff -u -r1.317 -r1.318 src/sys/kern/kern_synch.c
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/subr_pserialize.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_synch.c
diff -u src/sys/kern/kern_synch.c:1.317 src/sys/kern/kern_synch.c:1.318
--- src/sys/kern/kern_synch.c:1.317	Tue Jul 24 15:09:37 2018
+++ src/sys/kern/kern_synch.c	Tue Aug 14 01:06:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_synch.c,v 1.317 2018/07/24 15:09:37 bouyer Exp $	*/
+/*	$NetBSD: kern_synch.c,v 1.318 2018/08/14 01:06:01 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.317 2018/07/24 15:09:37 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.318 2018/08/14 01:06:01 ozaki-r Exp $");
 
 #include "opt_kstack.h"
 #include "opt_dtrace.h"
@@ -699,6 +699,11 @@ mi_switch(lwp_t *l)
 			(*dtrace_vtime_switch_func)(newl);
 		}
 
+		/*
+		 * We must ensure not to come here from inside a read section.
+		 */
+		KASSERT(pserialize_not_in_read_section());
+
 		/* Switch to the new LWP.. */
 #ifdef MULTIPROCESSOR
 		KASSERT(curlwp == ci->ci_curlwp);

Index: src/sys/kern/subr_pserialize.c
diff -u src/sys/kern/subr_pserialize.c:1.11 src/sys/kern/subr_pserialize.c:1.12
--- src/sys/kern/subr_pserialize.c:1.11	Mon Apr 16 20:25:21 2018
+++ src/sys/kern/subr_pserialize.c	Tue Aug 14 01:06:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pserialize.c,v 1.11 2018/04/16 20:25:21 hannken Exp $	*/
+/*	$NetBSD: subr_pserialize.c,v 1.12 2018/08/14 01:06:01 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.11 2018/04/16 20:25:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.12 2018/08/14 01:06:01 ozaki-r Exp $");
 
 #include <sys/param.h>
 
@@ -248,9 +248,6 @@ pserialize_switchpoint(void)
 	pserialize_t psz, next;
 	cpuid_t cid;
 
-	/* We must to ensure not to come here from inside a read section. */
-	KASSERT(pserialize_not_in_read_section());
-
 	/*
 	 * If no updates pending, bail out.  No need to lock in order to
 	 * test psz_work_todo; the only ill effect of missing an update

Reply via email to