Date: Tue, 14 Mar 2017 20:39:06 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315284 - in stable/11/sys: compat/linuxkpi/common/include/linux conf dev/drm2 sys Message-ID: <201703142039.v2EKd7Qk034518@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Tue Mar 14 20:39:06 2017 New Revision: 315284 URL: https://svnweb.freebsd.org/changeset/base/315284 Log: MFC r312888: Introduce __read_mostly and __exclusive_cache_line macros. The intended use is to annotate frequently used globals which either rarely change (and thus can be grouped in the same cacheline) or are an atomic counter (which means it may benefit from being the only variable in the cacheline). Linker script support is provided only for amd64. Architectures without it risk having other variables put in, i.e. as if they were not annotated. This is harmless from correctness point of view. Modified: stable/11/sys/compat/linuxkpi/common/include/linux/compiler.h stable/11/sys/conf/ldscript.amd64 stable/11/sys/dev/drm2/drm_os_freebsd.h stable/11/sys/sys/systm.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/compiler.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/compiler.h Tue Mar 14 20:31:10 2017 (r315283) +++ stable/11/sys/compat/linuxkpi/common/include/linux/compiler.h Tue Mar 14 20:39:06 2017 (r315284) @@ -67,7 +67,6 @@ #define typeof(x) __typeof(x) #define uninitialized_var(x) x = x -#define __read_mostly __attribute__((__section__(".data.read_mostly"))) #define __always_unused __unused #define __must_check __result_use_check Modified: stable/11/sys/conf/ldscript.amd64 ============================================================================== --- stable/11/sys/conf/ldscript.amd64 Tue Mar 14 20:31:10 2017 (r315283) +++ stable/11/sys/conf/ldscript.amd64 Tue Mar 14 20:39:06 2017 (r315284) @@ -145,6 +145,17 @@ SECTIONS .got : { *(.got) } . = DATA_SEGMENT_RELRO_END (24, .); .got.plt : { *(.got.plt) } + . = ALIGN(64); + .data.read_mostly : + { + *(.data.read_mostly) + } + . = ALIGN(64); + .data.exclusive_cache_line : + { + *(.data.exclusive_cache_line) + } + . = ALIGN(64); .data : { *(.data .data.* .gnu.linkonce.d.*) Modified: stable/11/sys/dev/drm2/drm_os_freebsd.h ============================================================================== --- stable/11/sys/dev/drm2/drm_os_freebsd.h Tue Mar 14 20:31:10 2017 (r315283) +++ stable/11/sys/dev/drm2/drm_os_freebsd.h Tue Mar 14 20:39:06 2017 (r315284) @@ -80,7 +80,6 @@ typedef void irqreturn_t; #define __init #define __exit -#define __read_mostly #define BUILD_BUG_ON(x) CTASSERT(!(x)) #define BUILD_BUG_ON_NOT_POWER_OF_2(x) Modified: stable/11/sys/sys/systm.h ============================================================================== --- stable/11/sys/sys/systm.h Tue Mar 14 20:31:10 2017 (r315283) +++ stable/11/sys/sys/systm.h Tue Mar 14 20:39:06 2017 (r315284) @@ -131,6 +131,12 @@ void kassert_panic(const char *fmt, ...) #define SCHEDULER_STOPPED() __predict_false(curthread->td_stopsched) /* + * Align variables. + */ +#define __read_mostly __section(".data.read_mostly") +#define __exclusive_cache_line __aligned(CACHE_LINE_SIZE) \ + __section(".data.exclusive_cache_line") +/* * XXX the hints declarations are even more misplaced than most declarations * in this file, since they are needed in one file (per arch) and only used * in two files.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703142039.v2EKd7Qk034518>