Module Name:    src
Committed By:   maxv
Date:           Thu Feb  2 08:57:04 UTC 2017

Modified Files:
        src/sys/arch/x86/x86: cpu.c identcpu.c pmap.c
        src/sys/arch/xen/x86: cpu.c x86_xpmap.c

Log Message:
Use __read_mostly on these variables, to reduce the probability of false
sharing.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/x86/x86/identcpu.c
cvs rdiff -u -r1.237 -r1.238 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.106 -r1.107 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.121 src/sys/arch/x86/x86/cpu.c:1.122
--- src/sys/arch/x86/x86/cpu.c:1.121	Sun Oct 16 10:24:58 2016
+++ src/sys/arch/x86/x86/cpu.c	Thu Feb  2 08:57:04 2017
@@ -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	tss_init(struct i386tss *, v
 
 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

Index: src/sys/arch/x86/x86/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.51 src/sys/arch/x86/x86/identcpu.c:1.52
--- src/sys/arch/x86/x86/identcpu.c:1.51	Sat Dec 17 15:23:08 2016
+++ src/sys/arch/x86/x86/identcpu.c	Thu Feb  2 08:57:04 2017
@@ -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 @@ static const struct x86_cache_info amd_c
 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.

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.237 src/sys/arch/x86/x86/pmap.c:1.238
--- src/sys/arch/x86/x86/pmap.c:1.237	Sun Jan 22 20:04:35 2017
+++ src/sys/arch/x86/x86/pmap.c	Thu Feb  2 08:57:04 2017
@@ -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 @@ static vaddr_t virtual_end __read_mostly
 /*
  * 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
 
 /*

Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.106 src/sys/arch/xen/x86/cpu.c:1.107
--- src/sys/arch/xen/x86/cpu.c:1.106	Sun Jan 22 19:42:48 2017
+++ src/sys/arch/xen/x86/cpu.c	Thu Feb  2 08:57:04 2017
@@ -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 phycpu_info_primary __al
 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

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.70 src/sys/arch/xen/x86/x86_xpmap.c:1.71
--- src/sys/arch/xen/x86/x86_xpmap.c:1.70	Sun Jan 22 19:24:51 2017
+++ src/sys/arch/xen/x86/x86_xpmap.c	Thu Feb  2 08:57:04 2017
@@ -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 <m...@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 @@ unsigned long *xpmap_phys_to_machine_map
 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);
 

Reply via email to