svn commit: r312888 - in head/sys: compat/linuxkpi/common/include/linux conf dev/drm2 sys

Mateusz Guzik mjg at FreeBSD.org
Fri Jan 27 14:53:11 UTC 2017


Author: mjg
Date: Fri Jan 27 14:53:09 2017
New Revision: 312888
URL: https://svnweb.freebsd.org/changeset/base/312888

Log:
  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.
  
  Reviewed by:	bde (previous version)
  MFC after:	1 month

Modified:
  head/sys/compat/linuxkpi/common/include/linux/compiler.h
  head/sys/conf/ldscript.amd64
  head/sys/dev/drm2/drm_os_freebsd.h
  head/sys/sys/systm.h

Modified: head/sys/compat/linuxkpi/common/include/linux/compiler.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/compiler.h	Fri Jan 27 14:17:48 2017	(r312887)
+++ head/sys/compat/linuxkpi/common/include/linux/compiler.h	Fri Jan 27 14:53:09 2017	(r312888)
@@ -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: head/sys/conf/ldscript.amd64
==============================================================================
--- head/sys/conf/ldscript.amd64	Fri Jan 27 14:17:48 2017	(r312887)
+++ head/sys/conf/ldscript.amd64	Fri Jan 27 14:53:09 2017	(r312888)
@@ -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: head/sys/dev/drm2/drm_os_freebsd.h
==============================================================================
--- head/sys/dev/drm2/drm_os_freebsd.h	Fri Jan 27 14:17:48 2017	(r312887)
+++ head/sys/dev/drm2/drm_os_freebsd.h	Fri Jan 27 14:53:09 2017	(r312888)
@@ -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: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h	Fri Jan 27 14:17:48 2017	(r312887)
+++ head/sys/sys/systm.h	Fri Jan 27 14:53:09 2017	(r312888)
@@ -129,6 +129,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.


More information about the svn-src-head mailing list