diff options
author | mjg <mjg@FreeBSD.org> | 2017-12-31 03:35:34 +0000 |
---|---|---|
committer | mjg <mjg@FreeBSD.org> | 2017-12-31 03:35:34 +0000 |
commit | 7a9ec347a0491d03665e237ad4653b79aae25d03 (patch) | |
tree | 426ade898fcd6a0f356348f52082362839fb8477 | |
parent | 046f82c455b766a4a1d1a23203499211a06badcb (diff) | |
download | FreeBSD-src-7a9ec347a0491d03665e237ad4653b79aae25d03.zip FreeBSD-src-7a9ec347a0491d03665e237ad4653b79aae25d03.tar.gz |
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.
-rw-r--r-- | sys/conf/ldscript.amd64 | 4 | ||||
-rw-r--r-- | sys/kern/kern_dtrace.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_lockstat.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_mutex.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_rwlock.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_sx.c | 6 | ||||
-rw-r--r-- | sys/kern/subr_kdb.c | 2 | ||||
-rw-r--r-- | sys/security/audit/audit.c | 2 | ||||
-rw-r--r-- | sys/sys/kdb.h | 2 | ||||
-rw-r--r-- | sys/sys/systm.h | 1 |
10 files changed, 18 insertions, 13 deletions
diff --git a/sys/conf/ldscript.amd64 b/sys/conf/ldscript.amd64 index e64a957..838a3c4 100644 --- a/sys/conf/ldscript.amd64 +++ b/sys/conf/ldscript.amd64 @@ -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) diff --git a/sys/kern/kern_dtrace.c b/sys/kern/kern_dtrace.c index f5f14b7..adc36a8 100644 --- a/sys/kern/kern_dtrace.c +++ b/sys/kern/kern_dtrace.c @@ -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 diff --git a/sys/kern/kern_lockstat.c b/sys/kern/kern_lockstat.c index 679a01c..77e5526 100644 --- a/sys/kern/kern_lockstat.c +++ b/sys/kern/kern_lockstat.c @@ -62,7 +62,7 @@ SDT_PROBE_DEFINE1(lockstat, , , sx__downgrade, "struct sx *"); 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) diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index e93cd0e..f86cfa4 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -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, ""); diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index 4c8e9bd..56a25f1 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -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, ""); diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c index 1446543..1a26293 100644 --- a/sys/kern/kern_sx.c +++ b/sys/kern/kern_sx.c @@ -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, ""); diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 356ad37..249aab4 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -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; diff --git a/sys/security/audit/audit.c b/sys/security/audit/audit.c index f2a01dd..399bec9 100644 --- a/sys/security/audit/audit.c +++ b/sys/security/audit/audit.c @@ -91,7 +91,7 @@ static SYSCTL_NODE(_security, OID_AUTO, audit, CTLFLAG_RW, 0, * * Define the audit control flags. */ -int audit_enabled; +int __read_frequently audit_enabled; int audit_suspended; /* diff --git a/sys/sys/kdb.h b/sys/sys/kdb.h index 49c8c32..1e68c39 100644 --- a/sys/sys/kdb.h +++ b/sys/sys/kdb.h @@ -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(). */ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 651cd50..fa5bc3f 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -138,6 +138,7 @@ void kassert_panic(const char *fmt, ...) __printflike(1, 2); * 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") /* |