Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Sprinkle __cacheline_aligned and __read_mostly.
details: https://anonhg.NetBSD.org/src/rev/a7ca1787fe65
branches: trunk
changeset: 764943:a7ca1787fe65
user: rmind <rmind%NetBSD.org@localhost>
date: Fri May 13 22:16:43 2011 +0000
description:
Sprinkle __cacheline_aligned and __read_mostly.
diffstat:
sys/kern/kern_cpu.c | 17 +++++++++--------
sys/kern/kern_mutex_obj.c | 6 +++---
sys/kern/kern_rwlock_obj.c | 6 +++---
sys/kern/kern_synch.c | 18 ++++++++++--------
sys/kern/subr_percpu.c | 13 +++++++------
sys/kern/subr_xcall.c | 16 ++++++++--------
sys/kern/sysv_sem.c | 30 ++++++++++++++++++------------
sys/kern/vfs_vnode.c | 26 +++++++++++++-------------
8 files changed, 71 insertions(+), 61 deletions(-)
diffs (truncated from 325 to 300 lines):
diff -r 4b190a7f01d3 -r a7ca1787fe65 sys/kern/kern_cpu.c
--- a/sys/kern/kern_cpu.c Fri May 13 21:15:34 2011 +0000
+++ b/sys/kern/kern_cpu.c Fri May 13 22:16:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_cpu.c,v 1.45 2010/12/22 02:43:23 matt Exp $ */
+/* $NetBSD: kern_cpu.c,v 1.46 2011/05/13 22:16:43 rmind Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.45 2010/12/22 02:43:23 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.46 2011/05/13 22:16:43 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -103,13 +103,14 @@
D_OTHER | D_MPSAFE
};
-kmutex_t cpu_lock;
-int ncpu;
-int ncpuonline;
-bool mp_online;
-struct cpuqueue cpu_queue = CIRCLEQ_HEAD_INITIALIZER(cpu_queue);
+kmutex_t cpu_lock __cacheline_aligned;
+int ncpu __read_mostly;
+int ncpuonline __read_mostly;
+bool mp_online __read_mostly;
+struct cpuqueue cpu_queue __cacheline_aligned
+ = CIRCLEQ_HEAD_INITIALIZER(cpu_queue);
-static struct cpu_info **cpu_infos;
+static struct cpu_info **cpu_infos __read_mostly;
int
mi_cpu_attach(struct cpu_info *ci)
diff -r 4b190a7f01d3 -r a7ca1787fe65 sys/kern/kern_mutex_obj.c
--- a/sys/kern/kern_mutex_obj.c Fri May 13 21:15:34 2011 +0000
+++ b/sys/kern/kern_mutex_obj.c Fri May 13 22:16:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_mutex_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $ */
+/* $NetBSD: kern_mutex_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_mutex_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -47,7 +47,7 @@
static int mutex_obj_ctor(void *, void *, int);
-static pool_cache_t mutex_obj_cache;
+static pool_cache_t mutex_obj_cache __read_mostly;
/*
* mutex_obj_init:
diff -r 4b190a7f01d3 -r a7ca1787fe65 sys/kern/kern_rwlock_obj.c
--- a/sys/kern/kern_rwlock_obj.c Fri May 13 21:15:34 2011 +0000
+++ b/sys/kern/kern_rwlock_obj.c Fri May 13 22:16:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_rwlock_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $ */
+/* $NetBSD: kern_rwlock_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rwlock_obj.c,v 1.2 2010/03/31 19:59:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -47,7 +47,7 @@
static int rw_obj_ctor(void *, void *, int);
-static pool_cache_t rw_obj_cache;
+static pool_cache_t rw_obj_cache __read_mostly;
/*
* rw_obj_init:
diff -r 4b190a7f01d3 -r a7ca1787fe65 sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c Fri May 13 21:15:34 2011 +0000
+++ b/sys/kern/kern_synch.c Fri May 13 22:16:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.288 2011/05/02 00:29:53 rmind Exp $ */
+/* $NetBSD: kern_synch.c,v 1.289 2011/05/13 22:16:43 rmind Exp $ */
/*-
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.288 2011/05/02 00:29:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.289 2011/05/13 22:16:43 rmind Exp $");
#include "opt_kstack.h"
#include "opt_perfctrs.h"
@@ -128,13 +128,15 @@
syncobj_noowner,
};
-unsigned sched_pstats_ticks;
-kcondvar_t lbolt; /* once a second sleep address */
+/* "Lightning bolt": once a second sleep address. */
+kcondvar_t lbolt __cacheline_aligned;
+
+u_int sched_pstats_ticks __cacheline_aligned;
-/* Preemption event counters */
-static struct evcnt kpreempt_ev_crit;
-static struct evcnt kpreempt_ev_klock;
-static struct evcnt kpreempt_ev_immed;
+/* Preemption event counters. */
+static struct evcnt kpreempt_ev_crit __cacheline_aligned;
+static struct evcnt kpreempt_ev_klock __cacheline_aligned;
+static struct evcnt kpreempt_ev_immed __cacheline_aligned;
/*
* During autoconfiguration or after a panic, a sleep will simply lower the
diff -r 4b190a7f01d3 -r a7ca1787fe65 sys/kern/subr_percpu.c
--- a/sys/kern/subr_percpu.c Fri May 13 21:15:34 2011 +0000
+++ b/sys/kern/subr_percpu.c Fri May 13 22:16:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_percpu.c,v 1.12 2011/04/19 07:12:59 martin Exp $ */
+/* $NetBSD: subr_percpu.c,v 1.13 2011/05/13 22:16:44 rmind Exp $ */
/*-
* Copyright (c)2007,2008 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_percpu.c,v 1.12 2011/04/19 07:12:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_percpu.c,v 1.13 2011/05/13 22:16:44 rmind Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -58,10 +58,10 @@
#define percpu_decrypt(pc) (pc)
#endif /* defined(DIAGNOSTIC) */
-static krwlock_t percpu_swap_lock;
-static kmutex_t percpu_allocation_lock;
-static vmem_t *percpu_offset_arena;
-static unsigned int percpu_nextoff = PERCPU_QUANTUM_SIZE;
+static krwlock_t percpu_swap_lock __cacheline_aligned;
+static kmutex_t percpu_allocation_lock __cacheline_aligned;
+static vmem_t * percpu_offset_arena __cacheline_aligned;
+static unsigned int percpu_nextoff __cacheline_aligned;
static percpu_cpu_t *
cpu_percpu(struct cpu_info *ci)
@@ -217,6 +217,7 @@
ASSERT_SLEEPABLE();
rw_init(&percpu_swap_lock);
mutex_init(&percpu_allocation_lock, MUTEX_DEFAULT, IPL_NONE);
+ percpu_nextoff = PERCPU_QUANTUM_SIZE;
percpu_offset_arena = vmem_create("percpu", 0, 0, PERCPU_QUANTUM_SIZE,
percpu_backend_alloc, NULL, NULL, PERCPU_QCACHE_MAX, VM_SLEEP,
diff -r 4b190a7f01d3 -r a7ca1787fe65 sys/kern/subr_xcall.c
--- a/sys/kern/subr_xcall.c Fri May 13 21:15:34 2011 +0000
+++ b/sys/kern/subr_xcall.c Fri May 13 22:16:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_xcall.c,v 1.12 2010/06/22 18:29:01 rmind Exp $ */
+/* $NetBSD: subr_xcall.c,v 1.13 2011/05/13 22:16:44 rmind Exp $ */
/*-
* Copyright (c) 2007-2010 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.12 2010/06/22 18:29:01 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.13 2011/05/13 22:16:44 rmind Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -100,16 +100,16 @@
#define XC_PRI_BIT (1ULL << 63)
/* Low priority xcall structures. */
-static xc_state_t xc_low_pri;
-static uint64_t xc_tailp;
+static xc_state_t xc_low_pri __cacheline_aligned;
+static uint64_t xc_tailp __cacheline_aligned;
/* High priority xcall structures. */
-static xc_state_t xc_high_pri;
-static void * xc_sih;
+static xc_state_t xc_high_pri __cacheline_aligned;
+static void * xc_sih __cacheline_aligned;
/* Event counters. */
-static struct evcnt xc_unicast_ev;
-static struct evcnt xc_broadcast_ev;
+static struct evcnt xc_unicast_ev __cacheline_aligned;
+static struct evcnt xc_broadcast_ev __cacheline_aligned;
static void xc_init(void);
static void xc_thread(void *);
diff -r 4b190a7f01d3 -r a7ca1787fe65 sys/kern/sysv_sem.c
--- a/sys/kern/sysv_sem.c Fri May 13 21:15:34 2011 +0000
+++ b/sys/kern/sysv_sem.c Fri May 13 22:16:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysv_sem.c,v 1.86 2009/10/05 23:46:02 rmind Exp $ */
+/* $NetBSD: sysv_sem.c,v 1.87 2011/05/13 22:16:44 rmind Exp $ */
/*-
* Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.86 2009/10/05 23:46:02 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.87 2011/05/13 22:16:44 rmind Exp $");
#define SYSVSEM
@@ -59,18 +59,22 @@
* 3rd: Conditional variables
* 4th: Undo structures
*/
-struct semid_ds *sema;
-static struct __sem *sem;
-static kcondvar_t *semcv;
-static int *semu;
+struct semid_ds * sema __read_mostly;
+static struct __sem * sem __read_mostly;
+static kcondvar_t * semcv __read_mostly;
+static int * semu __read_mostly;
-static kmutex_t semlock;
-static struct sem_undo *semu_list; /* list of active undo structures */
-static u_int semtot = 0; /* total number of semaphores */
+static kmutex_t semlock __cacheline_aligned;
+static bool sem_realloc_state __read_mostly;
+static kcondvar_t sem_realloc_cv;
-static u_int sem_waiters = 0; /* total number of semop waiters */
-static bool sem_realloc_state;
-static kcondvar_t sem_realloc_cv;
+/*
+ * List of active undo structures, total number of semaphores,
+ * and total number of semop waiters.
+ */
+static struct sem_undo *semu_list __read_mostly;
+static u_int semtot __cacheline_aligned;
+static u_int sem_waiters __cacheline_aligned;
/* Macro to find a particular sem_undo vector */
#define SEMU(s, ix) ((struct sem_undo *)(((long)s) + ix * seminfo.semusz))
@@ -94,6 +98,8 @@
mutex_init(&semlock, MUTEX_DEFAULT, IPL_NONE);
cv_init(&sem_realloc_cv, "semrealc");
sem_realloc_state = false;
+ semtot = 0;
+ sem_waiters = 0;
/* Allocate the wired memory for our structures */
sz = ALIGN(seminfo.semmni * sizeof(struct semid_ds)) +
diff -r 4b190a7f01d3 -r a7ca1787fe65 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Fri May 13 21:15:34 2011 +0000
+++ b/sys/kern/vfs_vnode.c Fri May 13 22:16:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.5 2011/04/04 02:46:57 rmind Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.6 2011/05/13 22:16:44 rmind Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.5 2011/04/04 02:46:57 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.6 2011/05/13 22:16:44 rmind Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -115,20 +115,20 @@
#include <uvm/uvm.h>
#include <uvm/uvm_readahead.h>
-u_int numvnodes;
+u_int numvnodes __cacheline_aligned;
Home |
Main Index |
Thread Index |
Old Index