Module Name: src Committed By: uwe Date: Sun Oct 6 15:11:17 UTC 2019
Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c src/sys/kern: kern_lwp.c kern_ras.c kern_softint.c kern_syscall.c kern_tc.c subr_pserialize.c subr_xcall.c src/sys/net: if.c src/sys/net/agr: if_agr.c src/sys/opencrypto: crypto.c src/sys/rump/kern/lib/libsysproxy: sysproxy.c src/sys/sys: xcall.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/arch/x86/acpi/acpi_cpu_md.c cvs rdiff -u -r1.204 -r1.205 src/sys/kern/kern_lwp.c cvs rdiff -u -r1.38 -r1.39 src/sys/kern/kern_ras.c cvs rdiff -u -r1.47 -r1.48 src/sys/kern/kern_softint.c cvs rdiff -u -r1.18 -r1.19 src/sys/kern/kern_syscall.c cvs rdiff -u -r1.51 -r1.52 src/sys/kern/kern_tc.c cvs rdiff -u -r1.12 -r1.13 src/sys/kern/subr_pserialize.c cvs rdiff -u -r1.26 -r1.27 src/sys/kern/subr_xcall.c cvs rdiff -u -r1.462 -r1.463 src/sys/net/if.c cvs rdiff -u -r1.49 -r1.50 src/sys/net/agr/if_agr.c cvs rdiff -u -r1.109 -r1.110 src/sys/opencrypto/crypto.c cvs rdiff -u -r1.7 -r1.8 src/sys/rump/kern/lib/libsysproxy/sysproxy.c cvs rdiff -u -r1.7 -r1.8 src/sys/sys/xcall.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.79 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.80 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.79 Sat Nov 10 09:42:42 2018 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sun Oct 6 15:11:17 2019 @@ -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 <jruoho...@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 @@ acpicpu_md_cstate_stop(void) { static char text[16]; void (*func)(void); - uint64_t xc; bool ipi; x86_cpu_idle_get(&func, text, sizeof(text)); @@ -393,8 +392,7 @@ acpicpu_md_cstate_stop(void) * 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; } Index: src/sys/kern/kern_lwp.c diff -u src/sys/kern/kern_lwp.c:1.204 src/sys/kern/kern_lwp.c:1.205 --- src/sys/kern/kern_lwp.c:1.204 Thu Oct 3 22:48:44 2019 +++ src/sys/kern/kern_lwp.c Sun Oct 6 15:11:17 2019 @@ -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 @@ static void lwp_dtor(void *arg, void *obj) { lwp_t *l = obj; - uint64_t where; (void)l; /* @@ -379,8 +378,7 @@ lwp_dtor(void *arg, void *obj) * 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); } /* Index: src/sys/kern/kern_ras.c diff -u src/sys/kern/kern_ras.c:1.38 src/sys/kern/kern_ras.c:1.39 --- src/sys/kern/kern_ras.c:1.38 Mon Jul 4 07:56:07 2016 +++ src/sys/kern/kern_ras.c Sun Oct 6 15:11:17 2019 @@ -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 @@ ras_sync(void) /* 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: Index: src/sys/kern/kern_softint.c diff -u src/sys/kern/kern_softint.c:1.47 src/sys/kern/kern_softint.c:1.48 --- src/sys/kern/kern_softint.c:1.47 Fri May 17 03:34:26 2019 +++ src/sys/kern/kern_softint.c Sun Oct 6 15:11:17 2019 @@ -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 @@ softint_disestablish(void *arg) softcpu_t *sc; softhand_t *sh; uintptr_t offset; - uint64_t where; u_int flags; offset = (uintptr_t)arg; @@ -432,8 +431,7 @@ softint_disestablish(void *arg) * 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 (;;) { Index: src/sys/kern/kern_syscall.c diff -u src/sys/kern/kern_syscall.c:1.18 src/sys/kern/kern_syscall.c:1.19 --- src/sys/kern/kern_syscall.c:1.18 Mon May 6 08:05:03 2019 +++ src/sys/kern/kern_syscall.c Sun Oct 6 15:11:17 2019 @@ -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 @@ syscall_disestablish(const struct emul * { struct sysent *sy; const uint32_t *sb; - uint64_t where; lwp_t *l; int i; @@ -175,8 +174,7 @@ syscall_disestablish(const struct emul * * 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 Index: src/sys/kern/kern_tc.c diff -u src/sys/kern/kern_tc.c:1.51 src/sys/kern/kern_tc.c:1.52 --- src/sys/kern/kern_tc.c:1.51 Sun Jul 1 15:12:06 2018 +++ src/sys/kern/kern_tc.c Sun Oct 6 15:11:17 2019 @@ -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 @@ tc_detach(struct timecounter *target) struct timecounter *tc; struct timecounter **tcp = NULL; int removals; - uint64_t where; lwp_t *l; /* First, find the timecounter. */ @@ -652,8 +651,7 @@ tc_detach(struct timecounter *target) * 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) { Index: src/sys/kern/subr_pserialize.c diff -u src/sys/kern/subr_pserialize.c:1.12 src/sys/kern/subr_pserialize.c:1.13 --- src/sys/kern/subr_pserialize.c:1.12 Tue Aug 14 01:06:01 2018 +++ src/sys/kern/subr_pserialize.c Sun Oct 6 15:11:17 2019 @@ -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 @@ void pserialize_perform(pserialize_t psz) { int n; - uint64_t xc; KASSERT(!cpu_intr_p()); KASSERT(!cpu_softintr_p()); @@ -187,8 +186,7 @@ pserialize_perform(pserialize_t psz) */ 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)); Index: src/sys/kern/subr_xcall.c diff -u src/sys/kern/subr_xcall.c:1.26 src/sys/kern/subr_xcall.c:1.27 --- src/sys/kern/subr_xcall.c:1.26 Wed Feb 7 04:25:09 2018 +++ src/sys/kern/subr_xcall.c Sun Oct 6 15:11:17 2019 @@ -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 @@ xc_broadcast(unsigned int flags, xcfunc_ } } + +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: * Index: src/sys/net/if.c diff -u src/sys/net/if.c:1.462 src/sys/net/if.c:1.463 --- src/sys/net/if.c:1.462 Wed Sep 25 09:53:37 2019 +++ src/sys/net/if.c Sun Oct 6 15:11:17 2019 @@ -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 @@ if_detach(struct ifnet *ifp) 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 @@ restart: 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); Index: src/sys/net/agr/if_agr.c diff -u src/sys/net/agr/if_agr.c:1.49 src/sys/net/agr/if_agr.c:1.50 --- src/sys/net/agr/if_agr.c:1.49 Fri Apr 26 11:51:56 2019 +++ src/sys/net/agr/if_agr.c Sun Oct 6 15:11:17 2019 @@ -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 @@ agrreq_copyout(void *ubuf, struct agrreq 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 Index: src/sys/opencrypto/crypto.c diff -u src/sys/opencrypto/crypto.c:1.109 src/sys/opencrypto/crypto.c:1.110 --- src/sys/opencrypto/crypto.c:1.109 Tue Oct 1 18:00:09 2019 +++ src/sys/opencrypto/crypto.c Sun Oct 6 15:11:17 2019 @@ -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 @@ crypto_destroy(bool exit_kthread) 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 @@ crypto_destroy(bool exit_kthread) 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) Index: src/sys/rump/kern/lib/libsysproxy/sysproxy.c diff -u src/sys/rump/kern/lib/libsysproxy/sysproxy.c:1.7 src/sys/rump/kern/lib/libsysproxy/sysproxy.c:1.8 --- src/sys/rump/kern/lib/libsysproxy/sysproxy.c:1.7 Fri May 17 03:34:26 2019 +++ src/sys/rump/kern/lib/libsysproxy/sysproxy.c Sun Oct 6 15:11:17 2019 @@ -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 @@ static void hyp_lwpexit(void) { struct proc *p = curproc; - uint64_t where; struct lwp *l; mutex_enter(p->p_lock); @@ -163,8 +162,7 @@ hyp_lwpexit(void) * 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: Index: src/sys/sys/xcall.h diff -u src/sys/sys/xcall.h:1.7 src/sys/sys/xcall.h:1.8 --- src/sys/sys/xcall.h:1.7 Mon Aug 27 07:10:15 2018 +++ src/sys/sys/xcall.h Sun Oct 6 15:11:16 2019 @@ -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. @@ -53,6 +53,8 @@ uint64_t xc_broadcast(u_int, xcfunc_t, v 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); #endif /* _KERNEL */