Sun Oct 6 15:11:17 2019 UTC ()
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.


(uwe)
diff -r1.79 -r1.80 src/sys/arch/x86/acpi/acpi_cpu_md.c
diff -r1.204 -r1.205 src/sys/kern/kern_lwp.c
diff -r1.38 -r1.39 src/sys/kern/kern_ras.c
diff -r1.47 -r1.48 src/sys/kern/kern_softint.c
diff -r1.18 -r1.19 src/sys/kern/kern_syscall.c
diff -r1.51 -r1.52 src/sys/kern/kern_tc.c
diff -r1.12 -r1.13 src/sys/kern/subr_pserialize.c
diff -r1.26 -r1.27 src/sys/kern/subr_xcall.c
diff -r1.462 -r1.463 src/sys/net/if.c
diff -r1.49 -r1.50 src/sys/net/agr/if_agr.c
diff -r1.109 -r1.110 src/sys/opencrypto/crypto.c
diff -r1.7 -r1.8 src/sys/rump/kern/lib/libsysproxy/sysproxy.c
diff -r1.7 -r1.8 src/sys/sys/xcall.h

cvs diff -r1.79 -r1.80 src/sys/arch/x86/acpi/acpi_cpu_md.c (expand / switch to context diff)
--- src/sys/arch/x86/acpi/acpi_cpu_md.c 2018/11/10 09:42:42 1.79
+++ src/sys/arch/x86/acpi/acpi_cpu_md.c 2019/10/06 15:11:17 1.80
@@ -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>
@@ -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;
 }

cvs diff -r1.204 -r1.205 src/sys/kern/kern_lwp.c (expand / switch to context diff)
--- src/sys/kern/kern_lwp.c 2019/10/03 22:48:44 1.204
+++ src/sys/kern/kern_lwp.c 2019/10/06 15:11:17 1.205
@@ -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);
 }
 
 /*

cvs diff -r1.38 -r1.39 src/sys/kern/kern_ras.c (expand / switch to context diff)
--- src/sys/kern/kern_ras.c 2016/07/04 07:56:07 1.38
+++ src/sys/kern/kern_ras.c 2019/10/06 15:11:17 1.39
@@ -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:

cvs diff -r1.47 -r1.48 src/sys/kern/kern_softint.c (expand / switch to context diff)
--- src/sys/kern/kern_softint.c 2019/05/17 03:34:26 1.47
+++ src/sys/kern/kern_softint.c 2019/10/06 15:11:17 1.48
@@ -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 (;;) {

cvs diff -r1.18 -r1.19 src/sys/kern/kern_syscall.c (expand / switch to context diff)
--- src/sys/kern/kern_syscall.c 2019/05/06 08:05:03 1.18
+++ src/sys/kern/kern_syscall.c 2019/10/06 15:11:17 1.19
@@ -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

cvs diff -r1.51 -r1.52 src/sys/kern/kern_tc.c (expand / switch to context diff)
--- src/sys/kern/kern_tc.c 2018/07/01 15:12:06 1.51
+++ src/sys/kern/kern_tc.c 2019/10/06 15:11:17 1.52
@@ -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) {

cvs diff -r1.12 -r1.13 src/sys/kern/subr_pserialize.c (expand / switch to context diff)
--- src/sys/kern/subr_pserialize.c 2018/08/14 01:06:01 1.12
+++ src/sys/kern/subr_pserialize.c 2019/10/06 15:11:17 1.13
@@ -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));

cvs diff -r1.26 -r1.27 src/sys/kern/subr_xcall.c (expand / switch to context diff)
--- src/sys/kern/subr_xcall.c 2018/02/07 04:25:09 1.26
+++ src/sys/kern/subr_xcall.c 2019/10/06 15:11:17 1.27
@@ -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>
@@ -266,6 +266,30 @@
 		return xc_lowpri(func, arg1, arg2, NULL);
 	}
 }
+
+
+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:

cvs diff -r1.462 -r1.463 src/sys/net/if.c (expand / switch to context diff)
--- src/sys/net/if.c 2019/09/25 09:53:37 1.462
+++ src/sys/net/if.c 2019/10/06 15:11:17 1.463
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.462 2019/09/25 09:53:37 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.463 2019/10/06 15:11:17 uwe Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.462 2019/09/25 09:53:37 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.463 2019/10/06 15:11:17 uwe Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1307,7 +1307,6 @@
 	struct domain *dp;
 	const struct protosw *pr;
 	int s, i, family, purged;
-	uint64_t xc;
 
 #ifdef IFAREF_DEBUG
 	if_build_ifa_list(ifp);
@@ -1513,8 +1512,7 @@
 	if (in6_present)
 		pktq_barrier(ip6_pktq);
 #endif
-	xc = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-	xc_wait(xc);
+	xc_barrier(0);
 
 	if (ifp->if_percpuq != NULL) {
 		if_percpuq_destroy(ifp->if_percpuq);

cvs diff -r1.49 -r1.50 src/sys/net/agr/if_agr.c (expand / switch to context diff)
--- src/sys/net/agr/if_agr.c 2019/04/26 11:51:56 1.49
+++ src/sys/net/agr/if_agr.c 2019/10/06 15:11:17 1.50
@@ -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 $	*/
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.49 2019/04/26 11:51:56 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.50 2019/10/06 15:11:17 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -894,13 +894,11 @@
 static void
 agr_sync(void)
 {
-	uint64_t h;
 
 	if (!mp_online)
 		return;
 
-	h = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-	xc_wait(h);
+	xc_barrier(0);
 }
 
 static int

cvs diff -r1.109 -r1.110 src/sys/opencrypto/crypto.c (expand / switch to context diff)
--- src/sys/opencrypto/crypto.c 2019/10/01 18:00:09 1.109
+++ src/sys/opencrypto/crypto.c 2019/10/06 15:11:17 1.110
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.109 2019/10/01 18:00:09 chs Exp $ */
+/*	$NetBSD: crypto.c,v 1.110 2019/10/06 15:11:17 uwe Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.109 2019/10/01 18:00:09 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.110 2019/10/06 15:11:17 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/reboot.h>
@@ -618,7 +618,6 @@
 
 	if (exit_kthread) {
 		struct cryptocap *cap = NULL;
-		uint64_t where;
 		bool is_busy = false;
 
 		/* if we have any in-progress requests, don't unload */
@@ -657,8 +656,7 @@
 			qs->crp_ret_q_exit_flag = true;
 			crypto_put_crp_ret_qs(ci);
 		}
-		where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-		xc_wait(where);
+		xc_barrier(0);
 	}
 
 	if (sysctl_opencrypto_clog != NULL)

cvs diff -r1.7 -r1.8 src/sys/rump/kern/lib/libsysproxy/sysproxy.c (expand / switch to context diff)
--- src/sys/rump/kern/lib/libsysproxy/sysproxy.c 2019/05/17 03:34:26 1.7
+++ src/sys/rump/kern/lib/libsysproxy/sysproxy.c 2019/10/06 15:11:17 1.8
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysproxy.c,v 1.7 2019/05/17 03:34:26 ozaki-r Exp $	*/
+/*	$NetBSD: sysproxy.c,v 1.8 2019/10/06 15:11:17 uwe Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysproxy.c,v 1.7 2019/05/17 03:34:26 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysproxy.c,v 1.8 2019/10/06 15:11:17 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/filedesc.h>
@@ -141,7 +141,6 @@
 hyp_lwpexit(void)
 {
 	struct proc *p = curproc;
-	uint64_t where;
 	struct lwp *l;
 
 	mutex_enter(p->p_lock);
@@ -163,8 +162,7 @@
 	 * we wake up the threads.
 	 */
 
-	where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-	xc_wait(where);
+	xc_barrier(0);
 
 	/*
 	 * Ok, all lwps are either:

cvs diff -r1.7 -r1.8 src/sys/sys/xcall.h (expand / switch to context diff)
--- src/sys/sys/xcall.h 2018/08/27 07:10:15 1.7
+++ src/sys/sys/xcall.h 2019/10/06 15:11:16 1.8
@@ -1,4 +1,4 @@
-/*	$NetBSD: xcall.h,v 1.7 2018/08/27 07:10:15 riastradh Exp $	*/
+/*	$NetBSD: xcall.h,v 1.8 2019/10/06 15:11:16 uwe Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -52,6 +52,8 @@
 uint64_t	xc_broadcast(u_int, xcfunc_t, void *, void *);
 uint64_t	xc_unicast(u_int, xcfunc_t, void *, void *, struct cpu_info *);
 void		xc_wait(uint64_t);
+
+void		xc_barrier(u_int);
 
 unsigned int	xc_encode_ipl(int);