Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

src: Function pserialize_perform() usually succeeds after two cr...



details:   https://anonhg.NetBSD.org/src/rev/cffd77cdd659
branches:  trunk
changeset: 318255:cffd77cdd659
user:      hannken <hannken%NetBSD.org@localhost>
date:      Mon Apr 16 20:25:21 2018 +0000
description:
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@

diffstat:

 sys/kern/subr_pserialize.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (46 lines):

diff -r ac4e80bbf45b -r cffd77cdd659 sys/kern/subr_pserialize.c
--- a/sys/kern/subr_pserialize.c        Mon Apr 16 19:19:51 2018 +0000
+++ b/sys/kern/subr_pserialize.c        Mon Apr 16 20:25:21 2018 +0000
@@ -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 @@
 void
 pserialize_perform(pserialize_t psz)
 {
+       int n;
        uint64_t xc;
 
        KASSERT(!cpu_intr_p());
@@ -176,6 +177,7 @@
        TAILQ_INSERT_TAIL(&psz_queue0, psz, psz_chain);
        psz_work_todo++;
 
+       n = 0;
        do {
                mutex_spin_exit(&psz_lock);
 
@@ -183,9 +185,10 @@
                 * 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));



Home | Main Index | Thread Index | Old Index