Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Dec 2017 03:35:35 +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: r327409 - in stable/11/sys: conf kern security/audit sys
Message-ID:  <201712310335.vBV3ZZro099265@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sun Dec 31 03:35:34 2017
New Revision: 327409
URL: https://svnweb.freebsd.org/changeset/base/327409

Log:
  MFC r323235,r323236,r324789,r324863:
  
      Introduce __read_frequently
  
      While __read_mostly groups variables together, their placement is not
      specified. In particular 2 frequently used variables can end up in
      different lines.
  
      This annotation is only expected to be used for variables read all the time,
      e.g. on each syscall entry.
  
  =============
  
      Sprinkle __read_frequently on few obvious places.
  
      Note that some of annotated variables should probably change their types
      to something smaller, preferably bit-sized.
  
  =============
  
      Mark kdb_active as __read_frequently and switch to bool to eat less space.
  
  =============
  
      Change kdb_active type to u_char.
  
      Fixes warnings from gcc and keeps the small size. Perhaps nesting should be moved
      to another variablle.

Modified:
  stable/11/sys/conf/ldscript.amd64
  stable/11/sys/kern/kern_dtrace.c
  stable/11/sys/kern/kern_lockstat.c
  stable/11/sys/kern/kern_mutex.c
  stable/11/sys/kern/kern_rwlock.c
  stable/11/sys/kern/kern_sx.c
  stable/11/sys/kern/subr_kdb.c
  stable/11/sys/security/audit/audit.c
  stable/11/sys/sys/kdb.h
  stable/11/sys/sys/systm.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/conf/ldscript.amd64
==============================================================================
--- stable/11/sys/conf/ldscript.amd64	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/conf/ldscript.amd64	Sun Dec 31 03:35:34 2017	(r327409)
@@ -146,6 +146,10 @@ SECTIONS
   . = DATA_SEGMENT_RELRO_END (24, .);
   .got.plt        : { *(.got.plt) }
   . = ALIGN(64);
+  .data.read_frequently :
+  {
+    *(.data.read_frequently)
+  }
   .data.read_mostly :
   {
     *(.data.read_mostly)

Modified: stable/11/sys/kern/kern_dtrace.c
==============================================================================
--- stable/11/sys/kern/kern_dtrace.c	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/kern/kern_dtrace.c	Sun Dec 31 03:35:34 2017	(r327409)
@@ -54,7 +54,7 @@ dtrace_doubletrap_func_t	dtrace_doubletrap_func;
 dtrace_pid_probe_ptr_t		dtrace_pid_probe_ptr;
 dtrace_return_probe_ptr_t	dtrace_return_probe_ptr;
 
-systrace_probe_func_t		systrace_probe_func;
+systrace_probe_func_t __read_frequently	systrace_probe_func;
 
 /* Return the DTrace process data size compiled in the kernel hooks. */
 size_t

Modified: stable/11/sys/kern/kern_lockstat.c
==============================================================================
--- stable/11/sys/kern/kern_lockstat.c	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/kern/kern_lockstat.c	Sun Dec 31 03:35:34 2017	(r327409)
@@ -62,7 +62,7 @@ SDT_PROBE_DEFINE1(lockstat, , , sx__downgrade, "struct
 
 SDT_PROBE_DEFINE2(lockstat, , , thread__spin, "struct mtx *", "uint64_t");
 
-volatile int __read_mostly lockstat_enabled;
+volatile int __read_frequently lockstat_enabled;
 
 uint64_t 
 lockstat_nsecs(struct lock_object *lo)

Modified: stable/11/sys/kern/kern_mutex.c
==============================================================================
--- stable/11/sys/kern/kern_mutex.c	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/kern/kern_mutex.c	Sun Dec 31 03:35:34 2017	(r327409)
@@ -140,7 +140,7 @@ struct lock_class lock_class_mtx_spin = {
 #ifdef ADAPTIVE_MUTEXES
 static SYSCTL_NODE(_debug, OID_AUTO, mtx, CTLFLAG_RD, NULL, "mtx debugging");
 
-static struct lock_delay_config __read_mostly mtx_delay;
+static struct lock_delay_config __read_frequently mtx_delay;
 
 SYSCTL_INT(_debug_mtx, OID_AUTO, delay_base, CTLFLAG_RW, &mtx_delay.base,
     0, "");
@@ -153,7 +153,7 @@ LOCK_DELAY_SYSINIT_DEFAULT(mtx_delay);
 static SYSCTL_NODE(_debug, OID_AUTO, mtx_spin, CTLFLAG_RD, NULL,
     "mtx spin debugging");
 
-static struct lock_delay_config __read_mostly mtx_spin_delay;
+static struct lock_delay_config __read_frequently mtx_spin_delay;
 
 SYSCTL_INT(_debug_mtx_spin, OID_AUTO, delay_base, CTLFLAG_RW,
     &mtx_spin_delay.base, 0, "");

Modified: stable/11/sys/kern/kern_rwlock.c
==============================================================================
--- stable/11/sys/kern/kern_rwlock.c	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/kern/kern_rwlock.c	Sun Dec 31 03:35:34 2017	(r327409)
@@ -93,14 +93,14 @@ struct lock_class lock_class_rw = {
 };
 
 #ifdef ADAPTIVE_RWLOCKS
-static int rowner_retries = 10;
-static int rowner_loops = 10000;
+static int __read_frequently rowner_retries = 10;
+static int __read_frequently rowner_loops = 10000;
 static SYSCTL_NODE(_debug, OID_AUTO, rwlock, CTLFLAG_RD, NULL,
     "rwlock debugging");
 SYSCTL_INT(_debug_rwlock, OID_AUTO, retry, CTLFLAG_RW, &rowner_retries, 0, "");
 SYSCTL_INT(_debug_rwlock, OID_AUTO, loops, CTLFLAG_RW, &rowner_loops, 0, "");
 
-static struct lock_delay_config __read_mostly rw_delay;
+static struct lock_delay_config __read_frequently rw_delay;
 
 SYSCTL_INT(_debug_rwlock, OID_AUTO, delay_base, CTLFLAG_RW, &rw_delay.base,
     0, "");

Modified: stable/11/sys/kern/kern_sx.c
==============================================================================
--- stable/11/sys/kern/kern_sx.c	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/kern/kern_sx.c	Sun Dec 31 03:35:34 2017	(r327409)
@@ -142,13 +142,13 @@ struct lock_class lock_class_sx = {
 #endif
 
 #ifdef ADAPTIVE_SX
-static u_int asx_retries = 10;
-static u_int asx_loops = 10000;
+static __read_frequently u_int asx_retries = 10;
+static __read_frequently u_int asx_loops = 10000;
 static SYSCTL_NODE(_debug, OID_AUTO, sx, CTLFLAG_RD, NULL, "sxlock debugging");
 SYSCTL_UINT(_debug_sx, OID_AUTO, retries, CTLFLAG_RW, &asx_retries, 0, "");
 SYSCTL_UINT(_debug_sx, OID_AUTO, loops, CTLFLAG_RW, &asx_loops, 0, "");
 
-static struct lock_delay_config __read_mostly sx_delay;
+static struct lock_delay_config __read_frequently sx_delay;
 
 SYSCTL_INT(_debug_sx, OID_AUTO, delay_base, CTLFLAG_RW, &sx_delay.base,
     0, "");

Modified: stable/11/sys/kern/subr_kdb.c
==============================================================================
--- stable/11/sys/kern/subr_kdb.c	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/kern/subr_kdb.c	Sun Dec 31 03:35:34 2017	(r327409)
@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/smp.h>
 #endif
 
-int kdb_active = 0;
+u_char __read_frequently kdb_active = 0;
 static void *kdb_jmpbufp = NULL;
 struct kdb_dbbe *kdb_dbbe = NULL;
 static struct pcb kdb_pcb;

Modified: stable/11/sys/security/audit/audit.c
==============================================================================
--- stable/11/sys/security/audit/audit.c	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/security/audit/audit.c	Sun Dec 31 03:35:34 2017	(r327409)
@@ -91,7 +91,7 @@ static SYSCTL_NODE(_security, OID_AUTO, audit, CTLFLAG
  *
  * Define the audit control flags.
  */
-int			audit_enabled;
+int __read_frequently	audit_enabled;
 int			audit_suspended;
 
 /*

Modified: stable/11/sys/sys/kdb.h
==============================================================================
--- stable/11/sys/sys/kdb.h	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/sys/kdb.h	Sun Dec 31 03:35:34 2017	(r327409)
@@ -59,7 +59,7 @@ struct kdb_dbbe {
 	};						\
 	DATA_SET(kdb_dbbe_set, name##_dbbe)
 
-extern int kdb_active;			/* Non-zero while in debugger. */
+extern u_char kdb_active;		/* Non-zero while in debugger. */
 extern int debugger_on_panic;		/* enter the debugger on panic. */
 extern struct kdb_dbbe *kdb_dbbe;	/* Default debugger backend or NULL. */
 extern struct trapframe *kdb_frame;	/* Frame to kdb_trap(). */

Modified: stable/11/sys/sys/systm.h
==============================================================================
--- stable/11/sys/sys/systm.h	Sun Dec 31 03:34:00 2017	(r327408)
+++ stable/11/sys/sys/systm.h	Sun Dec 31 03:35:34 2017	(r327409)
@@ -138,6 +138,7 @@ void	kassert_panic(const char *fmt, ...)  __printflike
  * Align variables.
  */
 #define	__read_mostly		__section(".data.read_mostly")
+#define	__read_frequently	__section(".data.read_frequently")
 #define	__exclusive_cache_line	__aligned(CACHE_LINE_SIZE) \
 				    __section(".data.exclusive_cache_line")
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712310335.vBV3ZZro099265>