Use __read_mostly on these variables, to reduce the probability of false trunk
authormaxv <maxv@NetBSD.org>
Thu, 02 Feb 2017 08:57:04 +0000
branchtrunk
changeset 248337 e83aae1f3b66
parent 248336 9794209d7c72
child 248338 c259ae2d9ef2
Use __read_mostly on these variables, to reduce the probability of false sharing.
sys/arch/x86/x86/cpu.c
sys/arch/x86/x86/identcpu.c
sys/arch/x86/x86/pmap.c
sys/arch/xen/x86/cpu.c
sys/arch/xen/x86/x86_xpmap.c
--- a/sys/arch/x86/x86/cpu.c	Thu Feb 02 08:12:08 2017 +0000
+++ b/sys/arch/x86/x86/cpu.c	Thu Feb 02 08:57:04 2017 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.121 2016/10/16 10:24:58 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.122 2017/02/02 08:57:04 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.121 2016/10/16 10:24:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.122 2017/02/02 08:57:04 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -177,7 +177,7 @@
 
 static void	cpu_init_idle_lwp(struct cpu_info *);
 
-uint32_t cpu_feature[7]; /* X86 CPUID feature bits */
+uint32_t cpu_feature[7] __read_mostly; /* X86 CPUID feature bits */
 			/* [0] basic features cpuid.1:%edx
 			 * [1] basic features cpuid.1:%ecx (CPUID2_xxx bits)
 			 * [2] extended features cpuid:80000001:%edx
--- a/sys/arch/x86/x86/identcpu.c	Thu Feb 02 08:12:08 2017 +0000
+++ b/sys/arch/x86/x86/identcpu.c	Thu Feb 02 08:57:04 2017 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: identcpu.c,v 1.51 2016/12/17 15:23:08 maxv Exp $	*/
+/*	$NetBSD: identcpu.c,v 1.52 2017/02/02 08:57:04 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.51 2016/12/17 15:23:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.52 2017/02/02 08:57:04 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -61,9 +61,9 @@
 int cpu_vendor;
 char cpu_brand_string[49];
 
-int x86_fpu_save = FPU_SAVE_FSAVE;
-unsigned int x86_fpu_save_size = 512;
-uint64_t x86_xsave_features = 0;
+int x86_fpu_save __read_mostly = FPU_SAVE_FSAVE;
+unsigned int x86_fpu_save_size __read_mostly = 512;
+uint64_t x86_xsave_features __read_mostly = 0;
 
 /*
  * Note: these are just the ones that may not have a cpuid instruction.
--- a/sys/arch/x86/x86/pmap.c	Thu Feb 02 08:12:08 2017 +0000
+++ b/sys/arch/x86/x86/pmap.c	Thu Feb 02 08:57:04 2017 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.237 2017/01/22 20:04:35 maxv Exp $	*/
+/*	$NetBSD: pmap.c,v 1.238 2017/02/02 08:57:04 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.237 2017/01/22 20:04:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.238 2017/02/02 08:57:04 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -480,8 +480,8 @@
 /*
  * LAPIC virtual address, and fake physical address.
  */
-volatile vaddr_t local_apic_va;
-paddr_t local_apic_pa;
+volatile vaddr_t local_apic_va __read_mostly;
+paddr_t local_apic_pa __read_mostly;
 #endif
 
 /*
--- a/sys/arch/xen/x86/cpu.c	Thu Feb 02 08:12:08 2017 +0000
+++ b/sys/arch/xen/x86/cpu.c	Thu Feb 02 08:57:04 2017 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.106 2017/01/22 19:42:48 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.107 2017/02/02 08:57:04 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.106 2017/01/22 19:42:48 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.107 2017/02/02 08:57:04 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -171,7 +171,7 @@
 struct cpu_info *cpu_info_list = &cpu_info_primary;
 struct cpu_info *phycpu_info_list = &phycpu_info_primary;
 
-uint32_t cpu_feature[7]; /* X86 CPUID feature bits
+uint32_t cpu_feature[7] __read_mostly; /* X86 CPUID feature bits
 			  *	[0] basic features %edx
 			  *	[1] basic features %ecx
 			  *	[2] extended features %edx
--- a/sys/arch/xen/x86/x86_xpmap.c	Thu Feb 02 08:12:08 2017 +0000
+++ b/sys/arch/xen/x86/x86_xpmap.c	Thu Feb 02 08:57:04 2017 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.70 2017/01/22 19:24:51 maxv Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.71 2017/02/02 08:57:04 maxv Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert <mro@adviseo.fr>
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.70 2017/01/22 19:24:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.71 2017/02/02 08:57:04 maxv Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -105,7 +105,7 @@
 kmutex_t pte_lock;
 vaddr_t xen_dummy_page;
 
-pt_entry_t xpmap_pg_nx;
+pt_entry_t xpmap_pg_nx __read_mostly;
 
 void xen_failsafe_handler(void);