Source-Changes-HG archive

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

[src/trunk]: src/sys xc_barrier - convenience function to xc_broadcast() a nop.



details:   https://anonhg.NetBSD.org/src/rev/c69d4552ded6
branches:  trunk
changeset: 455085:c69d4552ded6
user:      uwe <uwe%NetBSD.org@localhost>
date:      Sun Oct 06 15:11:16 2019 +0000

description:
xc_barrier - convenience function to xc_broadcast() a nop.

Make the intent more clear and also avoid a bunch of (xcfunc_t)nullop
casts that gcc 8 -Wcast-function-type is not happy about.

diffstat:

 sys/arch/x86/acpi/acpi_cpu_md.c          |   8 +++-----
 sys/kern/kern_lwp.c                      |   8 +++-----
 sys/kern/kern_ras.c                      |   8 +++-----
 sys/kern/kern_softint.c                  |   8 +++-----
 sys/kern/kern_syscall.c                  |   8 +++-----
 sys/kern/kern_tc.c                       |   8 +++-----
 sys/kern/subr_pserialize.c               |   8 +++-----
 sys/kern/subr_xcall.c                    |  28 ++++++++++++++++++++++++++--
 sys/net/agr/if_agr.c                     |   8 +++-----
 sys/net/if.c                             |   8 +++-----
 sys/opencrypto/crypto.c                  |   8 +++-----
 sys/rump/kern/lib/libsysproxy/sysproxy.c |   8 +++-----
 sys/sys/xcall.h                          |   4 +++-
 13 files changed, 62 insertions(+), 58 deletions(-)

diffs (truncated from 453 to 300 lines):

diff -r 3d336f3e8a85 -r c69d4552ded6 sys/arch/x86/acpi/acpi_cpu_md.c
--- a/sys/arch/x86/acpi/acpi_cpu_md.c   Sun Oct 06 11:28:24 2019 +0000
+++ b/sys/arch/x86/acpi/acpi_cpu_md.c   Sun Oct 06 15:11:16 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_md.c,v 1.79 2018/11/10 09:42:42 maxv Exp $ */
+/* $NetBSD: acpi_cpu_md.c,v 1.80 2019/10/06 15:11:17 uwe Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.79 2018/11/10 09:42:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.80 2019/10/06 15:11:17 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -378,7 +378,6 @@
 {
        static char text[16];
        void (*func)(void);
-       uint64_t xc;
        bool ipi;
 
        x86_cpu_idle_get(&func, text, sizeof(text));
@@ -393,8 +392,7 @@
         * Run a cross-call to ensure that all CPUs are
         * out from the ACPI idle-loop before detachment.
         */
-       xc = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-       xc_wait(xc);
+       xc_barrier(0);
 
        return 0;
 }
diff -r 3d336f3e8a85 -r c69d4552ded6 sys/kern/kern_lwp.c
--- a/sys/kern/kern_lwp.c       Sun Oct 06 11:28:24 2019 +0000
+++ b/sys/kern/kern_lwp.c       Sun Oct 06 15:11:16 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lwp.c,v 1.204 2019/10/03 22:48:44 kamil Exp $     */
+/*     $NetBSD: kern_lwp.c,v 1.205 2019/10/06 15:11:17 uwe Exp $       */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.204 2019/10/03 22:48:44 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.205 2019/10/06 15:11:17 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -367,7 +367,6 @@
 lwp_dtor(void *arg, void *obj)
 {
        lwp_t *l = obj;
-       uint64_t where;
        (void)l;
 
        /*
@@ -379,8 +378,7 @@
         * the value of l->l_cpu must be still valid at this point.
         */
        KASSERT(l->l_cpu != NULL);
-       where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-       xc_wait(where);
+       xc_barrier(0);
 }
 
 /*
diff -r 3d336f3e8a85 -r c69d4552ded6 sys/kern/kern_ras.c
--- a/sys/kern/kern_ras.c       Sun Oct 06 11:28:24 2019 +0000
+++ b/sys/kern/kern_ras.c       Sun Oct 06 15:11:16 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_ras.c,v 1.38 2016/07/04 07:56:07 maxv Exp $       */
+/*     $NetBSD: kern_ras.c,v 1.39 2019/10/06 15:11:17 uwe Exp $        */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.38 2016/07/04 07:56:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.39 2019/10/06 15:11:17 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -66,9 +66,7 @@
        /* No need to sync if exiting or single threaded. */
        if (curproc->p_nlwps > 1 && ncpu > 1) {
 #ifdef NO_SOFTWARE_PATENTS
-               uint64_t where;
-               where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-               xc_wait(where);
+               xc_barrier(0);
 #else
                /*
                 * Assumptions:
diff -r 3d336f3e8a85 -r c69d4552ded6 sys/kern/kern_softint.c
--- a/sys/kern/kern_softint.c   Sun Oct 06 11:28:24 2019 +0000
+++ b/sys/kern/kern_softint.c   Sun Oct 06 15:11:16 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_softint.c,v 1.47 2019/05/17 03:34:26 ozaki-r Exp $        */
+/*     $NetBSD: kern_softint.c,v 1.48 2019/10/06 15:11:17 uwe Exp $    */
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.47 2019/05/17 03:34:26 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.48 2019/10/06 15:11:17 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -407,7 +407,6 @@
        softcpu_t *sc;
        softhand_t *sh;
        uintptr_t offset;
-       uint64_t where;
        u_int flags;
 
        offset = (uintptr_t)arg;
@@ -432,8 +431,7 @@
         * SOFTINT_ACTIVE already set.
         */
        if (__predict_true(mp_online)) {
-               where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-               xc_wait(where);
+               xc_barrier(0);
        }
 
        for (;;) {
diff -r 3d336f3e8a85 -r c69d4552ded6 sys/kern/kern_syscall.c
--- a/sys/kern/kern_syscall.c   Sun Oct 06 11:28:24 2019 +0000
+++ b/sys/kern/kern_syscall.c   Sun Oct 06 15:11:16 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_syscall.c,v 1.18 2019/05/06 08:05:03 kamil Exp $  */
+/*     $NetBSD: kern_syscall.c,v 1.19 2019/10/06 15:11:17 uwe Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.18 2019/05/06 08:05:03 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.19 2019/10/06 15:11:17 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_modular.h"
@@ -146,7 +146,6 @@
 {
        struct sysent *sy;
        const uint32_t *sb;
-       uint64_t where;
        lwp_t *l;
        int i;
 
@@ -175,8 +174,7 @@
         * of sy_call visible to all CPUs, and upon return we can be sure
         * that we see pertinent values of l_sysent posted by remote CPUs.
         */
-       where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-       xc_wait(where);
+       xc_barrier(0);
 
        /*
         * Now it's safe to check l_sysent.  Run through all LWPs and see
diff -r 3d336f3e8a85 -r c69d4552ded6 sys/kern/kern_tc.c
--- a/sys/kern/kern_tc.c        Sun Oct 06 11:28:24 2019 +0000
+++ b/sys/kern/kern_tc.c        Sun Oct 06 15:11:16 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_tc.c,v 1.51 2018/07/01 15:12:06 riastradh Exp $ */
+/* $NetBSD: kern_tc.c,v 1.52 2019/10/06 15:11:17 uwe Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 /* __FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.166 2005/09/19 22:16:31 andre Exp $"); */
-__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.51 2018/07/01 15:12:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.52 2019/10/06 15:11:17 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ntp.h"
@@ -609,7 +609,6 @@
        struct timecounter *tc;
        struct timecounter **tcp = NULL;
        int removals;
-       uint64_t where;
        lwp_t *l;
 
        /* First, find the timecounter. */
@@ -652,8 +651,7 @@
         * old timecounter state.
         */
        for (;;) {
-               where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-               xc_wait(where);
+               xc_barrier(0);
 
                mutex_enter(proc_lock);
                LIST_FOREACH(l, &alllwp, l_list) {
diff -r 3d336f3e8a85 -r c69d4552ded6 sys/kern/subr_pserialize.c
--- a/sys/kern/subr_pserialize.c        Sun Oct 06 11:28:24 2019 +0000
+++ b/sys/kern/subr_pserialize.c        Sun Oct 06 15:11:16 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pserialize.c,v 1.12 2018/08/14 01:06:01 ozaki-r Exp $     */
+/*     $NetBSD: subr_pserialize.c,v 1.13 2019/10/06 15:11:17 uwe 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.12 2018/08/14 01:06:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.13 2019/10/06 15:11:17 uwe Exp $");
 
 #include <sys/param.h>
 
@@ -147,7 +147,6 @@
 pserialize_perform(pserialize_t psz)
 {
        int n;
-       uint64_t xc;
 
        KASSERT(!cpu_intr_p());
        KASSERT(!cpu_softintr_p());
@@ -187,8 +186,7 @@
                 */
                if (n++ > 1)
                        kpause("psrlz", false, 1, NULL);
-               xc = xc_broadcast(XC_HIGHPRI, (xcfunc_t)nullop, NULL, NULL);
-               xc_wait(xc);
+               xc_barrier(XC_HIGHPRI);
 
                mutex_spin_enter(&psz_lock);
        } while (!kcpuset_iszero(psz->psz_target));
diff -r 3d336f3e8a85 -r c69d4552ded6 sys/kern/subr_xcall.c
--- a/sys/kern/subr_xcall.c     Sun Oct 06 11:28:24 2019 +0000
+++ b/sys/kern/subr_xcall.c     Sun Oct 06 15:11:16 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_xcall.c,v 1.26 2018/02/07 04:25:09 ozaki-r Exp $  */
+/*     $NetBSD: subr_xcall.c,v 1.27 2019/10/06 15:11:17 uwe Exp $      */
 
 /*-
  * Copyright (c) 2007-2010 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.26 2018/02/07 04:25:09 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.27 2019/10/06 15:11:17 uwe Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -267,6 +267,30 @@
        }
 }
 
+
+static void
+xc_nop(void *arg1, void *arg2)
+{
+
+    return;
+}
+
+
+/*
+ * xc_barrier:
+ *
+ *     Broadcast a nop to all CPUs in the system.
+ */
+void
+xc_barrier(unsigned int flags)
+{
+       uint64_t where;
+
+       where = xc_broadcast(flags, xc_nop, NULL, NULL);
+       xc_wait(where);
+}
+
+
 /*
  * xc_unicast:
  *
diff -r 3d336f3e8a85 -r c69d4552ded6 sys/net/agr/if_agr.c
--- a/sys/net/agr/if_agr.c      Sun Oct 06 11:28:24 2019 +0000
+++ b/sys/net/agr/if_agr.c      Sun Oct 06 15:11:16 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_agr.c,v 1.49 2019/04/26 11:51:56 pgoyette Exp $     */
+/*     $NetBSD: if_agr.c,v 1.50 2019/10/06 15:11:17 uwe Exp $  */



Home | Main Index | Thread Index | Old Index