From a4a47537291762552d31c676f76743a7ca33a5da Mon Sep 17 00:00:00 2001 From: maxv Date: Thu, 2 Feb 2017 08:57:04 +0000 Subject: [PATCH] Use __read_mostly on these variables, to reduce the probability of false sharing. --- sys/arch/x86/x86/cpu.c | 6 +++--- sys/arch/x86/x86/identcpu.c | 10 +++++----- sys/arch/x86/x86/pmap.c | 8 ++++---- sys/arch/xen/x86/cpu.c | 6 +++--- sys/arch/xen/x86/x86_xpmap.c | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sys/arch/x86/x86/cpu.c b/sys/arch/x86/x86/cpu.c index 7a3e376cb02d..aa8fc378ecad 100644 --- a/sys/arch/x86/x86/cpu.c +++ b/sys/arch/x86/x86/cpu.c @@ -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 -__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 *, void *, void *); 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 diff --git a/sys/arch/x86/x86/identcpu.c b/sys/arch/x86/x86/identcpu.c index 9a0acc41ad91..dc5d40ec3fb5 100644 --- a/sys/arch/x86/x86/identcpu.c +++ b/sys/arch/x86/x86/identcpu.c @@ -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 -__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_cpuid_l3cache_assoc_info[] = 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. diff --git a/sys/arch/x86/x86/pmap.c b/sys/arch/x86/x86/pmap.c index 0c46646f8f4e..f83f9fd9afd7 100644 --- a/sys/arch/x86/x86/pmap.c +++ b/sys/arch/x86/x86/pmap.c @@ -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 -__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; /* VA of last free KVA */ /* * 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 /* diff --git a/sys/arch/xen/x86/cpu.c b/sys/arch/xen/x86/cpu.c index b35e16d6797e..260eb6396905 100644 --- a/sys/arch/xen/x86/cpu.c +++ b/sys/arch/xen/x86/cpu.c @@ -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 -__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 __aligned(CACHE_LINE_SIZE) = { 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 diff --git a/sys/arch/xen/x86/x86_xpmap.c b/sys/arch/xen/x86/x86_xpmap.c index faec04d1f3cd..01a80e28df90 100644 --- a/sys/arch/xen/x86/x86_xpmap.c +++ b/sys/arch/xen/x86/x86_xpmap.c @@ -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 @@ -66,7 +66,7 @@ */ #include -__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_mapping; 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);