Module Name:    src
Committed By:   hannken
Date:           Mon Apr 16 20:25:21 UTC 2018

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

Log Message:
Function pserialize_perform() usually succeeds after two cross calls
so defer kpause() to iterations three and above.

Speeds up VOP_REVOKE() on /proc/XXX/status by a factor of ~12.

Ok: core@


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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/subr_pserialize.c
diff -u src/sys/kern/subr_pserialize.c:1.10 src/sys/kern/subr_pserialize.c:1.11
--- src/sys/kern/subr_pserialize.c:1.10	Thu Dec 28 03:39:48 2017
+++ src/sys/kern/subr_pserialize.c	Mon Apr 16 20:25:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pserialize.c,v 1.10 2017/12/28 03:39:48 msaitoh Exp $	*/
+/*	$NetBSD: subr_pserialize.c,v 1.11 2018/04/16 20:25:21 hannken 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.10 2017/12/28 03:39:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.11 2018/04/16 20:25:21 hannken Exp $");
 
 #include <sys/param.h>
 
@@ -146,6 +146,7 @@ pserialize_destroy(pserialize_t psz)
 void
 pserialize_perform(pserialize_t psz)
 {
+	int n;
 	uint64_t xc;
 
 	KASSERT(!cpu_intr_p());
@@ -176,6 +177,7 @@ pserialize_perform(pserialize_t psz)
 	TAILQ_INSERT_TAIL(&psz_queue0, psz, psz_chain);
 	psz_work_todo++;
 
+	n = 0;
 	do {
 		mutex_spin_exit(&psz_lock);
 
@@ -183,9 +185,10 @@ pserialize_perform(pserialize_t psz)
 		 * Force some context switch activity on every CPU, as
 		 * the system may not be busy.  Pause to not flood.
 		 */
+		if (n++ > 1)
+			kpause("psrlz", false, 1, NULL);
 		xc = xc_broadcast(XC_HIGHPRI, (xcfunc_t)nullop, NULL, NULL);
 		xc_wait(xc);
-		kpause("psrlz", false, 1, NULL);
 
 		mutex_spin_enter(&psz_lock);
 	} while (!kcpuset_iszero(psz->psz_target));

Reply via email to