aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2018-07-02 19:48:38 +0000
committerMatt Macy <mmacy@FreeBSD.org>2018-07-02 19:48:38 +0000
commitf4b3640475cec9299517289b7e8731ae26997cfc (patch)
treed5b84addce62cd31c3c05506a6f5b3f405f53c90
parent0479387e0ae72132bd249ae4b334d298275f06fa (diff)
inline atomics and allow tied modules to inline locks
- inline atomics in modules on i386 and amd64 (they were always inline on other arches) - allow modules to opt in to inlining locks by specifying MODULE_TIED=1 in the makefile Reviewed by: kib Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D16079
Notes
svn path=/head/; revision=335873
-rw-r--r--UPDATING4
-rw-r--r--sys/amd64/amd64/atomic.c52
-rw-r--r--sys/amd64/include/atomic.h2
-rw-r--r--sys/conf/files.amd641
-rw-r--r--sys/conf/files.i3862
-rw-r--r--sys/conf/kmod.mk3
-rw-r--r--sys/i386/i386/atomic.c51
-rw-r--r--sys/i386/include/atomic.h2
-rw-r--r--sys/sys/lock.h2
-rw-r--r--sys/sys/module.h5
-rw-r--r--sys/sys/mutex.h2
-rw-r--r--sys/sys/param.h2
-rw-r--r--sys/vm/vm_map.h2
-rw-r--r--sys/vm/vm_page.h4
14 files changed, 20 insertions, 114 deletions
diff --git a/UPDATING b/UPDATING
index 69365fdeb7f0..266bea6cc70e 100644
--- a/UPDATING
+++ b/UPDATING
@@ -31,6 +31,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
+20180702:
+ On i386 and amd64 atomics are now inlined. Out of tree modules using
+ atomics will need to be rebuilt.
+
20180701:
The '%I' format in the kern.corefile sysctl limits the number of
core files that a process can generate to the number stored in the
diff --git a/sys/amd64/amd64/atomic.c b/sys/amd64/amd64/atomic.c
deleted file mode 100644
index 0544336bd99a..000000000000
--- a/sys/amd64/amd64/atomic.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Peter Jeremy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/* This file creates publicly callable functions to perform various
- * simple arithmetic on memory which is atomic in the presence of
- * interrupts and multiple processors.
- */
-#include <sys/types.h>
-
-/* Firstly make atomic.h generate prototypes as it will for kernel modules */
-#define KLD_MODULE
-#include <machine/atomic.h>
-#undef _MACHINE_ATOMIC_H_ /* forget we included it */
-#undef KLD_MODULE
-#undef ATOMIC_ASM
-
-/* Make atomic.h generate public functions */
-static __inline void __storeload_barrier(void);
-#define WANT_FUNCTIONS
-#define static
-#undef __inline
-#define __inline
-
-#include <machine/atomic.h>
diff --git a/sys/amd64/include/atomic.h b/sys/amd64/include/atomic.h
index 3847b09cff47..4fef4314fb25 100644
--- a/sys/amd64/include/atomic.h
+++ b/sys/amd64/include/atomic.h
@@ -96,7 +96,7 @@
* Kernel modules call real functions which are built into the kernel.
* This allows kernel modules to be portable between UP and SMP systems.
*/
-#if defined(KLD_MODULE) || !defined(__GNUCLIKE_ASM)
+#if !defined(__GNUCLIKE_ASM)
#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \
void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); \
void atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index bc49cde9c729..eadb0e214c9b 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -126,7 +126,6 @@ acpi_wakedata.h optional acpi \
clean "acpi_wakedata.h"
#
#amd64/amd64/apic_vector.S standard
-amd64/amd64/atomic.c standard
amd64/amd64/bios.c standard
amd64/amd64/bpf_jit_machdep.c optional bpf_jitter
amd64/amd64/cpu_switch.S standard
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 513c35363cff..5c45dfab4061 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -474,8 +474,6 @@ i386/bios/smapi.c optional smapi
i386/bios/smapi_bios.S optional smapi
i386/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32
#i386/i386/apic_vector.s optional apic
-i386/i386/atomic.c standard \
- compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} ${.IMPSRC}"
i386/i386/bios.c standard
i386/i386/bioscall.s standard
i386/i386/bpf_jit_machdep.c optional bpf_jitter
diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index ef07516eb6ba..e8aa3ee15201 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -111,6 +111,9 @@ WERROR?= -Werror
CFLAGS+= ${WERROR}
CFLAGS+= -D_KERNEL
CFLAGS+= -DKLD_MODULE
+.if defined(MODULE_TIED)
+CFLAGS+= -DKLD_TIED
+.endif
# Don't use any standard or source-relative include directories.
NOSTDINC= -nostdinc
diff --git a/sys/i386/i386/atomic.c b/sys/i386/i386/atomic.c
deleted file mode 100644
index 26d853dfeb58..000000000000
--- a/sys/i386/i386/atomic.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Peter Jeremy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/* This file creates publically callable functions to perform various
- * simple arithmetic on memory which is atomic in the presence of
- * interrupts and multiple processors.
- */
-#include <sys/types.h>
-
-/* Firstly make atomic.h generate prototypes as it will for kernel modules */
-#define KLD_MODULE
-#include <machine/atomic.h>
-#undef _MACHINE_ATOMIC_H_ /* forget we included it */
-#undef KLD_MODULE
-#undef ATOMIC_ASM
-
-/* Make atomic.h generate public functions */
-#define WANT_FUNCTIONS
-#define static
-#undef __inline
-#define __inline
-
-#include <machine/atomic.h>
diff --git a/sys/i386/include/atomic.h b/sys/i386/include/atomic.h
index 52bb31f7a321..34ed3a6af8b1 100644
--- a/sys/i386/include/atomic.h
+++ b/sys/i386/include/atomic.h
@@ -104,7 +104,7 @@ __mbu(void)
* Kernel modules call real functions which are built into the kernel.
* This allows kernel modules to be portable between UP and SMP systems.
*/
-#if defined(KLD_MODULE) || !defined(__GNUCLIKE_ASM)
+#if !defined(__GNUCLIKE_ASM)
#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \
void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); \
void atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
diff --git a/sys/sys/lock.h b/sys/sys/lock.h
index 101ec9b89f77..f7e25d278f3b 100644
--- a/sys/sys/lock.h
+++ b/sys/sys/lock.h
@@ -127,7 +127,7 @@ struct lock_class {
* calling conventions for this debugging code in modules so that modules can
* work with both debug and non-debug kernels.
*/
-#if defined(KLD_MODULE) || defined(WITNESS) || defined(INVARIANTS) || \
+#if (defined(KLD_MODULE) && !defined(KLD_TIED)) || defined(WITNESS) || defined(INVARIANTS) || \
defined(LOCK_PROFILING) || defined(KTR)
#define LOCK_DEBUG 1
#else
diff --git a/sys/sys/module.h b/sys/sys/module.h
index 6799b179b8fc..b40870d32941 100644
--- a/sys/sys/module.h
+++ b/sys/sys/module.h
@@ -146,8 +146,13 @@ struct mod_pnp_match_info
SYSINIT(name##module, sub, order, module_register_init, &data); \
struct __hack
+#ifdef KLD_TIED
#define DECLARE_MODULE(name, data, sub, order) \
+ DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, __FreeBSD_version)
+#else
+#define DECLARE_MODULE(name, data, sub, order) \
DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, MODULE_KERNEL_MAXVER)
+#endif
/*
* The module declared with DECLARE_MODULE_TIED can only be loaded
diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h
index f9ce4e3bdca7..d4c9d1cbc815 100644
--- a/sys/sys/mutex.h
+++ b/sys/sys/mutex.h
@@ -138,7 +138,7 @@ void _thread_lock(struct thread *td, int opts, const char *file, int line);
void _thread_lock(struct thread *);
#endif
-#if defined(LOCK_PROFILING) || defined(KLD_MODULE)
+#if defined(LOCK_PROFILING) || (defined(KLD_MODULE) && !defined(KLD_TIED))
#define thread_lock(tdp) \
thread_lock_flags_((tdp), 0, __FILE__, __LINE__)
#elif LOCK_DEBUG > 0
diff --git a/sys/sys/param.h b/sys/sys/param.h
index fd2b1d5dd942..cdaf49fd8b29 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -60,7 +60,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1200069 /* Master, propagated to newvers */
+#define __FreeBSD_version 1200070 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h
index 65b8f23ce583..7502b95ee1a8 100644
--- a/sys/vm/vm_map.h
+++ b/sys/vm/vm_map.h
@@ -206,7 +206,7 @@ struct vm_map {
#define MAP_BUSY_WAKEUP 0x02
#ifdef _KERNEL
-#ifdef KLD_MODULE
+#if defined(KLD_MODULE) && !defined(KLD_TIED)
#define vm_map_max(map) vm_map_max_KBI((map))
#define vm_map_min(map) vm_map_min_KBI((map))
#define vm_map_pmap(map) vm_map_pmap_KBI((map))
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
index 3942acc34ab9..5f3852d5fc48 100644
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -304,7 +304,7 @@ extern struct mtx_padalign pa_lock[];
#define PA_LOCK_ASSERT(pa, a) mtx_assert(PA_LOCKPTR(pa), (a))
-#ifdef KLD_MODULE
+#if defined(KLD_MODULE) && !defined(KLD_TIED)
#define vm_page_lock(m) vm_page_lock_KBI((m), LOCK_FILE, LOCK_LINE)
#define vm_page_unlock(m) vm_page_unlock_KBI((m), LOCK_FILE, LOCK_LINE)
#define vm_page_trylock(m) vm_page_trylock_KBI((m), LOCK_FILE, LOCK_LINE)
@@ -734,7 +734,7 @@ vm_page_dirty(vm_page_t m)
{
/* Use vm_page_dirty_KBI() under INVARIANTS to save memory. */
-#if defined(KLD_MODULE) || defined(INVARIANTS)
+#if (defined(KLD_MODULE) && !defined(KLD_TIED)) || defined(INVARIANTS)
vm_page_dirty_KBI(m);
#else
m->dirty = VM_PAGE_BITS_ALL;